Chapter 4: Intermediate SQL
Chapter 4: Intermediate SQL
Join Expressions
Views
Transactions
Integrity Constraints
SQL Data Types and Schemas
Authorization
Joined Relations
Relation prereq
Observe that
prereq information is missing for CS-315 and
course information is missing for CS-437
Outer Join
Computes the join and then adds tuples form one relation
that does not match tuples in the other relation to the result
of the join.
If relations used in the query are updated, the materialized view result
becomes out of date
Need to maintain the view, by updating the view whenever the
underlying relations are updated.
Transactions
Unit of work
Atomic transaction
either fully executed or rolled back as if it never occurred
Isolation from concurrent transactions
not null
primary key
unique
check (P), where P is a predicate
Not Null and Unique Constraints
not null
Declare name and budget to be not null
name varchar(20) not null
budget numeric(12,2) not null
check (P)
where P is a predicate
Chain of roles
create role dean;
grant instructor to dean;
grant dean to Satoshi;
Authorization on Views
create view geo_instructor as
(select *
from instructor
where dept_name = ’Geology’);
transfer of privileges
grant select on department to Amit with grant option;