The Database Design Resource Center

Trainee

composite primary key

hdr table PK - > hdr ID
item table PK - > item ID

Line table PK -> hdr ID , item ID

This will create several issues. In my opinion, every table should have a unique ID within the system , which is not a business data , like ACC Number etc. Otherwise we are making a rigid system.

Comments for
Trainee

Average Rating star

Click here to add your own comments

Jan 02, 2009
Rating
star
Not so fast
by: Aaron Bingham

I completely disagree. You don't need to add a numeric ID unless you have an external requirement for one (except for rare exceptions, see below).

You must define at least one key for every table (unique constraint or primary key). This key can span multiple columns. Often, the key _must_ span multiple columns because of the nature of the data. If you cannot identify such a key, you don't understand your data yet. Study it again.

Overuse of surrogate keys can cause you trouble when:
* you forget to define any other keys (unique constraints) on the real data and you end up with duplicate data
* you are forced to perform many unnecessary joins, complicating queries and degrading performance
* you lack data from the key in a referring table that would allow definition of better constraints
* etc.

A numeric surrogate key (a key which does not arise from the external requirements) can be considered in certain circumstances exceptional circumstances. Cases where you might consider a surrogate key are:
* when a concrete performance bottleneck has been identified which cannot be addressed by other means (e.g., defining an index)
* when writing queries proves too cumbersome
* when repeating multiple columns of the key in referring tables threatens to cause a maintenance headache.
Don't jump into this too fast.

Click here to add your own comments

Join in and write your own page! It's easy to do. How?
Simply click here to return to Worst Database Design Experience



Interview with
Donald Burleson

Interview with
Steven Feuerstein


What visitors say...

"I just stumbled accross your site looking for some normalization theory and I have to say it is fantastic.

I have been in the database field for 10+ years and I have never before come across such a useful site. Thank you for taking the time to put this site together."

Mike, USA

Read more Testimonials

Free eBook

Subscribe to my newsletter and get my ebook on Entity Relationship Modeling Principles as a free gift:


Workshop

On rare occasions, I may perform a Database Design Workshop . Unfortunately, I am currently unable to, but maybe later...

Influence me

Influence the content on this site: I want to know what database information you need the most: Participate in my Database Design Content investigation. I would appreciate it if you took the time...

Database Normalization eBook:


Database Normalization eBook


XML RSS
Add to My Yahoo!
Add to My MSN
Add to Google


Site Build It!

ADD TO YOUR SOCIAL BOOKMARKS: add to BlinkBlink add to Del.icio.usDel.icio.us add to DiggDigg
add to FurlFurl add to GoogleGoogle add to SimpySimpy add to SpurlSpurl Bookmark at TechnoratiTechnorati add to YahooY! MyWeb

Copyright © 2004-2010 www.databasedesign-resource.com / Alf A. Pedersen
All rights reserved.
All information contained on this website is for informational purposes only.
*Disclaimer: www.databasedesign-resource.com does not warrant any company, product, service or any content contained herein.

Return to top

Copyright acknowledgement note:

The name Oracle is a trademark of Oracle Corporation.
The names MS Access/MS SQL Server are trademarks of Microsoft Corporation.
Any other names used on this website may be trademarks of their respective owners, which I fully respect.