Please consider offering answers and suggestions to help other students!
And if you fix a problem by following a suggestion here,
it would be great if other interested students could see a short
"Great, fixed it!" followup message.
Hi Teaching Team,
I have a question regarding how to translate superclass/subclass related relationship types into SQL.
Take the following relation as an example:
PropertyForRent(propertyNo,street,city,postcode,type,room,rent,ownerNo)
Primary Key propertyNo
Foreign Key ownerNo references PrivateOwner(ownerNo) and BusinessOwner(ownerNo)
the foreign key ownerNo references two tables, PrivateOwner and BusinessOwner. How should we build the SQL database from this? My initial thought was to create a joint table, but if we do that, it seems there would be little point in splitting the table in the first place.
I’m wondering if there is a standard approach to such problems.
Thank you for your help!
considering practicality of implementation, i would have a combined table with following attributes
OwnerNo OwnerType OwnerName
001 Private Joe D
002 Business XYZ PTY LTD
003 Private James
and will use OwnerNo as foreign key.
Hi,
The standard approach has been discussed in the lecture under logical modeling. However, it is also possible to deviate from the standard approach. You need to look at the connections between the subclasses/superclass with rest of the ER model. If the standard approach creates an inconsistency (refer to the example from university case study), then you can deviate from the standard approach. Options were discussed in the Lecture.
Cheers