I am currently designing an extension to the "Bar Beer Drinkers" database (one that is often used to teach basic SQL Queries).
As part of the design I have created entities that follow the "ISA" pattern, specifically: "Beers," "Food," and "OtherItems" are all "subclasses" of "Item."
The other entity that is involved is the Bars entity.
Between Bars and Items I have a relationship entity called "Sells".
The Schema for these tables are as follows:
Bar[ID(pk), Name, State, Address, Phone, Open, Close]
Beers[Name(pk), Manf]
Food[Name(pk), Manf]
OtherItems[Name(pk), Manf].
As it stands I do not have a table named "Items."
For the Sells table the schema is:
Sells[barID(fk), item(fk), price]
I was hoping to map the PKs from the three tables all into the "item" column in sells. Aka I could put a beer name in it, a food name in it, or an otheritem name in it.
This does not seem to work in MySQLWorkBench as it does not allow me to reference mutltiple foreign keys to the same column.
My potential fix to this problem was to have something like:
Sells[barID{fk), beerItem(fk), foodItem(fk), otherItem(fk), price]
However this would result in every tuple having at least two null values. Is this acceptable? What is the preferred way to include an "ISA" relationship in a relation entity for SQL?