I'm fairly new to database design, but I understand the fundamentals. I'm creating a relational database and I'd like to do something similar to creating a reusable type or class. For example, let's say I have a Customer
table and a Item
table. Customer and Item are related by a standard 1-to-many relationship, so Item has a column called CustomerId
.
I'd also like to have multiple "notes" for each Customer and each Item. In an normal OOP model, I'd just create a Note
class and create instances of that whenever I needed. Of course, a relational database is different. I was thinking about having a Note
table, and I'd like a 1-to-many relationship between Customer and Note, as well as Item and Note. The problem then is that the Note table will have to have a column for each other table that wishes to use this "type". (see example below)
I also thought that instead, I could create an intermediate table between Note and Customer/Item (or others). This would allow me to avoid having extra columns in Note for each table referencing it, so note could remain unchanged as I add more tables that require notes. I'm thinking that this is the better solution. (see example)
How is this sort of situation usually handled? Am I close to correct? I'd appreciate any advice on how to design my database to have the sort of functionality I've described above.