slides9 - Schedule Today: Jan. 31 (TH) x x Constraints....

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 9–1 Schedule Today: Jan. 31 (TH) Constraints. Read Sections 7.1-7.3, 7.4.1. Project Part 3 due. Feb. 5 (T) Triggers, PL/SQL. Read Sections 7.4, 8.2. Assignment 4 due. Feb. 7 (TH) PL/SQL, Embedded SQL, CLI, JDBC. Read Sections 8.1, 8.3-8.5. Feb. 12 (T) Advising Day. No class. Reminder: Midterm is Feb. 14 (TH) Covers material through Feb. 7 (TH) lecture and readings (Chapters 1-3, 5-7, 8.1-8.5).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Winter 2002 Arthur Keller – CS 180 9–2 Constraints Commercial relational systems allow much more “fine-tuning” of constraints than do the modeling languages we learned earlier. In essence: SQL programming is used to describe constraints. Outline 1. Primary key declarations (already covered). 2. Foreign-keys = referential integrity constraints. 3. Attribute- and tuple-based checks = constraints within relations. 4. SQL Assertions = global constraints. Not found in Oracle. 1. Oracle Triggers. A substitute for assertions.
Background image of page 2
Winter 2002 Arthur Keller – CS 180 9–3 Foreign Keys In relation R a clause that “attribute A references S ( B )” says that whatever values appear in the A column of R must also appear in the B column of relation S . B must be declared the primary key for S . Example CREATE TABLE Beers ( name CHAR(20) PRIMARY KEY, manf CHAR(20) ); CREATE TABLE Sells ( bar CHAR(20), beer CHAR(20) REFERENCES Beers(name), price REAL );
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Winter 2002 Arthur Keller – CS 180 9–4 Alternative: add another element declaring the foreign key, as: CREATE TABLE Sells ( bar CHAR(20), beer CHAR(20), price REAL, FOREIGN KEY beer REFERENCES Beers(name) ); Extra element essential if the foreign key is more than one attribute.
Background image of page 4
Winter 2002 Arthur Keller – CS 180 9–5 What Happens When a Foreign Key Constraint is Violated? Two ways:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

slides9 - Schedule Today: Jan. 31 (TH) x x Constraints....

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online