Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

emp(eid(underlined), ename, age, salary) dept(did (underlined), dname, budget, m

ID: 3840901 • Letter: E

Question

emp(eid(underlined), ename, age, salary)
dept(did (underlined), dname, budget, managerid)
works (eid(underlined), did(underlined), pct_time)

a. suppose the emps-works-dept database (see table above) is loaded into schema hr (Human resources). the owner of this schema has made these tables readable by user user1 in user1 schema, also named user1 (this could be MySQL or Oracle) Give the SQL for user1 to display all the rows of the table emps in schema hr.

b. suppose user user1 wants user user2 to be able to read department IDs and names, but not budgets. propose a way (show the SQL) for user user1 to provide this data to user user2

c. give the SQL for user2 to display all the department IDs and names, once they have become available via the actions in part b.

Explanation / Answer

a. select * from the hr.emp;

This will retrieve all the rows from the table emp which is in hr schema.

b. In order to make available only particular rows it is better and secure to create a view for this specified rows only and can grant this permissions to the user 2

This will create the view for the department id and name columns only. So this can be given to user2. So that he only access this column records only.

c. select did,dname from department;

By this he can access did and dname.