ncamaa1

create table maman 11

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