1

What is it called in a relational database when you have a class or entity which has multiple sub-classes? That is not a very clear question so let me give an example.

In my database i have a table called Vehicle

I also have a table called Motorbike I also have a table calle Car

Both tables Car and Motorbike have a one-to-one relationship with Vehicle. That is to say that every Vehicle is one of either a Motorbike or a Car. In the Vehicle table they share common attributes such as vehicle.colour and vehicle.price, and in their respective 'sub-class' tables they have their individual attributes, such as car.number_of_seatbelts.

I am looking for the correct terminology to describe this relationship within a database, so that i may find documentation on how to (and how not to) implement it.

Thanks.

teebagz
  • 656
  • 1
  • 4
  • 26
  • 1
    You are talking about the generic notion of subtyping. Related to is-a, inheritance & polymorphism. [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) It's a special case of a hierarchical relationship where we have a hierarchy of types. [What are the options for storing hierarchical data in a relational database?](https://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database) – philipxy May 02 '19 at 08:59
  • That helps, Thanks! – teebagz May 02 '19 at 09:07
  • 1
    " Car and Motorbike have a one-to-one relationship with Vehicle." Better to say each has a zero-or-one-to-one relationship with vehicle. Those are sometimes called 'auxiliary' tables. I'd expect them to share a key (Vehicle identifier) so it's a foreign key from Car to Vehicle. The fancy name for that is 'Inclusion Dependency' https://en.wikipedia.org/wiki/Referential_integrity#Formalization. – AntC May 03 '19 at 01:32

0 Answers0