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)
 Question on Denormalizing and Multiple Table Joins

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-04-11 : 07:17:53
Stan writes "I have been reading the forums about creating denormalizing, primary keys, surrogate keys etc and it has got me really confused.

I have just started work for a company converting a Visual FoxPro database to SQL Server, but i am completely new to database design, although i know the principles.

With the existing table structure, I have tried to normalize, and split out fields where we don't have the data, to avoid having too many nulls, and having one large table with many columns, e.g

Table Contact_Name
Contact_Key int identity all
Title
Forename
Othernames
Surname

Table: Contact_Address (a person may have more than one address)
Contact_Address_ID identity (just for uniqueness)
Contact_Key - links to Contact_Name
Address1
Address2
Address3
Address4
Address5

Table:Contact_Personal
Contact_Key (links to Contact_Name)
DOB
Gender
Marital_Status
Uk_Tax_Payer

table:Contact_Phone (a person may have more than one phone number or none)
Contact_Phone_ID identity (just for uniqueness)
Contact_Key
Phone_Num
Type

There are a lot more tables than this. This will result in multiple joins on Contact_Key when trying to retrieve the data. Is this a bad thing? Or should i denormalize the data, and just live with the fact that many columns will have null values? How many columns is too many to have in a table. Plus should I not be using an identity key as a primary key?

I am sorry for asking an obvious question, and not phrasing it very well."

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-04-11 : 08:02:32
One thing I would is:

Create a table of Address_Types, with values like:

Business
Home
Billing
..etc..

And then for your address table, instead of an identity as your primary key, I would have a composite key of Contact_Key and Address_Type. I would do the same with phone numbers as well; i.e., a table of PhoneNumberTypes:

Home
Work
Cell
Fax

Try to use as many natural keys as possible. I personally feel that for people or companies, coming up with a numeric key of some sort (be it an identity or someone just typing one in while doing data entry) is a good idea, but some people prefer to use natural keys for that as well, such as FirstNameLastName or CompanyName.

But you appear to be on the right track.

Good luck!

Side note: with the table of address types, you can put other fields in there to make those types more meaningful, such as "InvoiceWeight" where each type has a weight, and the highest weighted address for a contact has is the one you send the invoices to, or fields of that nature.

- Jeff
Go to Top of Page
   

- Advertisement -