Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 11th, 2004, 11:48 AM
Authorized User
 
Join Date: Jun 2004
Location: Georgetown, Selangor, Malaysia.
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default Database question

I want to create a database which, involving user information. I have three types of user, i.e. Staff, Customer and Owner. For me, there are two ways to create the database for this.

The first way is, I create separate table each for Staff, Customer, and Owner. The table names and attributes are as below:

Staff (SSN, FName, LName)
Customer (SSN, FName, LName)
Owner (SSN, FName, LName)

And the second way is, I create only one table with the added attribute "UserType" to differentiate different kind of users as below:

User (SSN, FName, LName, UserType)

I have got advice from many others and what they told me is that I cannot create new table as I like such as in First solution abovemetioned, rather they suggest me to use the second solution as above.

Of course I know that to have one table is much neater and easier to maintain if compared to many tables. But I have doubt about the performance if I would have only one table. Just imagine that all the user information disregarding Staff, Customer and Owner are to be placed in just one table rather in three separate tables (e.g. 10,000 rows of tuple mass up together). For me, I prefer second solution as I think that it is easier to maintain in long run and may keep up the performance of database.

However, I still hope that anyone can share me your idea on this matter, thank you.

Regards,
Chuah

Reply With Quote
  #2 (permalink)  
Old November 11th, 2004, 12:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

We have tables that have 100,000 users. It all depends on your DB.

Listen to your friends and go with the 2nd solution.

Reply With Quote
  #3 (permalink)  
Old November 11th, 2004, 12:50 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I would prefer the second solution. The only advatage of the first is if you have a person who could be of more than one type, i.e. a customer and an owner. You could however have a single table of person details and a second table of types, then a table joining the two with the ID's of both the person and the type. If you're never going to have people in more than one category this would make things over complicated.



--

Joe (Microsoft MVP - XML)
Reply With Quote
  #4 (permalink)  
Old November 11th, 2004, 01:44 PM
Authorized User
 
Join Date: Jun 2004
Location: Georgetown, Selangor, Malaysia.
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Ok, so the second solution is better in this case.

 
Quote:
quote:The only advatage of the first is if you have a person who could be of more than one type, i.e. a customer and an owner.


Does "a person who could of more than one type" mean such this as well:

It is best to use first solution if, for example, Staff details which may further categorized to Temporary Staff and Permanent Staff?

Reply With Quote
  #5 (permalink)  
Old November 12th, 2004, 04:23 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by hlchuah77
 Ok, so the second solution is better in this case.

Quote:
quote:The only advatage of the first is if you have a person who could be of more than one type, i.e. a customer and an owner.
Does "a person who could of more than one type" mean such this as well:

It is best to use first solution if, for example, Staff details which may further categorized to Temporary Staff and Permanent Staff?
Not really, you could still have different types for both these categories. The problem only arises when a person can be both a temporary meber of staff and a customer for instance. Now you will get duplicated data unless you go with the three table approach.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #6 (permalink)  
Old November 12th, 2004, 12:40 PM
Authorized User
 
Join Date: Jun 2004
Location: Georgetown, Selangor, Malaysia.
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Thanks a lot, Joe. Thanks for your valuable opinion. :)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Question rose77 Access 0 January 9th, 2005 02:14 PM
Database question! Calibus Classic ASP Databases 3 August 17th, 2004 05:23 PM
HELP database question TnTandyO Classic ASP Databases 0 December 1st, 2003 12:39 PM
database question. kyootepuffy Classic ASP Databases 5 September 29th, 2003 03:11 PM
database question writedom VS.NET 2002/2003 2 July 29th, 2003 05:58 AM



All times are GMT -4. The time now is 09:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.