Relational Database Flashcards
What is a database?
A well-organised collection of data
that are related in a meaningful way,
describing a domain of interest
(a collection of relations)
What is a relational database?
Focus on things in the
domain of interest and the relations between
them
What is a database management system?
Software that helps
maintain and utilise large collections of data in an
efficient manner
What are the advantages of a database management system?
Data independence
Efficient data access
Data integrity
Concurrent access and recovery from crashes
What does a relation consist of?
Relation schema: describes the format of a table,
consisting of:
• Relation’s name
• Name of each field (column)
• Domain of each field
Relation instance: the content of a table
• A set of tuples (records)
What is Arity?
Also called degree
Number of fields
What is Cardinality?
Number of rows
What is Structured Query Language?
Standard language
for creating, manipulating and querying data in
relational database management systems
What is Data Definition Language?
Subset of SQL that
allows us to create, delete and modify tables
How do you create relations with DDL?
CREATE TABLE declaration: define a new relation
(called ‘table’ in SQL) with a particular schema
CREATE TABLE table-name (
⟨attribute declarations⟩
⟨integrity constraints⟩
)
What is Domain constraint?
For each row in this table, the
values in each column must be drawn from the
appropriate domain
-Condition of the database
What are the integrity constraints?
- Key constraints
- Foreign key constraints
What is the Primary key?
-Uniquely identifies a tuple
-No 2 rows in the table have the same mn
PRIMARY KEY (mn)
What is the Foreign key?
Specify links between tables
Will always take a value that appears in the table you choose
FOREIGN KEY (mn) REFERNECES Course
The foreign key in a referencing relation must match
the primary key of the reference relation.
• Same number of columns and same domains.
What should happen if a row in the table is deleted?
- All rows in Takes that refer to it should be deleted (ON DELETE CASCADE)
- For each row in Takes that refer to it, set its mn value to some pre-specified default value (ON DELETE SET DEFAULT)
- For each row in Takes that refer to it, set its mn value to null (ON DELETE SET NULL)