I
,NF3707 Assignment 3 (COMPLETE ANSWERS)
2024 (620712) - DUE 2 August 2024 ; 100%
TRUSTED Complete, trusted solutions and
Question 1: Chapter 6 To perform the following assignments,
refer to the tables in the JustLee books database. 1.1 Create a
sequence for populating the Custeomer# column of the
CUSTOMERS table. When setting the start and the increment
values, beer in mind that data already exist in the table. Hence,
you need to know the last customer number stored in the
database. The options should be set not to cycle the values and
not to cache any values. No minimum or maximum values
should be declared. (2 marks) 1.2 Add a new customer row by
using the sequence created in Question 1.1. the only data
currently available for the customer is as follows: last name =
Shoulders, first_name = Frank, and zip = 23567. (3 marks)
Question 2 Chapter 7 JustLee Books has recently hired a
temporary salesman. The name of the new employee is John.
The login credential for John should expire at the end of his
contract. As a salesperson, John should be granted some object
privileges on the JustLee Books database. 2.1 create the user
John with a password that expire with the role of sales_person
(3 marks).
To assist with these assignments, you'll need to use SQL
(Structured Query Language) to interact with the JustLee Books
database. Here are the steps and SQL commands required for
each task:
,Question 1: Chapter 6
1.1 Create a sequence for populating the Customer# column of
the CUSTOMERS table.
First, you need to find the last customer number in the
CUSTOMERS table. You can do this with a query:
sql
Copy code
SELECT MAX(Customer#) FROM CUSTOMERS;
Assuming the last customer number is, for example, 100, you
can then create a sequence starting from 101:
sql
Copy code
CREATE SEQUENCE customer_seq
START WITH 101
INCREMENT BY 1
NOCYCLE
NOCACHE;
This sequence will start from 101 and increment by 1 for each
new customer, without cycling and without caching values.
1.2 Add a new customer row using the sequence created in
Question 1.1.
, You can use the customer_seq sequence to add a new row to
the CUSTOMERS table:
sql
Copy code
INSERT INTO CUSTOMERS (Customer#, last_name, first_name,
zip)
VALUES (customer_seq.NEXTVAL, 'Shoulders', 'Frank', '23567');
Question 2: Chapter 7
2.1 Create the user John with a password that expires and
assign the role of sales_person.
First, create the user John with a password that expires:
sql
Copy code
CREATE USER John IDENTIFIED BY temporary_password
PASSWORD EXPIRE;
Then, grant the sales_person role to John. Assuming the
sales_person role already exists, you can grant it to John:
sql
Copy code
GRANT sales_person TO John;