ncamaa1

Untitled

Aug 9th, 2017
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE item
  2.     (iname  varchar(30),
  3.      itype  varchar(30),
  4.      PRIMARY KEY (iname));
  5.  
  6. CREATE TABLE Cafe
  7.     (license numeric(5,0),
  8.      cname   varchar(30),
  9.      address varchar(30),
  10.      PRIMARY KEY (license));
  11.  
  12. CREATE TABLE Client
  13.     (cid    numeric(5,0),
  14.      name   varchar(30),
  15.      phone  numeric(9,0),
  16.      PRIMARY KEY (cid));
  17.  
  18. CREATE TABLE Likes
  19.     (cid    numeric(5,0),
  20.      iname  varchar(30),
  21.      PRIMARY KEY (cid,iname),
  22.      FOREIGN KEY (cid) REFERENCES Client,
  23.      FOREIGN KEY (iname) REFERENCES item);
  24.  
  25. CREATE TABLE Sells
  26.     (license numeric(5,0),
  27.      iname   varchar(30),
  28.      price   float,
  29.      PRIMARY KEY (license,iname),
  30.      FOREIGN KEY (license) REFERENCES Cafe,
  31.      FOREIGN KEY (iname) REFERENCES item);
  32.  
  33. CREATE TABLE Receipt
  34.     (cid     numeric(5,0),
  35.      rno     numeric(5,0),
  36.      license numeric(5,0),
  37.      rdate   date,
  38.      PRIMARY KEY (cid,rno),
  39.      FOREIGN KEY (cid) REFERENCES Client,
  40.      FOREIGN KEY (license) REFERENCES Cafe);
  41.  
  42. CREATE TABLE Buys
  43.     (cid     numeric(5,0),
  44.      rno     numeric(5,0),
  45.      iname   varchar(30),
  46.      amount  int,
  47.      PRIMARY KEY (cid,rno,iname),
  48.      FOREIGN KEY (cid,rno) REFERENCES Receipt,
  49.      FOREIGN KEY (iname) REFERENCES item);
RAW Paste Data