More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Sunday, April 12, 2009 3:55:45 AM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 11/23/2008(UTC)
Posts: 522

The three basic normalization principles of a relational database

1. 1st Normal - Exclude duplicated (basically the same structure, such as home and work addresses) columns in the same table. Implement the columns in the 2nd Normal form.
2. 2nd Normal - Create a separate table for each logical group of data. In this case, create a separate addresses table and connect the two tables with their primary keys. Find more information below.
3. 3rd Normal - Tables cannot include duplicate information. If two tables need a common field, a separate table should be created to manage that column.

Edited by user Wednesday, May 24, 2017 8:31:12 AM(UTC)  | Reason: Not specified

Sponsor
hong  
#2 Posted : Wednesday, May 24, 2017 8:19:05 AM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 11/23/2008(UTC)
Posts: 522

Composite Primary Keys

How would you define what a primary key of a table is?

a.    An auto-generated numeric or GUID column in the table that uniquely identifies each row
b.    A non-nullable column in the table that uniquely identifies each row
c.    None of the above

I suspect that many people will answer (a), and quite a few will answer (b).  If you answer (c), though, you are correct!  Why?  Because a primary key is not a single column, it is a set of columns.  Many people who have designed large, complicated systems are simply not aware of this.

Don't confuse Primary key with identity column. They are not the same. 

An identity column may be a type of primary key, but a primary key is not an identity column; it is a set of columns that you define that determine what makes the data in your table unique.  It defines your data. It may be an identity column, it may be a varchar column or a datetime column or an integer column, or it may be a combination of multiple columns.

 We also need to diffrentiate the following two table categories.

  • Tables that define entities: eg. Customer, Products
  • Tables that relate entities: eg. CustomerProducts

Tables that relate entities no need to have an additional surrogate key such as unique id column or GUID column, We should just use composite primary keys CustomerID, ProductID. This will also eliminate the need of unique constraint on the columns.

Code:
Primary key (CustomerID, ProductID)

More information

Does each table need a unique identifier and primary key?

Edited by user Wednesday, May 24, 2017 8:44:23 AM(UTC)  | Reason: Not specified

Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.