Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Database Design - Storing flags

Author  Topic 

appzguy
Starting Member

1 Post

Posted - 2006-06-09 : 15:24:00
Quick question about design:

We have an event which requires a lot of flags. Each event belongs to one customer. The flags describe the current processes that need to be handled for each event.

Which is a better design?

A table which will have one row with multiple columns for each flag.

Or

A table which will have multiple rows - one row for each flag.

Any thing I should be on the lookout for before committing myself to one design?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-09 : 15:26:51
second alternative. most versatile. also possible to store additonal meta data, such as apply date, confirmation date and so one...
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-06-09 : 15:27:43
I vote for rows



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-06-09 : 16:05:34
+1 for rows
If you ever need more flags, it's easy to add a row. Adding columns and changing your application to handle that is more complicated. That coupled with the fact that a row in SQL server can only be 8000 bytes and I think you can only have 255 columns, means rows is probably a better choice.

Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>

Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-10 : 06:55:11
Also read about Normalisation
http://www.datamodel.org/NormalizationRules.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cmdr_skywalker
Posting Yak Master

159 Posts

Posted - 2006-06-12 : 02:27:09
what type of flags and how many flags do you have? if yes/no and less than 63, you can use just one column. There's a little trick about it but it works.

Else, use the row, applying the metadata techniques (ie. table eventflags(eventid, flagname, flagvalue)).

May the Almighty God bless us all!
Go to Top of Page
   

- Advertisement -