exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 25 discussion

Actual exam question from Microsoft's 70-487
Question #: 25
Topic #: 1
[All 70-487 Questions]

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:

Show Suggested Answer Hide Answer
Suggested Answer:
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.
References:
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
tiger25
Highly Voted 5 years, 4 months ago
Table-per-concrete class - answer 3. "Vehicle is an abstract class" - I don't see it in requirements so it's a non-abstract class hence three tables.
upvoted 10 times
...
TinaZh
Highly Voted 5 years, 4 months ago
Why "Vehicle" is abstract? There is no such information...
upvoted 8 times
Juanjo
4 years, 7 months ago
I believe vehicle is asumed to be abstract since a vehicle could be a motorboat or a plane, not only a car. If you had to instantiate a vehicle but couldn't give details about *what kind* of vehicle should it be, how would you do it?
upvoted 1 times
SirMarv
4 years, 5 months ago
....you are right, but in programming, we dont assume. Every unique line of code produces a unique set of results, no matter how similar the scenarios might be.
upvoted 1 times
...
...
...
Natali
Most Recent 5 years ago
Even more, the hierarchy is Car: Vehicle and SportsCar:Car so Car is not the only candidate of being abstract - Vehicle can also be one. And SportsCar aswell. So it should be 3 because nothing is said about these cases
upvoted 2 times
pipujagyan
5 years ago
Given answer about TPH is correct "TPH uses a single table to store the data for all types in the hierarchy, and a discriminator column is used to identify which type each row represents." https://docs.microsoft.com/en-us/ef/core/modeling/inheritance#:~:text=At%20the%20moment%2C%20EF%20Core,which%20type%20each%20row%20represents.
upvoted 1 times
...
...
SirMarv
5 years, 2 months ago
i also think that Table-per-concrete should be 3 since we are not told anything about the Vehicle class being abstract, for all we know, Vehicle is just a base class for the hierarchy.
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...