Database Reference
In-Depth Information
STUDENT
STUDENT_CLASS
COURSE
COURSE_PREREQUISITE
CourseID (FK)
StudentID
StudentID (FK)
ClassID (FK)
P
CourseID
FirstName
Prerequisite (FK)
P
CourseName
LastName
FacultyID (FK)
Grade
Credit
FACULT Y
CLASS
FACULT Y_CLASS
CLASS_CLASSROOM
ClassID (FK)
BuildingID (FK)
P
Class ID
FacultyID (FK)
FacultyID
TimeID (FK)
Class ID (FK)
FirstName
P
CourseID (FK)
SemesterID (FK)
ClassroomID (FK)
LastName
P
DayID (FK)
CLASSROOM
DAYS
TIMEBLOCK
SEMESTER
BUILDING
ClassroomID
DayID
TimeID
SemesterID
BuildingID
BuildingId (FK)
P
We ekDay
TimeBlock
BuildingName
Semester
Capacity
Figure 3.24
Class registration data model.
Relationship constraints : Used to implement relationships by enforcing referential integrity
and cardinality among the related tables.
Uniqueness constraints : Used to enforce uniqueness for the values entered in a column.
Domain constraints : Used to control the values entered in a column.
Business rules : Used to enforce a company's policies and regulations.
here are two types of relationship constraints: the integrity constraint and cardinality con-
straint . he foreign key and primary key constraint is used to enforce the integrity constraint. As
described in the previous sections, a relationship can be represented by a primary key and foreign
key. herefore, a relationship can be implemented by enforcing the integrity constraint. When
creating tables, you can enforce the integrity constraint by creating the primary key and foreign
key constraint. When deining the foreign key constraint, you can specify the parent table and the
column shared by the primary key and the foreign key. After the integrity key constraint is created,
the connection between the parent table and child table is established.
When you insert, update, or delete data in a table, some measures may be needed to protect the
integrity of the database. For example, when a new row is inserted into a table, you want to make
sure that there are no duplicated rows in the table. Or, when a row is updated in the child table,
you want to be sure that the foreign key value matches one of the primary key values in the parent
table. Most DBMSs provide options that allow you to conigure the constraints needed to prevent
undesirable values from being entered in a table. Windows Azure SQL Database can automati-
cally enforce the integrity constraint if an integrity constraint violation occurs during a process of
inserting, deleting, or updating.
When specifying how many rows in one table can be associated with each row in another
table, you need to enforce a cardinality constraint. Cardinality constraints are often created based
on business rules. Programming is commonly used to implement the complex logic enforced by
Search WWH ::




Custom Search