Chapter 18 Application Flashcards
Login as user root to create a database named csci and user named developer at localhost with the password ‘whoAmI’.
create database csci;
Have root grant privileges to developer for creating and maintaining tables with the option to delegate grants to other users.
grant all on csci.* to developer@localhost identified by ‘whoAmI’ with grant option;
Show the privileges granted to the developer.
show grant for developer@localhost;
The user named developer is to:
a. create a view named csciMajor that permits access to complete student records that are CSCI majors;
create or replace view csciMajor as select * from student where major = ‘CSCI’;
b. create a view named csciList that materializes a row and column subset with access to sId, sName, major, and classYear but not to birthdate in rows for ‘CSCI’ majors;
create or replace view csciList as select sid, sname, major, classYear from student where major = ‘CSCI’;
c. create gradeReport, a join view, with sName, cCode and grade;
create or replace view gradeReport as select sname, cCode, grade from student s join enrollemnt e on s.sid = e.sid;
d. create courseLoad, a statistical summary view, with columns sName and count(*) of course enrollments by student.
create or replace view courseLoad as select sName, count(*) as courses from student s, enrollment e where s.sid = e.sid group by sname;
Show the views created for the student table.
show create view csciMajor;
show create view csci;
Have root create users admiss, deptHead, advisor and professor with these privileges:
a) User admiss may select, insert, update, and delete student data;
exit;
mysql -u root -p mysql
grant select, insert, update, delete on csci.student to admiss@localhost identified by ‘secret’;
b) User deptHead is to have select privileges over the view courseLoad with authorization to grant this privilege to another user;
grant select on csci.courseLoad to deptHead@localhost identified by ‘secret’ with grant option;
c) User advisor may select from csciList and update major in student (this may also require the select privilege on csci.student).
grant select on csci.csciList to advisor@localhost identified by ‘secret’;
grant select,update(major) on student to advisor@localhost;
d) User professor is to have permission to query csciList and to update grade in Enrollment.
grant select,update(grade) on csci.enrollment to professor@localhost identified by ‘drSaffer’;
Show grants [for ‘user’@’localhost’]; or query information_schema to find information about authorizations granted by the current user. Include grantee, table name and privileges (select, insert, …).
show grants for developer@localhost;
Revoke the privileges granted above.
revoke select,insert,update,delete on csci.student from admiss@localhost;