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)
 table design

Author  Topic 

knappn
Starting Member

1 Post

Posted - 2003-03-22 : 20:18:23
I 2 types of users, members and employees. Both have the same attributes, such as login, password, address etc., but there are other attributes that are specific to each. Do I make 1 table to hold both type of users's information or do I make 2 tables, one for members and one for employees?

Thanks,
Nick

nr
SQLTeam MVY

12543 Posts

Posted - 2003-03-22 : 20:35:18
users(Id, loginID, Password, address)
member(UserId, ...)
Employee(UserId, ...)

You might want to put the address into another table as you usually want more than one address per entity with the same format.

Anything with a login and password should usually be in the same table as these have specific requirements. You would normally expect the security info (login/password) to be in a separate table (maybe with other security info) as this is crucial to the system.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-03-23 : 01:58:11
nr is right, the security info should be maintained in a different table (you could deny select on the table to all database user other than your one used by your application). But there would be a caveat in creating two different tables for this particular scenario: if you had a userid, and wanted to retreive the corresponding information, you would have to scan through two tables (members & employees), to find the corresponding personal information. Of course, you could do a UNION on the two tables, but then you wouldnt know what columns to select, and some of the columns in members might not map to any of the columns in employees.

If you dont have too many specific attributes, another solution is to have a generic Person table, and add all the columns for both members and employees, and have a PersonType column. You could either use static values for the PersonType or create another table to hold Person Types.

Table Users (UserID, Password, columns...)
Table Person (UserID, FirstName, LastName, <member columns>, <employee columns>, PersonTypeID, etc...)
Table PersonType (PersonTypeID, PersonTypeDesc)

OS



Go to Top of Page
   

- Advertisement -