Week 10 Flashcards
What is a foreign key?
A Foreign key is a key borrowed from another related table (that’s why its foreign) in order to make the relationship between two tables. It is normally denoted with its first two letters, namely, FK
What is a primary key?
A Primary key is a key that uniquely identifies a row in each table. It is normally denoted with its first two letters, namely, PK
What is Referential Integrity?
means that the Foreign key must match in terms of actual values and data types with the related Primary Key.
What are constraints?
Database constraints are restrictions on the contents of the database or on database operations
Constraints provide a way to guarantee that (3)?
- rows in table have valid primary or unique key values
- rows in a dependent table have valid foreign key values that reference rows in a parent table
- individual column values are valid
Foreign Key / References constraint:
- Rejects an INSERT or UPDATE of a value if a corresponding value does not currently exist in the primary key table.
- Rejects a DELETE, if it would invalidate a REFERENCES constraint.
- Must reference a PRIMARY KEY or UNIQUE column in primary key table.
- Will reference the PRIMARY KEY of the primary key table if no column or group of columns is specified in the constraints.
- Must refer a table , not a view.
- Requires that a FOREIGN KEY column and the CONSTRAINT column have matching data types
Three primary type of relationships are:
one-to-one
one-to-many
Many-to-many.
Each row/record in a Table should be unique using a
Primary key
To create a relationship among tables you must have the ___________ on a different table
Foreign Key
Referential Integrity protects the integrity of your data by matching both your Primary key and Foreign in terms of _______ _______ and _______ _______ .
Data types and actual values
what is a Default Key Constraint –
At the time of cell creation a‘default value’ can be assigned to it. When the user is loading a ‘record’ with values and leaves this cell empty, the DBA will automatically load this cell with the default value specified. The data type of the default value should match the data type of the column.
What are check constraints?
•Used to enforce the validity of column values.
What are unique key contraints
purpose of a unique key is to ensure that information in the column for each record is unique
what is null?
Can mean many things:
Value does not exists
Value exists but is unknown
Value not applicable
truncate does the following, where as delete statement does not
Releases the memory used
Resets the identity value
Does not invoke delete trigger