Project
Project
1)
a) Create Bank Manager has a database administrator DBA user and create the
Customer table with the relevant attributes and insert at least 10 customer records
under Bank Manager user login. (Note:- Assume what all attributes required for a
customer in bank).
Command:
CREATE TABLE Customer (
customer_id INT PRIMARY KEY,
name VARCHAR(50),
address VARCHAR(100),
phone_number VARCHAR(15),
account_number VARCHAR(20),
balance DECIMAL(10, 2)
);
1
(5, 'David Wilson', '987 Cedar St', '444-444-4444', '4444444444', 3000.00),
(6, 'Emily Brown', '654 Walnut St', '777-888-9999', '7778889999', 2500.00),
(7, 'Michael Smith', '234 Maple St', '222-333-4444', '2223334444', 3500.00),
(8, 'Jessica Taylor', '876 Birch St', '999-888-7777', '9998887777', 4000.00),
(9, 'Andrew Miller', '543 Pine St', '666-777-8888', '6667778888', 4500.00),
(10, 'Olivia Johnson', '765 Oak St', '333-222-1111', '3332221111', 5000.00);
b) Create 4 different users in the bank for each work under Bank Manager login.
(like clerk, cashier, auditor & manager).
Command:
CREATE USER clerk IDENTIFIED BY password;
CREATE USER cashier IDENTIFIED BY password;
CREATE USER auditor IDENTIFIED BY password;
CREATE USER manager IDENTIFIED BY password;
c) Create different views for every user which you created in the 2nd Step which is
necessary for that particular user as per the bank role.
Command:
CREATE VIEW clerk_view AS SELECT customer_id, name, address FROM
Customer;
CREATE VIEW cashier_view AS SELECT customer_id, name, address,
account_number, balance FROM Customer;
CREATE VIEW auditor_view AS SELECT * FROM Customer;
CREATE VIEW manager_view AS SELECT * FROM Customer;
d) Give any user only view permission as per the realistic bank role.
Command:
GRANT SELECT ON clerk_view TO clerk;
GRANT SELECT ON cashier_view TO cashier;
GRANT SELECT ON auditor_view TO auditor;
GRANT SELECT ON manager_view TO manager;
2
e) Give any user only update permission the balance attribute when there is a cash
deposit or cash withdrawal as per the realistic bank role.
Command:
GRANT UPDATE (balance) ON Customer TO cashier;
f) Give auditor only delete permission and show any delete transaction.
Command:
GRANT DELETE ON Customer TO auditor;
2. Suppose that the database administrator (DBA) creates four users: user1, user2,
user3, and user4. DBA issues the following GRANT command in SQL
3
And suppose that user2 creates the three base tables department, student, and
course. Do the following questions based on the given direction.
a) Write SQL command, if user2 wants to grant user3 the privilege to enter and
read rows in the student relation, and also user2 wants user3 to be able to propagate
these privileges to other users.
Command:
GRANT INSERT, SELECT ON student TO user3 WITH GRANT OPTION;
b) Write SQL command, based on question number A, if user3 wants to grant user1
the privilege to insert data in the student relation, but user3 does not want user1 to
be able to propagate these privileges to other users.
Command:
GRANT INSERT ON student TO user1;
c) Write SQL command, if user2 wants to grant all users the privilege to insert,
delete, update, and delete rows in the three relations, but each user does not want to
be able to propagate these privileges to other users.
Command:
GRANT INSERT, DELETE, UPDATE, SELECT ON department, student, course
TO PUBLIC;
Command:
REVOKE INSERT, DELETE ON department, student, course FROM user1, user4;