The Artima Developer Community
Sponsored Link

Design Forum
Database normalization

1 reply on 1 page. Most recent reply: Sep 21, 2005 6:05 AM by Dhrubo

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Dallas Moore

Posts: 1
Nickname: dallas
Registered: Jun, 2005

Database normalization Posted: Jun 25, 2005 8:17 PM
Reply to this message Reply
Advertisement
I'm a rookie here trying to clearly grasp the concept of normalizing data in a relational model.
I want to buid a client database with contact info. How could I better normalize this table or is it OK the way it is? I'm using the email address as a primary key. Are there any issues that I might run into with this table? Should I split it up into more tables?

Client_contact_table:

First_Name: VARCHAR (20)
Last_Name: VARCHAR (20)
Business_Name: VARCHAR (60)
Email: VARCHAR (60)
Address_1: VARCHAR (60)
Address_2: VARCHAR (40)
City: VARCHAR (40)
State: VARCHAR (2)
Zip: SMALLINT
Phone: VARCHAR (20)

Please give some advise because after this I have a lot more complex tables to create. I just want to make sure I understand.


Dhrubo

Posts: 32
Nickname: dhrubo
Registered: Mar, 2003

Re: Database normalization Posted: Sep 21, 2005 6:05 AM
Reply to this message Reply
Hi Dallas,
This is not a correct DB design. Your design is a denormalised one and is very cramped.
Ideally there should be two tables
1> TBL_Client
2> TBL_Client_Contact
TBL_Client
----------
Client_id NUMBER(20) Primary Key
First_Name: VARCHAR (20) Not Null
Last_Name: VARCHAR (20)Not Null
Business_Name: VARCHAR (60)Not Null

TBL_Client_Contact
------------------
Client_id NUMBER(20) Primary Key
Contact_id NUMBER(20) Primary Key
Email: VARCHAR (60)
Address_1: VARCHAR (60)
Address_2: VARCHAR (40)
City: VARCHAR (40)
State: VARCHAR (2)
Zip: SMALLINT
Phone: VARCHAR (20)

This table has a composite primary key. I have kept the client_id column as the first column of the PK, as most searches in this table will happen based on client_id, so this will ensure a index range scan in selects.

Please note e-mails can be used as PK, but its ideal to have id or number columns as the PK as number comparison is more efficient than string comparison.

This probably shows you how to normalise your db design.
But be careful too much normalisation may cause performance bottlenects, so you need to be careful and make intelligent trade-off and denormalisation

Flat View: This topic has 1 reply on 1 page
Topic: Request opinions on database structure Previous Topic   Next Topic Topic: PATTERN == GOLDEN RATIO

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use