I’m designing a database for shops. There’s a table for the shop branches and a table for the chain names:
Chains
id name
1 Wendy's
2 Henry's
3 Other
Branches
id chain_id name
1 1 East Hollywood // Wendy's East Hollywood
2 1 NYC // Wendy's NYC
3 2 NYC // Henry's NYC
In the end, I want to display stuff like “Wendy’s NYC” and “Henry’s East Hollywood”. This is fairly basic stuff.
My problem is that I want to have a chain called “Other”, where I can dump all the shops which aren’t numerous enough to give their own category. If a chain only has a couple of shops, it goes in “Other” so that the category list doesn’t get out of hand. But I still want to be able to display something like “Mom ‘n’ Pops NYC”. What’s the best database design for something like this? Is it easier to implement this in the code instead of the database? Thanks.
At present you are storing the name in Chains and the location in Branches.
You want a class of stores with no name in Chains, but still have a name, therefore you need somewhere to store that name.
There are various possibilities:
The third is probably the least useful, but any of them could work.