Reputation: 1810
I have the following trouble: https://technet.microsoft.com/en-us/library/Aa224923.howmanystoomanyfigure_01(l=en-us,v=sql.80).gif
In this image I saw model of realization supertype and subtype relationship.
Question is: if I know VehicleID and how to know exactly which kind of vehicle is it? The way I so is to write select to each table ( but it looks really ugly). Or maybe to write help table to know which type is it, but I'm not sure. Can anyone suggest a better solution?
Upvotes: 1
Views: 267
Reputation: 9353
The Vehicles table has a 'type' column. This would have values in such as 'truck', 'car', 'motorcycle' and tells your code which table to query for the rest of the data.
Because the columns in the sub tables are different. I would recommend looking up the type in the Vehicles table before using a second query to get the type specific data.
Upvotes: 1