0% found this document useful (0 votes)
127 views3 pages

2808ICT Assignment 2 Comment

The document creates SQL users and assigns privileges for a university database. It creates users for students, academic staff, and administrators. It grants SELECT privileges to allow students and staff to view courses and grades. It grants additional privileges to administrators to manage enrollment and course data. Views are created to restrict data access based on user roles.

Uploaded by

William Chin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views3 pages

2808ICT Assignment 2 Comment

The document creates SQL users and assigns privileges for a university database. It creates users for students, academic staff, and administrators. It grants SELECT privileges to allow students and staff to view courses and grades. It grants additional privileges to administrators to manage enrollment and course data. Views are created to restrict data access based on user roles.

Uploaded by

William Chin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

!!!Do not copy this into sql bo, may cuase error cuase of incoding!!!

--User according to the appendix, and the password is their first name, ip is not
specified so hostname is set as %

CREATE USER 'U07'@'%' IDENTIFIED BY 'Angela';

CREATE USER 'U08'@'%' IDENTIFIED BY 'Donaldo';

CREATE USER 'U04'@'%' IDENTIFIED BY 'Seb';

CREATE USER 'U06'@'%' IDENTIFIED BY 'Miguel';

CREATE USER 'U02'@'%' IDENTIFIED BY 'Cristiano';

CREATE USER 'U03'@'%' IDENTIFIED BY 'Lionel';

--Admin staff who charge on enrollment has privilege to select, insert, delete and update
on Enrolment table. (U02)

-- Admin staff who charge on Course has privilege to select, insert, delete and update on
Course table. (U03)

GRANT SELECT, INSERT, DELETE, UPDATE ON University.Enrolment TO 'U02'@'%';

GRANT SELECT, INSERT, DELETE, UPDATE ON University.Course TO 'U03'@'%';

--Student and academic staff can only see the course contents, cant edit.

GRANT SELECT ON University.Course TO 'U07'@'%';

GRANT SELECT ON University.Course TO 'U08'@'%';

GRANT SELECT ON University.Course TO 'U04'@'%';

GRANT SELECT ON University.Course TO 'U06'@'%';

--Academic staff can see the name and gender of student but not for other information.

GRANT SELECT(first_name, last_name, sex) ON University.Student TO 'U04'@'%';

GRANT SELECT(first_name, last_name, sex) ON University.Student TO 'U06'@'%';

--Assigning view to student user to allow them to check their grade.


GRANT SELECT(grade, user_id) ON University.Enrolment TO 'U07'@'%';

CREATE VIEW see_my_grade_s01 AS

SELECT grade, user_id

FROM Enrolment

WHERE user_id = 'S01';

GRANT SELECT ON see_my_grade_s01 TO 'U07'@'%';

GRANT SELECT(grade, user_id) ON University.Enrolment TO 'U08'@'%';

CREATE VIEW see_my_grade_s02 AS

SELECT grade, user_id

FROM Enrolment

WHERE user_id = 'S02';

GRANT SELECT ON see_my_grade_s02 TO 'U08'@'%';

I used Inner join to use ‘ON’ clause to match user ID.

--Assigning academic staff to enrolment status for their course.

GRANT SELECT ON University.Enrolment TO 'U04'@'%';

CREATE VIEW see_enrolment_a01 AS SELECT Enrolment . *

FROM Enrolment

INNER JOIN Course ON Enrolment.course_id = Course.course_id

WHERE Course.user_id = 'A01';

GRANT SELECT ON see_enrolment_a01 TO 'U04'@'%';

GRANT SELECT ON University.Enrolment TO 'U06'@'%';


CREATE VIEW see_enrolment_a03 AS SELECT Enrolment . *

FROM Enrolment

INNER JOIN Course ON Enrolment.course_id = Course.course_id

WHERE Course.user_id = 'A03';

GRANT SELECT ON see_enrolment_a03 TO 'U06'@'%';

--Allow academic staff to modify the grade(match with their user id)

GRANT UPDATE(grade) ON University.Enrolment TO 'U04'@'%';

CREATE VIEW modify_grade_a01 AS

SELECT Enrolment. *

FROM Enrolment

INNER JOIN Course ON Enrolment.course_id = Course.course_id

WHERE Course.user_id = 'A01';

GRANT UPDATE ON modify_grade_a01 TO 'U04'@'%';

GRANT UPDATE(grade) ON University.Enrolment TO 'U06'@'%';

CREATE VIEW modify_grade_a03 AS

SELECT Enrolment. *

FROM Enrolment

INNER JOIN Course ON Enrolment.course_id = Course.course_id

WHERE Course.user_id = 'A03';

GRANT UPDATE ON modify_grade_a03 TO 'U06'@'%';

You might also like