Skip to content
Snippets Groups Projects
Commit 5b5b8977 authored by Finlay White's avatar Finlay White :speech_balloon:
Browse files

base table done

parent 1068e723
Branches
No related tags found
No related merge requests found
...@@ -15,13 +15,15 @@ subscribed bool, ...@@ -15,13 +15,15 @@ subscribed bool,
phonenum int); phonenum int);
DROP TABLE IF EXISTS `Students`; DROP TABLE IF EXISTS `Students`;
CREATE TABLE `Students`( CREATE TABLE `Students`(
studentID int primary key, studentID int(20),
primary key(studentID),
fname varchar(35), fname varchar(35),
lname varchar(35), lname varchar(35),
-- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name -- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name
bday date, bday date,
dayjoined date , dayjoined date ,
parentsID int(20), parentsID int(20),
groupID int(20),
FOREIGN KEY (parentsID) REFERENCES Parents(parentID) FOREIGN KEY (parentsID) REFERENCES Parents(parentID)
-- parent ID is stored in student rather than the parents table so that one parent can have many children -- parent ID is stored in student rather than the parents table so that one parent can have many children
-- and not one child can have many parents. A child may have multiple parents irl but they would share an -- and not one child can have many parents. A child may have multiple parents irl but they would share an
...@@ -39,8 +41,8 @@ CREATE TABLE `Volunteers`( ...@@ -39,8 +41,8 @@ CREATE TABLE `Volunteers`(
SGlastchecked date, SGlastchecked date,
emergencycontact varchar(20) emergencycontact varchar(20)
); );
DROP TABLE IF EXISTS `Session`; DROP TABLE IF EXISTS `Sessions`;
CREATE TABLE `Session`( CREATE TABLE `Sessions`(
sessionID int(20), sessionID int(20),
primary key (sessionID), primary key (sessionID),
leaderID int(20), leaderID int(20),
...@@ -48,19 +50,43 @@ CREATE TABLE `Session`( ...@@ -48,19 +50,43 @@ CREATE TABLE `Session`(
duration int(10), duration int(10),
FOREIGN KEY (leaderID) REFERENCES Volunteers(VolunteerID), FOREIGN KEY (leaderID) REFERENCES Volunteers(VolunteerID),
maxAttendees int(10), maxAttendees int(10),
groupid int(20),
Nohelpers int(10)); Nohelpers int(10));
DROP TABLE IF EXISTS `Badge`; DROP TABLE IF EXISTS `Badge`;
CREATE TABLE `Badge`( CREATE TABLE `Badge`(
BadgeID int(20), BadgeID int(20),
primary key(BadgeID),
badgeName varchar(35), badgeName varchar(35),
requirementID int(20) badgeDesc varchar(255),
RequirementID int(20)
); );
DROP TABLE IF EXISTS `BadgeAwarded`; DROP TABLE IF EXISTS `BadgeAwarded`;
CREATE TABLE `BadgeAwarded`( CREATE TABLE `BadgeAwarded`(
studentID int(20), awardedID int(20),
primary key(awardedID),
awardedto int(20),
awardedby int(20), awardedby int(20),
BadgeID int(20), Badgeawarded int(20),
dateAwarded date dateAwarded date,
FOREIGN KEY (awardedto) REFERENCES Students(studentID),
FOREIGN KEY (awardedby) REFERENCES Volunteers(VolunteerID),
FOREIGN KEY (Badgeawarded) REFERENCES Badge(BadgeID)
); );
-- DROP TABLE IF EXISTS `Badgereqs`;
select * from Session; CREATE TABLE `Badgereqs`(
\ No newline at end of file RequirementID int(20),
primary key(RequirementID),
mustbecompleted int(20),
tocomplete int(20),
FOREIGN KEY (mustbecompleted) REFERENCES Badge(BadgeID),
FOREIGN KEY (tocomplete) REFERENCES Badge(BadgeID)
);
DROP TABLE IF EXISTS `StudentAttendance`;
CREATE TABLE `StudentAttendance`(
studentID int(20),
sessionID int(20),
FOREIGN KEY (studentID) REFERENCES Students(studentID),
FOREIGN KEY (sessionID) REFERENCES Sessions(SessionID)
);
Alter table `Badge`ADD FOREIGN KEY (RequirementID) REFERENCES Badgereqs(RequirementID);
select * from StudentAttendance;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment