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.
| Author |
Topic |
|
KenA
Starting Member
28 Posts |
Posted - 2004-06-29 : 14:50:29
|
| Hi. I´d like to save User´s data into a table called Users, but I have at least 2 types of Users and they will have different table fields according to its type. Ex.========Users========UserIDUsernamePassword========A user of type==User01 will use the info in the Users table, plus:========User01========FullnameEmailTelephone========A user of type==User02 will use the info in the Users table, plus:========User02========CompanyNameAddressTelephoneFax========I could use just 1 table (the Users table) and save info for both user types, but depending of the type of user I´m saving info, some fields will be left blank/null, so I believe that I need a way to to have separate tables to save the user details according to the user type and a main table where I save the UserID,Username and Password because those fields are common to any kind of user.I would appreciate receiving some tips regarding these issues...»»» Ken.A |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-29 : 15:32:32
|
| And the answer is....yesThere are differences between logical and physical implementation.Logical: The 2 tables...with the common data stored in the single tablePhysical: Well that's where things get f=grey...the closer you can stay to the logical the better...my opinion...but there could be some BIG road blocks...How much data...how many "splits" to you logically need to make...what is the expected level of transactions...lots of reasonsAnd what are the "types" anyway..please don't store 01 and 02 in the database..they must have some meaning...Brett8-) |
 |
|
|
KenA
Starting Member
28 Posts |
Posted - 2004-06-29 : 15:51:18
|
| Ok ... but I still need some design samples for those tables including PK and FK and the relationships.»»» Ken.A |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-29 : 16:07:20
|
| [code]DROP TABLE myUsertype2goCREATE TABLE myUsertype2 ( myUserId char(18) NOT NULL, LoginId char(18) NOT NULL, CompanyName char(18) NOT NULL, ect char(18) NOT NULL)goALTER TABLE myUsertype2 ADD PRIMARY KEY (myUserId)goDROP TABLE myUserType1goCREATE TABLE myUserType1 ( myUserId char(18) NOT NULL, Email char(18) NULL)goALTER TABLE myUserType1 ADD PRIMARY KEY (myUserId)goDROP TABLE myUser99goCREATE TABLE myUser99 ( myUserId char(18) NOT NULL, myUserEct char(18) NOT NULL, myUserName char(18) NOT NULL, myUserType char(18) NOT NULL)goALTER TABLE myUser99 ADD PRIMARY KEY (myUserId)goALTER TABLE myUsertype2 ADD FOREIGN KEY (myUserId) REFERENCES myUser99goALTER TABLE myUserType1 ADD FOREIGN KEY (myUserId) REFERENCES myUser99go[/code]Brett8-) |
 |
|
|
KenA
Starting Member
28 Posts |
|
|
|
|
|
|
|