Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2004, 11:48 AM
Authorized User
 
Join Date: Jun 2004
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

 
Old November 11th, 2004, 12:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
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.

 
Old November 11th, 2004, 12:50 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
Old November 11th, 2004, 01:44 PM
Authorized User
 
Join Date: Jun 2004
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?

 
Old November 12th, 2004, 04:23 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
Old November 12th, 2004, 12:40 PM
Authorized User
 
Join Date: Jun 2004
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. :)






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





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