Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Posts
    1

    Unanswered: Integrity Constraints

    Given the following example schema for an airline reservation system:
    CREATE TABLE Passenger
    (
    id INTEGER PRIMARY KEY,
    name VARCHAR(20) NOT NULL );

    CREATE TABLE Plane
    (
    id INTEGER PRIMARY KEY,
    capacity INTEGER,
    type CHAR(1) );

    CREATE TABLE Flight
    (
    id INTEGER,
    planeId INTEGER,
    flightDate DATE,
    startLocation VARCHAR(20),
    destination VARCHAR(20),
    PRIMARY KEY (Id),
    FOREIGN KEY (PlaneId) REFERENCES Plane );

    CREATE TABLE Reservation
    (
    passengerId INTEGER,
    flightId INTEGER,
    PRIMARY KEY (passengerId, flightId),
    FOREIGN KEY (passengerId) REFERENCES Passenger,
    FOREIGN KEY (flightId) REFERENCES Flight );
    Give an integrity constraint PlaneCapacity that enforces the restriction that the number of passengers on a plane cannot exceed the plane’s capacity.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Do we get credited when you hand your homework in to your teacher?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •