0% found this document useful (0 votes)
6 views2 pages

Midterm Section4

Uploaded by

hayamousa78
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Midterm Section4

Uploaded by

hayamousa78
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Course's Name: Database Palestine Technical University-Kadoorie Instructor’s Name: Eng.

Haya
Systems Lab Abu-Raed

Course's Number: 12140314 Student’s Name: ______________

Exam’s Period: 1 hour Student’s Number: ____________

Number of Pages: 2 Section’s Number: 4


Midterm Exam
Total Mark: 35 First Semester 2024-2025 Exam’s Date: 11/12/2024

Question: using the following tables, answer the following sections with the
suitable SQL statements:

Table 1 Sample Data - Publishers Table Table 3 Sample Data - Sales Table

ID Name Country CheckNumber PaymentMethod BookID


101 Bloomsbury Publishing UK GT1256 Credit Card 201
102 Secker & Warburg UK SFE597 PayPal 202
103 Penguin Classics US HJY495 Cash 203
104 HarperCollins US ARV597 Debit Card 202

Table 2 Sample Data – Books Table


ID Title PublishDate PublisherID Price
201456 Harry Potter and the Philosopher's Stone 1997-06-26 101 20.99
202753 1984 1949-06-08 102 15.99
203957 Pride and Prejudice 1813-01-28 103 10.99

1- Create a new user named student_[your name] and give it all the privileges you might need, then
authenticate. (3 marks)

2- Create the previous three tables with appropriate data types, constraints, and relationships
between them, ensuring the following: (10 marks)
o The book ID is up to 6 digits, and book price consists of 4 digits, as in the sample data.
o The book’s title and the payment method cannot be empty.
o The publisher’s name must allow a maximum of 100 characters.
o The payment method should be cash unless otherwise provided.
3- Add a new column PhoneNumber to the PUBLISHERS table. (2 marks)
Entry example: +970591234567

4- Modify the publisher’s name to accept the maximum number of characters. (2 marks)

5- Rename the CheckNumber column in SALES table to ID. (2 marks)

6- Adjust the Price column as needed to accept bills in the thousands. (2 marks)

7- Add a constraint named PRICE_CNST to ensure that the Price column contains a value larger
than zero. (3 marks)

8- Require the PublishedDate column to automatically store yesterday’s date (the day prior to the
entry date) if no value is provided. (2 marks)

9- Remove the PRICE_CNST constraint from the Price column. (1 mark)

10- Change the password to password456 of your student_user account then lock it. (2 marks)

11- Remove the administrative roles from your user. (2 marks)

12- Sara has created a new user and she is sure that she has received a success message . However,
when she tries to log in to the new account, she encounters the error: invalid
username/password; logon denied. What might have gone wrong, and what SQL commands
would you advise her to use to resolve this issue? (4 marks)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy