Term
|
Definition
tells you what is acceptable in a column
and it can be based on columns already existing in
other tables or columns
in the same table |
|
|
Term
|
Definition
what values are acceptable
to update
based on another column or tables' values
- it must reference of course, a primary key or
- unique constraint
- user must have REFERENCES permission on a reference table
- FKC that uses REFERENCES clause without the FOREIGN KEY clause refers to a column in the same table (doesn't go outside like a foreign keys does)
- No automatic index creation
|
|
|
Term
|
Definition
If your INSERT statement doesn't have a value,
this kicks in
You cannot use or have this:
- in columns with timestamp data type
- IDENTITY Columns
- ROWGUIDCOL property set on column (Globally Unique Identifier)
|
|
|
Term
|
Definition
null values are not allowed
each row is ID'd uniquely
One per table (column that uniquely identifies rows)
it must be unique
The primary key of course can also be composite
Null of course is NOT allowed |
|
|
Term
|
Definition
takes place automatically
when you
insert
update
delete |
|
|
Term
|
Definition
prevents duplication
of alternative
and not the primary key
values in a column
Here NULLS are allowed
A good candidate for unique constraint is
an employee (badge) number
or
parking space assignments |
|
|
Term
|
Definition
refer to a column
covers:
rules
data types
defaults
constraints
triggers
XML schema |
|
|
Term
|
Definition
applies to rows
"the primary key"
rules
NULLs
defaults
constraints
triggers |
|
|
Term
|
Definition
tables
and columns
includes triggers and constraints
"the foreign key" |
|
|
Term
|
Definition
this is created by CREATE RULE
however Microsoft states that forthcoming versions of MS SQL Server will no longer support Rules
This can be applied to multiple tables |
|
|
Term
Foreign Key Defined example |
|
Definition
ALTER TABLE [Sales].[SalesOrderHeader]
WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID] FOREIGN KEY ([CustomerID])
REFERENCES [Sales].[Customer] ([Customerid]) |
|
|
Term
Foreign Key Cascade Option |
|
Definition
you can change any column value that defines a UNIQUE or PRIMARY KEY constraint
to propagate the change to any foreign key values that reference it
You change one column and other columns that reference the former column are changed as well |
|
|
Term
REFERENCES clause of the
ALTER TABLE
CREATE TABLE
statements |
|
Definition
this supports:
ON DELETE
ON UPDATE
clauses
and controls the cascading referential integrity
options:
NO ACTION (default setting)
CASCADE
SET NULL
SET DEFAULT |
|
|
Term
What happens when you define a primary key? |
|
Definition
it automatically generates an index
and then SQL Server uses the index to enforce uniqueness |
|
|
Term
Primary Key Constraint Defined
Example |
|
Definition
CONSTRAINT [PK_Department_DepartmentID] PRIMARY KEY CLUSTERED
([DepartmentID] ASC) WITH (IGNORE_DUP_KEY=OFF) ON
[PRIMARY] |
|
|