Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. CREATE TABLE complaint (
  2. ComplaintID int AUTO_INCREMENT NOT NULL COMMENT 'Unique ID representing a complaint',
  3. RegNo varchar(30) NOT NULL COMMENT 'Register number of the student who filed this complaint. Maps to RegNo of Student table.',
  4. AssignedTo varchar(30) NOT NULL COMMENT 'StaffID to which this complaint has been assigned. Maps to StaffID of Staff table',
  5. PRIMARY KEY (ComplaintID)
  6. ) ENGINE = InnoDB
  7. COMMENT = 'Contains data regarding a complaint';
  8.  
  9. CREATE TABLE staff (
  10. StaffID varchar(30) NOT NULL COMMENT 'A unique ID assigned to each staff. Same as UserID of User table',
  11. `Year` year COMMENT 'Year the staff is currently handling',
  12. `Section` varchar(1) DEFAULT '-' COMMENT 'Section the staff is currently handling',
  13. PRIMARY KEY (StaffID)
  14. ) ENGINE = InnoDB
  15. COMMENT = 'Contains information about a staff member';
  16.  
  17. CREATE TABLE student (
  18. RegNo varchar(30) NOT NULL COMMENT 'A unique register number assigned to each student',
  19. `Year` year NOT NULL COMMENT 'Year in which the student joined the college',
  20. `Section` varchar(1) NOT NULL COMMENT 'Section of the student',
  21. PRIMARY KEY (RegNo)
  22. ) ENGINE = InnoDB
  23. COMMENT = 'Contains information about a student';
  24.  
  25.  
  26. CREATE TABLE `user` (
  27. UserID varchar(30) NOT NULL COMMENT 'RegNo/StaffID',
  28. UserName varchar(50) COMMENT 'Full name of the User',
  29. `Password` varchar(33) NOT NULL COMMENT 'Password for login',
  30. PRIMARY KEY (UserID)
  31. ) ENGINE = InnoDB
  32. COMMENT = 'Contains basic information for a Complaint Management System user';
  33.  
  34. /* Foreign Keys */
  35. ALTER TABLE complaint ADD CONSTRAINT complaint_ibfk_1 FOREIGN KEY (AssignedTo) REFERENCES staff(StaffID);
  36.  
  37. ALTER TABLE complaint ADD CONSTRAINT complaint_ibfk_2 FOREIGN KEY (Category) REFERENCES compcats(CategoryID);
  38.  
  39. ALTER TABLE complaint ADD CONSTRAINT complaint_ibfk_3 FOREIGN KEY (RegNo) REFERENCES student(RegNo);
  40.  
  41. ALTER TABLE student ADD CONSTRAINT RegNo FOREIGN KEY (RegNo) REFERENCES `user`(UserID);
  42.  
  43. ALTER TABLE `user` ADD CONSTRAINT user_ibfk_1 FOREIGN KEY (PriviledgeID) REFERENCES priviledge(PriviledgeID);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement