Shared Flashcard Set

Details

Constraints Lesson 8
This concerns Constraints
15
Computer Science
Undergraduate 4
09/28/2013

Additional Computer Science Flashcards

 


 

Cards

Term
Check Constraint
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
foreign key constraint
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
default constraint
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
primary key constraint
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
trigger
Definition

takes place automatically

when you

insert

update

delete

Term
Unique Constraint
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
Domain integrity
Definition

refer to a column

covers:

rules

data types

defaults

constraints

triggers

XML schema

Term
Entity Integrity
Definition

applies to rows

"the primary key"

rules

NULLs

defaults

constraints

triggers

Term
Referential integrity
Definition

tables

and columns

includes triggers and constraints

"the foreign key"

Term
Rules
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]

Supporting users have an ad free experience!