Data Relationships

esse quam videri
Jump to: navigation, search


Types of Data Relationships

one-to-many

Single primary key has many foreign keys. A person many have many email addresses.

The relationship is created in the diagram too by dragging on primary key to the foreign key.

OneToMany.png

one-to-one

A Single primary key may only have on foreign key. A sweater can only be one color.

many-to-many

A junction table is used to normalize data. A student may take many courses and a course may have many students.

ManyToManyStudentCourses.png

Notice the compound key in the StudentCourses table.

This compound key consists of two foreign keys. One form the Student table and one from the Course table. This allows a student to have many courses and a course to have many students. To make this example complete we could add a third foreign key from a semesters table that allows students to retake a course in a new semester. I'll leave this till later.

A person may also have many roles in a logon system.

ManyToMany.png