Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SUPERGEEKS-SQL
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Finlay White
SUPERGEEKS-SQL
Commits
5b5b8977
Commit
5b5b8977
authored
2 years ago
by
Finlay White
Browse files
Options
Downloads
Patches
Plain Diff
base table done
parent
1068e723
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
createdb.sql
+35
-9
35 additions, 9 deletions
createdb.sql
with
35 additions
and
9 deletions
createdb.sql
+
35
−
9
View file @
5b5b8977
...
...
@@ -15,13 +15,15 @@ subscribed bool,
phonenum
int
);
DROP
TABLE
IF
EXISTS
`Students`
;
CREATE
TABLE
`Students`
(
studentID
int
primary
key
,
studentID
int
(
20
),
primary
key
(
studentID
),
fname
varchar
(
35
),
lname
varchar
(
35
),
-- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name
bday
date
,
dayjoined
date
,
parentsID
int
(
20
),
groupID
int
(
20
),
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
-- 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`(
SGlastchecked
date
,
emergencycontact
varchar
(
20
)
);
DROP
TABLE
IF
EXISTS
`Session`
;
CREATE
TABLE
`Session`
(
DROP
TABLE
IF
EXISTS
`Session
s
`
;
CREATE
TABLE
`Session
s
`
(
sessionID
int
(
20
),
primary
key
(
sessionID
),
leaderID
int
(
20
),
...
...
@@ -48,19 +50,43 @@ CREATE TABLE `Session`(
duration
int
(
10
),
FOREIGN
KEY
(
leaderID
)
REFERENCES
Volunteers
(
VolunteerID
),
maxAttendees
int
(
10
),
groupid
int
(
20
),
Nohelpers
int
(
10
));
DROP
TABLE
IF
EXISTS
`Badge`
;
CREATE
TABLE
`Badge`
(
BadgeID
int
(
20
),
primary
key
(
BadgeID
),
badgeName
varchar
(
35
),
requirementID
int
(
20
)
badgeDesc
varchar
(
255
),
RequirementID
int
(
20
)
);
DROP
TABLE
IF
EXISTS
`BadgeAwarded`
;
CREATE
TABLE
`BadgeAwarded`
(
studentID
int
(
20
),
awardedID
int
(
20
),
primary
key
(
awardedID
),
awardedto
int
(
20
),
awardedby
int
(
20
),
BadgeID
int
(
20
),
dateAwarded
date
Badgeawarded
int
(
20
),
dateAwarded
date
,
FOREIGN
KEY
(
awardedto
)
REFERENCES
Students
(
studentID
),
FOREIGN
KEY
(
awardedby
)
REFERENCES
Volunteers
(
VolunteerID
),
FOREIGN
KEY
(
Badgeawarded
)
REFERENCES
Badge
(
BadgeID
)
);
select
*
from
Session
;
\ No newline at end of file
-- DROP TABLE IF EXISTS `Badgereqs`;
CREATE
TABLE
`Badgereqs`
(
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment