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
2ea4ccb6
Commit
2ea4ccb6
authored
1 year ago
by
Finlay White
Browse files
Options
Downloads
Patches
Plain Diff
viewed
parent
9ee3940d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
createdb.sql
+51
-10
51 additions, 10 deletions
createdb.sql
er1.png
+0
-0
0 additions, 0 deletions
er1.png
with
51 additions
and
10 deletions
createdb.sql
+
51
−
10
View file @
2ea4ccb6
...
...
@@ -49,13 +49,16 @@ CREATE TABLE `Sessions`(
sessionID
varchar
(
40
)
not
null
unique
,
primary
key
(
sessionID
),
leaderID
varchar
(
40
),
location
varchar
(
5
5
),
location
varchar
(
3
5
),
duration
int
(
10
),
dayofweek
int
(
2
)
,
occuredOn
date
,
FOREIGN
KEY
(
leaderID
)
REFERENCES
Volunteers
(
VolunteerID
),
maxAttendees
int
(
10
),
groupid
varchar
(
40
),
Nohelpers
int
(
10
));
reviewOfProgression
varchar
(
400
),
reviewOfstaffSafety
varchar
(
400
),
Nohelpers
int
(
10
));
DROP
TABLE
IF
EXISTS
`Badge`
;
CREATE
TABLE
`Badge`
(
BadgeID
varchar
(
40
)
not
null
unique
,
...
...
@@ -105,12 +108,11 @@ CREATE TABLE `StudentAttendance`(
FOREIGN
KEY
(
studentID
)
REFERENCES
Students
(
studentID
),
FOREIGN
KEY
(
sessionID
)
REFERENCES
Sessions
(
SessionID
)
);
CREATE
TABLE
`SessionHistory`
(
SessionHistoryID
varchar
(
40
),
heldOn
date
,
DROP
TABLE
IF
EXISTS
`VolunteerAttendance`
;
CREATE
TABLE
`VolunteerAttendance`
(
volunteerID
varchar
(
40
)
,
sessionID
varchar
(
40
),
reviewOfProgression
varchar
(
400
),
reviewOfStaffSafety
varchar
(
400
),
FOREIGN
KEY
(
VolunteerID
)
REFERENCES
Volunteers
(
volunteerID
),
FOREIGN
KEY
(
sessionID
)
REFERENCES
Sessions
(
SessionID
)
);
...
...
@@ -153,9 +155,12 @@ BEGIN
BEGIN
SELECT
'User already exists'
as
ERROR
;
END
;
IF
INSTR
(
email
,
"@"
)
>
0
then
INSERT
INTO
Volunteers
(
VolunteerID
,
fname
,
lname
,
email
,
emergencycontact
)
values
(
md5
(
concat
(
email
,
passwerd
)),
fname
,
lname
,
email
,
phonenum
);
end
if
;
END
$$
DELIMITER
;
...
...
@@ -230,15 +235,51 @@ BEGIN
INSERT
INTO
Students
(
StudentID
,
fname
,
lname
,
bday
,
parentsID
)
values
(
md5
(
concat
(
fname
,
lname
,
passwerd
)),
fname
,
lname
,
bday
,
parentsID
);
END
$$
DELIMITER
;
drop
procedure
if
exists
viewStudent
;
delimiter
$$
CREATE
PROCEDURE
viewStudent
(
IN
studentvID
varchar
(
40
))
BEGIN
If
LENGTH
(
studentvID
)
=
0
then
SELECT
s0
.
StudentID
,
s0
.
studentCode
,
s0
.
fname
,
s0
.
lname
,
s0
.
bday
,(
select
email
from
parents
where
parentID
=
s0
.
parentsID
),(
select
phonenum
from
parents
where
parentID
=
s0
.
parentsID
)
from
students
as
s0
;
else
SELECT
s0
.
StudentID
,
s0
.
studentCode
,
s0
.
fname
,
s0
.
lname
,
s0
.
bday
,(
select
email
from
parents
where
parentID
=
s0
.
parentsID
),(
select
phonenum
from
parents
where
parentID
=
s0
.
parentsID
)
from
students
as
s0
where
studentvID
=
s0
.
studentID
;
end
if
;
END
$$
DELIMITER
;
drop
procedure
if
exists
viewVolunteer
;
delimiter
$$
CREATE
PROCEDURE
viewVolunteer
(
IN
VolunteervID
varchar
(
40
))
BEGIN
If
LENGTH
(
volunteervID
)
=
0
then
SELECT
s0
.
VolunteerID
,
s0
.
volunteerCode
,
s0
.
fname
,
s0
.
lname
,
s0
.
DBSlastchecked
,
s0
.
SGlastchecked
,
s0
.
emergencycontact
,
s0
.
email
,(
select
sum
(
duration
)
from
Sessions
where
sessionID
in
(
select
sessionID
from
VolunteerAttendance
where
volunteerID
=
s0
.
volunteerID
))
from
volunteers
as
s0
;
else
SELECT
s0
.
VolunteerID
,
s0
.
volunteerCode
,
s0
.
fname
,
s0
.
lname
,
s0
.
DBSlastchecked
,
s0
.
SGlastchecked
,
s0
.
emergencycontact
,
s0
.
email
,(
select
sum
(
duration
)
from
Sessions
where
sessionID
in
(
select
sessionID
from
VolunteerAttendance
where
volunteerID
=
s0
.
volunteerID
))
from
volunteers
as
s0
where
volunteerID
=
volunteervID
;
end
if
;
END
$$
DELIMITER
;
call
addParent
(
"jeff"
,
"Jones"
,
"email@realemail.com"
,
"veryStrongPassw0rd"
,
02358254
);
call
addStudent
(
"bobby"
,
"jones"
,
'2012-2-11'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
"EXTRASTRONGPASSWORD"
);
call
addBadge
(
"real badge"
,
"this is a totally real badge"
);
call
addStudent
(
"timothy"
,
"jones"
,
'2002-2-11'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
"EXTREMELYSTRONGPASSWORD"
);
call
addVolunteer
(
"timothy"
,
"jones"
,
'bob@bbc.co.uk'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
"0777008913"
);
select
*
from
student
s
;
-- select * from parents
;
--
select * from
volunteer
s;
call
viewVolunteer
(
""
)
;
This diff is collapsed.
Click to expand it.
er1.png
0 → 100644
+
0
−
0
View file @
2ea4ccb6
318 KiB
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