100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

INF3707 ASSIGNMENT 3 2023 Database Design and Implementation

Rating
-
Sold
-
Pages
10
Uploaded on
08-08-2023
Written in
2023/2024

INF3707 ASSIGNMENT 3 2023 Database Design and Implementation

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
August 8, 2023
Number of pages
10
Written in
2023/2024
Type
Other
Person
Unknown

Subjects

Content preview

QUESTION 1

1.1 The sequence MY_FIRST_SEQ can be created by using the following code:



CREATE SEQUENCE MY_FIRST_SEQ

START WITH 5

INCREMENT BY -3

MINVALUE 0

NOCYCLE;



1.2 The SELECT statement to display NEXTVAL for MY_FIRST_SEQ three times can be issued as
follows:



SELECT MY_FIRST_SEQ.NEXTVAL FROM dual;

SELECT MY_FIRST_SEQ.NEXTVAL FROM dual;

, SELECT MY_FIRST_SEQ.NEXTVAL FROM dual;



The error on the third SELECT statement is caused by reaching the maximum value defined for the
sequence. Since the sequence has a maximum value of 0, it cannot generate a value greater than 0.



1.3 The failure to create the table ord_items is caused by referencing a non-existent table "orders" in
the FOREIGN KEY constraint. The corrected CREATE TABLE code is as follows:



CREATE SEQUENCE ord_seq

INCREMENT BY 10

START WITH 120

MAXVALUE 9999

NOCYCLE;



CREATE TABLE ord_items

(ord_no NUMBER (4) DEFAULT ord_seq.NEXTVAL NOT NULL,

item_no NUMBER(3),

qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200),

expiry_date date CHECK (expiry_date > SYSDATE),

CONSTRAINT its_pky PRIMARY KEY (ord_no, item_no),

CONSTRAINT ord_fky FOREIGN KEY(ord_no) REFERENCES ord_items(ord_no)

);



QUESTION 2

.1 To create the user Peter with a password that expires and assign the role of salesperson, use the
following code:



CREATE USER Peter IDENTIFIED BY [password] PASSWORD EXPIRE;



GRANT salesperson TO Peter;

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
GoldenKey University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
135
Member since
4 year
Number of followers
122
Documents
31
Last sold
3 months ago

3.4

11 reviews

5
4
4
1
3
3
2
1
1
2

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions