How many tables should you identify?

HOTSPOT
You are developing a web application that will store data in an Azure SQL Database.
The application will contain three classes named Vehicle, Car, and SportsCar. Car will inherit the Vehicle class.
SportsCar will inherit the Car class.
You plan to create the table structure for the three classes by using mapping strategies in the Entity
Framework.
You need to identify how many tables will be created by each mapping strategy.
How many tables should you identify? To answer, select the appropriate options in the answer area.
Hot Area:

HOTSPOT
You are developing a web application that will store data in an Azure SQL Database.
The application will contain three classes named Vehicle, Car, and SportsCar. Car will inherit the Vehicle class.
SportsCar will inherit the Car class.
You plan to create the table structure for the three classes by using mapping strategies in the Entity
Framework.
You need to identify how many tables will be created by each mapping strategy.
How many tables should you identify? To answer, select the appropriate options in the answer area.
Hot Area:

Answer:

Explanation:
Box 1: Table-per-type: 3
Table per Type is about representing inheritance relationships as relational foreign key associations. Every
class/subclass that declares persistent properties—including abstract classes—has its own table. The table for
subclasses contains columns only for each noninherited property (each property declared by the subclass itself)
along with a primary key that is also a foreign key of the base class table. This approach is shown in the
following figure:

Box 2: Table-per-hierarchy: 1
Table-per-hierarchy (TPH) inheritance uses one database table to maintain data for all of the entity types in an
inheritance hierarchy.
Box 3: Table-per-concrete class: 2
In Table per Concrete type (aka Table per Concrete class) we use exactly one table for each (nonabstract)
class.
Vehicle is an abstract class, while car and sportscar and nonabstract classes.

https://weblogs.asp.net/manavi/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-
table-per-hierarchy-tph
https://msdn.microsoft.com/en-us/library/jj618292(v=vs.113).aspx



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Rick

Rick

it did not say Vehicle is a abstract class…

bt

bt

car is also abstract probably so last one can be 1 as well.

Larsen

Larsen

Besides vehicle not mentioned as abstract in the task, it seems fine.