Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.04 KB | None | 0 0
  1. DROP DATABASE IF EXISTS sportGroups;
  2. CREATE DATABASE sportGroups;
  3. USE sportGroups;
  4.  
  5. CREATE TABLE clubs(
  6. id INT AUTO_INCREMENT PRIMARY KEY,
  7. sportName VARCHAR(100) NOT NULL
  8.  
  9. );
  10.  
  11. CREATE TABLE couches(
  12. id INT AUTO_INCREMENT PRIMARY KEY,
  13. name VARCHAR(255) NOT NULL,
  14. email VARCHAR(55) NOT NULL
  15.  
  16. );
  17.  
  18. CREATE TABLE students(
  19. id INT AUTO_INCREMENT PRIMARY KEY,
  20. name VARCHAR(255) NOT NULL,
  21. fNom CHAR(9) NOT NULL unique,
  22. phone VARCHAR(55) NULL
  23.  
  24. );
  25.  
  26. CREATE TABLE groups(
  27. id INT AUTO_INCREMENT PRIMARY KEY,
  28. day ENUM('Mon','Tue','Wen','T','Fr','Sat','Sun') NOT NULL,
  29. hour TIME NOT NULL,
  30. location VARCHAR(255) NOT NULL,
  31. club_id INT NOT NULL,
  32. coach_id INT NOT NULL,
  33. CONSTRAINT FOREIGN KEY (club_id) REFERENCES clubs(id),
  34. CONSTRAINT FOREIGN KEY (coach_id) REFERENCES clubs(id),
  35. Unique KEY(day,hour,location)
  36. );
  37.  
  38. CREATE TABLE student_group(
  39. student_id int not null,
  40. group_id int not null,
  41. constraint FOREIGN key(student_id) REFERENCES students(id),
  42. constraint FOREIGN key(group_id) REFERENCES groups(id),
  43. primary key (student_id,group_id)
  44. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement