Chapter 18 Application Flashcards

1
Q

Login as user root to create a database named csci and user named developer at localhost with the password ‘whoAmI’.

A

create database csci;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Have root grant privileges to developer for creating and maintaining tables with the option to delegate grants to other users.

A

grant all on csci.* to developer@localhost identified by ‘whoAmI’ with grant option;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Show the privileges granted to the developer.

A

show grant for developer@localhost;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The user named developer is to:

a. create a view named csciMajor that permits access to complete student records that are CSCI majors;

A

create or replace view csciMajor as select * from student where major = ‘CSCI’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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;

A

create or replace view csciList as select sid, sname, major, classYear from student where major = ‘CSCI’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

c. create gradeReport, a join view, with sName, cCode and grade;

A

create or replace view gradeReport as select sname, cCode, grade from student s join enrollemnt e on s.sid = e.sid;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

d. create courseLoad, a statistical summary view, with columns sName and count(*) of course enrollments by student.

A

create or replace view courseLoad as select sName, count(*) as courses from student s, enrollment e where s.sid = e.sid group by sname;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Show the views created for the student table.

A

show create view csciMajor;

show create view csci;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Have root create users admiss, deptHead, advisor and professor with these privileges:
a) User admiss may select, insert, update, and delete student data;

A

exit;
mysql -u root -p mysql
grant select, insert, update, delete on csci.student to admiss@localhost identified by ‘secret’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

b) User deptHead is to have select privileges over the view courseLoad with authorization to grant this privilege to another user;

A

grant select on csci.courseLoad to deptHead@localhost identified by ‘secret’ with grant option;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

c) User advisor may select from csciList and update major in student (this may also require the select privilege on csci.student).

A

grant select on csci.csciList to advisor@localhost identified by ‘secret’;

grant select,update(major) on student to advisor@localhost;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

d) User professor is to have permission to query csciList and to update grade in Enrollment.

A

grant select,update(grade) on csci.enrollment to professor@localhost identified by ‘drSaffer’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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, …).

A

show grants for developer@localhost;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Revoke the privileges granted above.

A

revoke select,insert,update,delete on csci.student from admiss@localhost;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly