Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SUPERGEEKS-SQL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
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
eab0259d
Commit
eab0259d
authored
2 years ago
by
Finlay White
Browse files
Options
Downloads
Patches
Plain Diff
removal working
parent
98e9968f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
createdb.sql
+49
-22
49 additions, 22 deletions
createdb.sql
with
49 additions
and
22 deletions
createdb.sql
+
49
−
22
View file @
eab0259d
...
...
@@ -21,7 +21,7 @@ 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
DEFAULT
CURDATE
()
,
dayjoined
date
,
parentsID
varchar
(
40
),
groupID
varchar
(
40
),
FOREIGN
KEY
(
parentsID
)
REFERENCES
Parents
(
parentID
)
...
...
@@ -72,12 +72,11 @@ CREATE TABLE `Badge`(
CREATE
TABLE
`WaitList`
(
studentID
varchar
(
40
)
unique
,
Session
ID
varchar
(
40
),
group
ID
varchar
(
40
),
dateJoined
date
,
dateRemoved
date
,
ageGroup
int
(
1
),
FOREIGN
KEY
(
studentID
)
REFERENCES
Students
(
studentID
),
FOREIGN
KEY
(
SessionID
)
REFERENCES
Sessions
(
SessionID
));
FOREIGN
KEY
(
studentID
)
REFERENCES
Students
(
studentID
));
...
...
@@ -226,16 +225,15 @@ drop procedure if exists `applyToGroup`;
delimiter
$$
CREATE
PROCEDURE
applyToGroup
(
IN
studentID
varchar
(
40
),
IN
SessionID
varchar
(
255
),
IN
ageGroup
int
(
1
))
IN
groupID
varchar
(
40
))
BEGIN
DECLARE
EXIT
HANDLER
FOR
1062
BEGIN
SELECT
'This student is already on a wait list'
as
ERROR
;
END
;
INSERT
INTO
WaitList
(
StudentID
,
Session
ID
,
dateJoined
,
ageGroup
)
values
(
StudentID
,
Session
ID
,
CURDATE
()
,
ageGroup
);
INSERT
INTO
WaitList
(
StudentID
,
group
ID
,
dateJoined
)
values
(
StudentID
,
group
ID
,
CURDATE
());
END
$$
DELIMITER
;
...
...
@@ -357,19 +355,38 @@ CREATE PROCEDURE addToGroup(
IN
grapeID
varchar
(
40
))
BEGIN
select
count
(
distinct
volunteerID
)
into
@
noOfVols
from
volunteerattendance
as
v0
DECLARE
toad
INT
DEFAULT
0
;
DECLARE
a
INT
Default
0
;
select
count
(
distinct
volunteerID
)
*
(
SELECT
ageGroup
from
Sessions
where
groupID
=
grapeID
limit
1
)
into
@
maxstu
from
volunteerattendance
as
v0
where
grapeID
in
(
select
groupID
from
Sessions
as
s0
where
v0
.
sessionID
=
s0
.
sessionID
And
date_add
(
s0
.
OccuredOn
,
interval
14
day
)
>
CURDATE
()
=
1
)
;
select
count
(
*
)
*
(
SELECT
ageGroup
from
Sessions
where
groupID
=
grapeID
limit
1
)
from
students
as
stu0
where
grapeID
in
(
select
groupID
from
sessions
as
s2
where
stu0
.
studentID
in
(
select
studentID
from
StudentAttendance
as
att0
where
stu0
.
studentID
=
att0
.
StudentID
));
-- select @noOfStus;
date_add
(
s0
.
OccuredOn
,
interval
7
day
)
>
CURDATE
()
=
1
)
;
-- UPDATE WaitList as wl0,students as stu2
select
count
(
*
)
into
@
currentStu
from
students
as
stu0
where
grapeID
in
(
select
groupID
from
sessions
as
s2
where
stu0
.
studentID
in
(
select
studentID
from
StudentAttendance
as
att0
where
stu0
.
studentID
=
att0
.
StudentID
));
set
toad
=
@
maxstu
-
@
currentStu
;
if
toad
is
not
null
and
toad
>
0
then
simple_loop
:
LOOP
SET
a
=
a
+
1
;
select
studentID
from
waitlist
where
(
dateRemoved
is
null
)
order
by
dateJoined
asc
limit
1
into
@
theChosenOnes
;
UPDATE
WaitList
as
wl0
,
students
as
stu2
SET
stu2
.
groupID
=
grapeID
,
wl0
.
dateRemoved
=
CURDATE
()
where
wl0
.
studentID
=
@
theChosenOnes
;
IF
a
=
toad
THEN
LEAVE
simple_loop
;
END
IF
;
END
LOOP
simple_loop
;
end
if
;
-- UPDATE WaitList as wl0,students as stu2
-- SET stu2.groupID=grapeID,wl0.dateRemoved=CURDATE() where stu2.studentID in (@theChosenOnes);
-- UPDATE student set groupID =groupID where true;
END
$$
DELIMITER
;
...
...
@@ -438,20 +455,30 @@ call addParent("jeff","Jones","email@realemail.com","veryStrongPassw0rd",0235825
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
addStudent
(
"samantha"
,
"jones"
,
'2012-2-11'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
'superSTRONGPASSWORD'
);
call
addStudent
(
"tom"
,
"jones"
,
'2012-2-11'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
'superSTRONGPASSWORD'
);
call
viewstudent
(
''
);
select
*
from
students
;
call
addVolunteer
(
"timothy"
,
"jones"
,
'bob@bbc.co.uk'
,
'8e301d6e513165a9c0b6b9a2b10c8305'
,
"0777008913"
);
call
applytogroup
(
'b6e14bcdd6a79c8f8cd9fcef3be5f00b'
,
'41'
);
call
applytogroup
(
'031f0ba110c9683bf4cf5d2836b32a95'
,
41
);
call
updateSG
(
'419fd9859978a9bf79df4ff16c99c5f9'
,
"2020-04-09"
);
call
updateDBS
(
'419fd9859978a9bf79df4ff16c99c5f9'
,
"2021-09-09"
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-02-03'
,
8
,
'41'
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-02-03'
,
3
,
'41'
);
call
ReviewSession
(
md5
(
'2023-02-03'
),
"it was ok"
,
"idk"
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-01-03'
,
8
,
'41'
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-01-03'
,
3
,
'41'
);
call
ReviewSession
(
md5
(
'2023-01-03'
),
"it was ok"
,
"idk"
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2022-11-03'
,
8
,
'41'
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-04-16'
,
8
,
'41'
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2022-11-03'
,
3
,
'41'
);
call
addSession
(
"computer lab"
,
3
,
'419fd9859978a9bf79df4ff16c99c5f9'
,
'2023-04-16'
,
3
,
'41'
);
CALL
STUDENTATTENDS
(
'562fe5b6c65003a11148594678c42b90'
,
'94b21f931d888fefd4da7a07c01dff4a'
);
call
studentattends
(
'313b6d9a06c3a0618f72ec75c082b6a4'
,
'94b21f931d888fefd4da7a07c01dff4a'
);
call
viewVolunteer
(
''
);
select
*
from
sessions
;
select
*
from
students
;
select
*
from
waitlist
;
call
viewCheckExpiries
();
call
addToGroup
(
'41'
);
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