1/40
Need to finish the outer joins
What does a relational database represent?
data as a collection of related relations

What is meant by the domain?
permitted values for an attribute
What is meant by degree?
the number of attributes
What is meant by cardinality in terms of tuples?
the number of tuples
How is a function mapped?
each input is related to exactly one output
What is a relation?
a set of ordered pairs (one input can relate to several outputs)
What is the definition for a relation/table?
a logical representation of data based on set theory and predicate logic
What are the 3 rules of a relation?
single valued cells
unique rows
row + column order don’t matter
What are the 3 aspects of data that the relational model covers?
Data Structure - table,column,row,domain
Data Integrity - rules to ensure data is valid
Data Manipulation - use relational algebra to retrieve + change data
What does the relational model consist of?
data structures
entities + their relations
data constraints
restrication on data, relations… etc.
relational operators
restrict, project, cartesian product, union, difference
What are the 4 objectives of the relational model?
Data Indepence - allow changes w/o affecting applications that use it
Control Redundancy - data not stored in multiple places
Maintain Consistency - copies are accurate and up to date
Enable Set-Oriented Languages (e.g. relational algebra)
What is a relational schema?
a textual representation for a data model

Relational Vocab: RELATION
the whole table
Relational Vocab: TUPLE
1 row
Relational Vocab: ATTRIBUTE
1 named column
What is an alternate key?
a candidate key that was not chosen as the primary key
What is a foreign key?
attribute(s) that refer to a candidate key in another relation
What do NULL values represent?
missing information (e.g. unknown value, value inserted later)
What are the types of database constraints?
entity integrity - each row is unique + identifiable
referential integrity - accuracy + consistency of data between tables
multiplicity
required data (primary key not null)
domain constraints
What is the difference between entity and referential integrity?
ENTITY INTEGRITY
constraint on PK
unique values + not null
REFERENTIAL INTEGRITY
constrain on FK
values match candidate key referred to/ be null
What is relational agebra?
a procedural language (an expression specifies operations to perform on relations)
What does the “natural join” operation do?
combines 2 tables based on common attribute names

What does the “restrict” operation do?
filters rows based on conditions

What does the “project” operation do?
selects specific columns

What does the “intersection” operation do?
returns only common tuples (rows)

What should you consider when choosing between different expressions that give the same result?
the efficiency of the operation
efficiency dependent on the no. tuples & indexes used
(different expressions may have the same result but are not equally efficient)
What do query languages allows us to do to a database?
allows manipulation & retrieval of data from database
What happens when a query is being responded to?
several operations are used (e.g. restrict, project etc.)
How are complex queries evaluated?
nesting operations = create relational expression
create temporary tables while applying operations one at a time
(most efficient method is chosen)
What are the 7 basic relational algebra operations?
restrict
project
cartesian product
union
set difference
join
intersection
What are the 3 types of standard set operations?
union
intersection
difference
What can the 3 types of standard set operations only be applied to?
union compatible tables - same amount of colums + same domain

What does the “union” operation do?
removes all duplicate rows


What does the “intersection” operation do?
returns rows that appear in both table


What does the “difference” operation do?
returns the rows that are in one and not in the other table

What does the “cartesian product” operation do?
multiplies 2 tables

What happens during a “cartesian product” operation if columns have the same name?
columns w/ same name must be prefixed w/ table name
maintains unique column names

What does the “join” operation do?
combines 2 tables to form a new one
columns involved must have the same domain
derivative of cartesian product
What are the 3 types of joins?
equijoins
natural join = auto matches attributes
outer joins = returns matching rows + preserve certain rows that dont have a match
left outer join
right outer join
full outer join
What can JOIN operatins be written in terms of?
restrict & cartesian product operations

What is the condition of the “equi-join” operation?
contains only equality comparisons
