G
Gareth
Hi NG,
I'm revisiting one of my applications and was wondering whether I
could/should normalize table that stores configuration data. I have over
20 different fields of configuration data that I store in one table,
with one row for the System Defaults (or data unique to the system) and
then one row for each user where I store their customized settings.
For example, currently:
tblSystemConfig
-----------------
UserID (foreign key from tblUsers - or 0 if SystemDefault)
DBName (Only used for System)
DBVersionNo (Only used for System)
AppFormWidth (Numeric - SystemDefault)
AppFormHeight (Numeric)
AppIsMaximized (Boolean)
BackGroundColor (Numeric)
DisplayStart (Date)
DisplayEnd (Date)
etc. ~ 25 fields: some dates, boolean, strings, numbers (also some BLOBs
for bitmaps and things but I can keep them separate anyway)
In order to normalize I suppose I should do something using three
tables, one for the system settings, one for users and one for setting
types e.g.
tblSettingTypes
---------------
SettingID
SettingName (e.g. DisplayStart, AppFormWidth)
tblSystemSettings
---------------
SettingID (foreign key from tblSettingTypes)
SettingValue
tblUserSettings
---------------
UserID (foreign key from tblUsers)
SettingID (foreign key from tblSettingTypes)
SettingValue
This would definitely be more normalized but is slightly longerwinded
when I load or update settings - I can no longer just say "SELECT * FROM
tblSettings WHERE UserID = 0" for example. I have to stipulate exactly
which fields I want so that I get them in the right order. (I think
using ORDER BY SettingName or SettingID is workable but... not exactly
nice.)
Note that the SettingValue may be a date, boolean, string or number.
However, I thought I could get away with having the SettingValue field
as Text (as in Duane Hookum's survey example DB) and then coercing to
the correct datatype in my front end (VB app, connecting thru ADO).
Is this recommended or should I make separate tables
tblUserSettingsDates, tblUserSettingsBoolean, tblUserSettingsStrings
etc. with the correct datatype for the SettingValue field?
Any thoughts on recommended working practises gratefully received.
Thanks
Gareth
I'm revisiting one of my applications and was wondering whether I
could/should normalize table that stores configuration data. I have over
20 different fields of configuration data that I store in one table,
with one row for the System Defaults (or data unique to the system) and
then one row for each user where I store their customized settings.
For example, currently:
tblSystemConfig
-----------------
UserID (foreign key from tblUsers - or 0 if SystemDefault)
DBName (Only used for System)
DBVersionNo (Only used for System)
AppFormWidth (Numeric - SystemDefault)
AppFormHeight (Numeric)
AppIsMaximized (Boolean)
BackGroundColor (Numeric)
DisplayStart (Date)
DisplayEnd (Date)
etc. ~ 25 fields: some dates, boolean, strings, numbers (also some BLOBs
for bitmaps and things but I can keep them separate anyway)
In order to normalize I suppose I should do something using three
tables, one for the system settings, one for users and one for setting
types e.g.
tblSettingTypes
---------------
SettingID
SettingName (e.g. DisplayStart, AppFormWidth)
tblSystemSettings
---------------
SettingID (foreign key from tblSettingTypes)
SettingValue
tblUserSettings
---------------
UserID (foreign key from tblUsers)
SettingID (foreign key from tblSettingTypes)
SettingValue
This would definitely be more normalized but is slightly longerwinded
when I load or update settings - I can no longer just say "SELECT * FROM
tblSettings WHERE UserID = 0" for example. I have to stipulate exactly
which fields I want so that I get them in the right order. (I think
using ORDER BY SettingName or SettingID is workable but... not exactly
nice.)
Note that the SettingValue may be a date, boolean, string or number.
However, I thought I could get away with having the SettingValue field
as Text (as in Duane Hookum's survey example DB) and then coercing to
the correct datatype in my front end (VB app, connecting thru ADO).
Is this recommended or should I make separate tables
tblUserSettingsDates, tblUserSettingsBoolean, tblUserSettingsStrings
etc. with the correct datatype for the SettingValue field?
Any thoughts on recommended working practises gratefully received.
Thanks
Gareth