This is a simplified version of my database, with the actual problem applied to a different subject area.
开发者_如何学GoI have four tables: Libraries, Books, Keepers, and another table, Keepers_Sections_Permissions, that tracks which Sections a Keeper can work in. Sections are predefined, and the number of them are known ahead of time. Let's call them Science, Math, and English.
Libraries have Books (no surprise there), with each Book storing a reference to which Section it is in.
My question is, do I need a Sections table? Every library has the same Sections, with the same name. They are known ahead of time, so I won't need to populate them from my database.
Keepers_Sections_Permissions needs to reference the Section somehow, so I'm not sure if my primary key should be the name of the Section, or a unique number pointing to a Sections table (a lookup table, really).
I would say yes. It would make the system more scalable to have the sections defined in a separate table and will benefit the Keepers_Sections_Permissions table.
My question is, do I need a Sections table?
You make it sound like a good use-case for an enum, but...
Every library has the same Sections, with the same name.
Sorry, but no. They just don't. Or maybe US libraries do; bookstores on this side of the Atlantic certainly don't.
精彩评论