Transactions: ---------------- - Atomicity: begin; transaction commit; --rollback Constraints: --------------- Integrity rules for the database. Constraint types: - Database level (Assertions) - Table level: - Primary key - Foreign Key - Unique - Not Null - Check (attribute level of table level) create table abc ( vala varchar(10) primary key , valb int ) ; create table xyz( id int , val1 varchar(10) , val2 varchar(10) not null , val3 int , val4 int , primary key (id) --not null implicitly true , foreign key (val1) references abc(vala) on delete cascade , foreign key (val2) references def(vald) , unique (val2, val3) , check (val1 > 4) , check (val1 <> 0 or val2 < 5) ) ; -- If any constraint violated: the transaction causing the change is aborted, all changes are rolled back. drop table b; drop table a; create table a (id1 int primary key, id3 int) ; create table b (id2 int primary key , id1 int not null , foreign key (id1) references a(id1) on delete set null on update cascade); insert into a values(1, 41); insert into a values(2, 42); insert into a values(4, 44); insert into b values(21, 1); insert into b values(22, 1); insert into b values(24, 2); --> restrict (default): if a tuple references the updated/deleted tuple, then the update/delete is rolled back. --> cascade: cascade the change