· 7 years ago · Nov 06, 2018, 01:56 AM
1-- Creating the Python Club tables through a query
2-- CTRL+R and click Next a bunch of times and the EER diagram is created automatically
3
4-- "Updating" the tables cheat - Drop all tables and recreate them
5
6-- Tables with foreign keys must be dropped first
7DROP TABLE IF EXISTS pythonclub.attendance;
8DROP TABLE IF EXISTS pythonclub.meetingminutes;
9
10-- Primary keys next
11DROP TABLE IF EXISTS pythonclub.members;
12DROP TABLE IF EXISTS pythonclub.meeting;
13
14CREATE TABLE members (
15 PK_idMembers INT NOT NULL,
16 PRIMARY KEY (PK_idMembers),
17
18 LastName VARCHAR(45),
19 FirstName VARCHAR(45),
20 Email VARCHAR(100),
21 DateAdded DATE
22);
23
24CREATE TABLE meeting (
25 PK_idMeeting INT NOT NULL,
26 PRIMARY KEY (PK_idMeeting),
27
28 MeetingType VARCHAR(45),
29 MeetingDate DATE,
30 MeetingTime TIME
31);
32
33-- I think SQL code runs top to bottom, because this must be put after meeting and members since it uses their PKs
34CREATE TABLE attendance (
35 FK_idMembers INT NOT NULL,
36 FOREIGN KEY (FK_idMembers) REFERENCES members(PK_idMembers),
37
38 FK_idMeeting INT NOT NULL,
39 FOREIGN KEY (FK_idMeeting) REFERENCES meeting(PK_idMeeting)
40);
41
42CREATE TABLE meetingminutes (
43 FK_idMembers_Participants INT NOT NULL,
44 FOREIGN KEY (FK_idMembers_Participants) REFERENCES members(PK_idMembers),
45
46 Minutes INT,
47 TopicsToFollowUp int, -- I don't know what this is supposed to be
48 results int -- Don't know what this is either
49);
50
51
52-- MeetingMinutes