Chapter 3 – Table Index and Constraint

1.Index
-As we know that PK is the unique constraint in a table.
-If we want to make one or more columns that are NOT keys but to be unique. We can create UNIQUE INDEX.
Ex: tb1 (c1, c2, c3, c4, c5)
–> We have c1 is PK
–> c3, c4 are not keys, but we can make this {c3, c4} unique by create UNIQUE INDEX for them
-There are many type of INDEX, but most of concern is UNIQUE INDEX

2.Constraint
-We can understand constraints as simple as conditions that columns and tables need to follow
2.1 NOT NULL
-This is the constraint to force user to give data for a column. All of the PK, FK and columns with UNIQUE INDEX must have this constrain
2.2 Referential Integrity Constraint
-A FK in a table depend on the PK in its original table. We cannot delete a PK value without delete all of its reference FK value in referential tables
-In design, we must indicate by drawing this referential integrity constraint
-In DML, we can indicate this referential integrity constraint by CREATE or ALTER command

Add Comment