PRIMARY KEY Constraint
PRIMARY KEY Constraint
So far:
PRIMARY KEY Constraint
So far:
So far:
So far:
constraints
constraints
constraints
Sales
FOREIGN KEY Constraint
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
foreign key
points to a column of another table and, thus, links the two tables
FOREIGN KEY Constraint
FOREIGN KEY Constraint
child table
FOREIGN KEY Constraint
parent table
child table
FOREIGN KEY Constraint
parent table
child table
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
Sales
FOREIGN KEY Constraint
Sales
Sales
the foreign key maintains the referential integrity within the database
FOREIGN KEY Constraint
ON DELETE CASCADE
if a specific value from the parent table’s primary key has been
deleted, all the records from the child table referring to this value
will be removed as well
FOREIGN KEY Constraint
FOREIGN KEY Constraint
FOREIGN KEY Constraint
FOREIGN KEY Constraint
ON DELETE CASCADE
UNIQUE Constraint
UNIQUE Constraint
unique key
used whenever you would like to specify that you don’t want to see
duplicate data in a given field
UNIQUE Constraint
unique key
used whenever you would like to specify that you don’t want to see
duplicate data in a given field
ERROR
UNIQUE Constraint
Sales
UNIQUE Constraint
UNIQUE Constraint
Indexes
UNIQUE Constraint
Indexes
unique keys in MySQL have the same role as indexes
UNIQUE Constraint
Indexes
unique keys in MySQL have the same role as indexes
Indexes
unique keys in MySQL have the same role as indexes
index of a table
Indexes
unique keys in MySQL have the same role as indexes
index of a table
- it takes more time to update a table because indexes must be updated, too, and
that’s time consuming
UNIQUE Constraint
UNIQUE Constraint
DEFAULT Constraint
DEFAULT Constraint
DEFAULT Constraint
helps us assign a particular default value to every row of a column
DEFAULT Constraint
DEFAULT Constraint
helps us assign a particular default value to every row of a column
- a value different from the default can be stored in a field where the
DEFAULT constraint has been applied, only if specifically indicated.
DEFAULT Constraint
DEFAULT Constraint
2
DEFAULT Constraint
2 Peter Figaro M
Data Definition Language
the “not null” restriction is applied through the NOT NULL Constraint
NOT NULL Constraint
the “not null” restriction is applied through the NOT NULL Constraint
- when you insert values in the table, you cannot leave the respective
field empty
NOT NULL Constraint
the “not null” restriction is applied through the NOT NULL Constraint
- when you insert values in the table, you cannot leave the respective
field empty
- if you leave it empty, MySQL will signal an error
ERROR
NOT NULL Constraint
NOT NULL Constraint
NOT NULL
NOT NULL Constraint
0 NONE NULL
NULL
the value
of 0,
NOT NULL
NOT NULL Constraint
NULL
NOT NULL Constraint
NULL
NOT NULL Constraint
NULL