How can you model a ratio of zero, one, or many types without breaking the first normal form? That is, without storing any NULL values.
Separate relationship table? Is it “worth” adding a table, or is it excessive normalization?
Here is an example that fits my real case:
Say we have a college, with some free courses and some free dorms. Some of the courses and dorm rooms are indeed paid. And many of the courses and rooms have the same fee, although they are different courses / rooms.
So, we will have:
tblCourse
Id
Name
tblDormRoom
Id
Address
tblFee
Id
Amount
To simulate this, I decided to add two tables to store an optional one-to-many relationship.
tblCourseToFee
CourseId
FeeId
tblDormRoomToFee
DormRoomId
FeeId
, , , DormRoom .
n , 1NF:
tblFee
Id
CourseId (nullable)
DormRoomId (nullable)
Amount
, .