I believe all of us seen this design requirement in one form or another.
Software needs to offer a user several answer options for various questions/settings. These options reside in the database. In a big project a number of such questions can easily surpass 50.
Now.
Is it okay to have 50+ tables with the identical design like this?
CREATE TABLE [dbo].[Setting1]
(
[ID] uniqueidentifier NOT NULL,
[Name] varchar(max) NOT NULL
)
CREATE TABLE [dbo].[Setting2]
(
[ID] uniqueidentifier NOT NULL,
[Name] varchar(max) NOT NULL
)
etc.
and then have these tables linked via foreign key like this:
CREATE TABLE [dbo].[UserSettings]
(
[UserID] uniqueidentifier NOT NULL,
[Setting1ID] uniqueidentifier NOT NULL,
[Setting2ID] uniqueidentifier NOT NULL
)
Or is it more sensible to create one "master" options table?
CREATE TABLE [dbo].[Setting]
(
[ID] uniqueidentifier NOT NULL,
[Name] varchar(max) NOT NULL
[SettingCode] int NOT NULL
)
What are advantages and disadvantages besides having to multiply tables with similar structure in the first cases and having no integrity constraints in the other?