Advertisement
Albinutte

CSC Database tables

Nov 19th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP TABLE BugComponent;
  2. DROP TABLE Component;
  3. DROP TABLE Project;
  4. DROP TABLE Bug;
  5. DROP TABLE BugStatus;
  6. DROP TABLE qaengineer;
  7. DROP TABLE ProjectManager;
  8. DROP TABLE Employee;
  9.  
  10. CREATE TABLE Employee(
  11.         id INT PRIMARY KEY,
  12.         email character varying(256) UNIQUE,
  13.         name character varying(256));
  14.  
  15. CREATE TABLE qaengineer (
  16.         id INT PRIMARY KEY,
  17.         FOREIGN KEY(id) REFERENCES Employee
  18. );
  19.  
  20. CREATE TABLE ProjectManager (
  21.         id INT PRIMARY KEY,
  22.         FOREIGN KEY(id) REFERENCES Employee
  23. );
  24.  
  25. CREATE TABLE BugStatus(id INT PRIMARY KEY, value VARCHAR(20) NOT NULL);
  26.  
  27.  
  28. CREATE TABLE bug (
  29.         num integer PRIMARY KEY,
  30.         title character varying(256),
  31.         submission_date DATE,
  32.         owner_id INT,
  33.         status_id INT,
  34.         FOREIGN KEY(owner_id) REFERENCES qaengineer,
  35.         FOREIGN KEY(status_id) REFERENCES BugStatus);
  36.  
  37.  
  38. CREATE TABLE Project (
  39.         id INT PRIMARY KEY,
  40.         title VARCHAR(256),
  41.         manager_id INT,
  42.         FOREIGN KEY(manager_id) REFERENCES ProjectManager
  43.     );
  44.  
  45.  
  46. CREATE TABLE component (
  47.         id INT PRIMARY KEY,
  48.         title character varying(256),
  49.         project_id INT,
  50.         FOREIGN KEY(project_id) REFERENCES Project
  51.     );
  52.  
  53.  
  54. CREATE TABLE BugComponent(
  55.         bug_num INT,
  56.         component_id INT,
  57.         UNIQUE(bug_num, component_id),
  58.         FOREIGN KEY (bug_num) REFERENCES Bug,
  59.         FOREIGN KEY (component_id) REFERENCES Component
  60.     );
  61.  
  62.  
  63. INSERT INTO BugStatus(id, value) VALUES (1, 'new'), (2, 'assigned'), (3, 'fixed'), (4, 'verified'), (5, 'not reproducible');
  64. INSERT INTO Project(id, title) VALUES (1001, 'Тетрис 2014'), (1002, 'Windows XXX'), (1003, 'Instagraph'), (1004, 'чебурашка'), (1005, 'skynet');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement