daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Oct 18th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE People (
  2.   pID SERIAL,
  3.   pName VARCHAR(50),
  4.   pAddress VARCHAR(50),
  5.   pPhoneNumber INTEGER,
  6.   pDOB DATE NOT NULL,
  7.   pDOD DATE DEFAULT NULL,
  8.   PRIMARY KEY (pID)
  9. );
  10.  
  11. CREATE TABLE Linking (
  12.   lID SERIAl,
  13.   lName VARCHAR (50),
  14.   lType VARCHAR (20),
  15.   lDescription TEXT,
  16.   PRIMARY KEY (lID)
  17. );
  18.  
  19. CREATE TABLE hasLink (
  20.   HLlID INTEGER,
  21.   HLpID INTEGER,
  22.   PRIMARY KEY (HLlID, HLpID),
  23.   FOREIGN KEY (HLlID) REFERENCES Linking (lID),
  24.   FOREIGN KEY (HLpID) REFERENCES People(pID)
  25. );
  26.  
  27. CREATE TABLE Member (
  28.   mStartingDate DATE,
  29.   mID INTEGER,
  30.   PRIMARY KEY (mID),
  31.   FOREIGN KEY (mID) REFERENCES People (pID)
  32. );
  33.  
  34. CREATE TABLE Enemy (
  35.   eID INTEGER,
  36.   PRIMARY KEY (eID),
  37.   FOREIGN KEY (eID) REFERENCES People (pID)
  38. );
  39. /*
  40. CREATE TABLE Opponent(
  41.   NOT NULL
  42. )
  43. */
  44. CREATE TABLE Appointment(
  45.   aStartDate DATE,
  46.   aEndDate DATE DEFAULT NULL
  47.  
  48. );
  49.  
  50. CREATE TABLE Role(
  51.   rID INTEGER,
  52.   rSalary INTEGER,
  53.   rTitle VARCHAR(50),
  54.   PRIMARY KEY (rID)
  55. );
  56.  
  57. CREATE TABLE In2 (
  58.   --Member in specific Role
  59.   IStartDate DATE,
  60.   IEndDate DATE,
  61.   ImID INTEGER,
  62.   IrID INTEGER,
  63.   PRIMARY KEY (ImID, IrID),
  64.   FOREIGN KEY (ImID) REFERENCES Member (mID),
  65.   FOREIGN KEY (IrID) REFERENCES Role (rID)
  66. );
  67.  
  68. CREATE TABLE Asset (
  69.   aName VARCHAR(50),
  70.   aUsage VARCHAR(50),
  71.   aDescription TEXT,
  72.   PRIMARY KEY (aName)
  73. );
  74.  
  75. CREATE TABLE hasAsset (
  76.   HAName VARCHAR(50),
  77.   HAmID INTEGER,
  78.   PRIMARY KEY (HAmID, HAName),
  79.   FOREIGN KEY (HAName) REFERENCES Asset (aName),
  80.   FOREIGN KEY (HAmID) REFERENCES Member (mID)
  81. );
  82.  
  83. CREATE TABLE Sponsor(
  84.   sID SERIAL,
  85.   sName VARCHAR (50),
  86.   sIndustry VARCHAR (50),
  87.   sAddress VARCHAR (50),
  88.   PRIMARY KEY (sID)
  89. );
  90.  
  91. CREATE TABLE Grants (
  92.   gAmount FLOAT,
  93.   gDate DATE,
  94.   gPayback VARCHAR (50),
  95.   gsID INTEGER,
  96.   gmID INTEGER,
  97.   FOREIGN KEY (gsID) REFERENCES Sponsor (sID),
  98.   FOREIGN KEY (gmID) REFERENCES Member (mID),
  99.   PRIMARY KEY (gsID, gmID)
  100. );
  101.  
  102. CREATE TABLE OtherParties (
  103.   opID SERIAL,
  104.   opName VARCHAR(50),
  105.   opCountry VARCHAR(20),
  106.   PRIMARY KEY (opID)
  107. );
  108.  
  109. CREATE TABLE Monitors (
  110.   momID INTEGER,
  111.   moopID INTEGER,
  112.   PRIMARY KEY (momID, moopID),
  113.   FOREIGN KEY (momID) REFERENCES Member(mID),
  114.   FOREIGN KEY (moopID) REFERENCES OtherParties(opID)
  115. );
  116.  
  117. CREATE TABLE Review (
  118.   rDate DATE REFERENCES Grants (gDate),
  119.   rGrade INTEGER CHECK (rGrade > 0 AND rGrade <= 10),
  120.   --rID
  121.   PRIMARY KEY (mID)
  122. );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top