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
 Transact-SQL (2000)
 designing a table !!

Author  Topic 

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-10-09 : 05:52:21
I have to store the features for a user ,these features are predefined and I have a master table which has the id associated with each feature and I have a id for each feature.Now one user can have multiple features ,so I have to design a table to store these features related to each user.
there are 25 features ,so if I take one field for each feature and one for the userId ,the number of columns become 26 .is this the right way to do it ??
please advice.
harshal.

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-10-09 : 08:37:12
That's one way to do it but you will have to change your table schema if the number of features changes.

Another way is to have 3 tables.

Table 1 - the users
Table 2 - the features (in rows)
Table 3 - the user id and related feature id in rows.

This way if a new feature is added, just add another row to Table 2.

Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-10-09 : 09:24:47
but here the table size would grow a lot ,I am afraid at the end of the year I may end with a huge table.
either ways ,if I choose my option the number of columns increase and if i choose the second option of having three tables the number of rows increases.so what is recomended???
please advice.
thnxs.
harshal

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-09 : 09:40:05
You'll use about the same amount of space with either structure. Moreover, you'll WASTE a lot of space using one table if certain users do not use all 25-26 features. You're much better off following Scott's suggestion. Not only is his design more efficient and modifiable, it's far more flexible when searching for users who match a certain set or number of features (and will search a lot faster than one wide table)

Edited by - robvolk on 10/09/2002 09:41:22
Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-10-10 : 07:17:43
thanks a lot!!!

Go to Top of Page
   

- Advertisement -