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

Midterm Section3

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)
9 views2 pages

Midterm Section3

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: 3


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 - Customers Table Table 2 Sample Data - Orders Table

ID FirstName LastName ID OrderDate CustomerID Amount


102 Ahmed Al-Faisal 564327 2024-12-01 103 50.00
103 Fatima Al-Hassan 795143 2024-12-05 103 100.89
106 Khalid Al-Amari 951367 2024-12-06 102 250.00
110 Noor Omari 159763 2024-12-06 106 168.33

Table 3 Sample Data – Payments Table


CheckNumber PaymentMethod OrderID
GT1256 Credit Card 795143
SFE597 PayPal 564327
HJY495 Cash 951367

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 order ID is up to 6 digits, and order amount consists of 5 digits, as in the sample data.
o The customer’s first name and the payment method cannot be empty.
o The customer’s last 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 CUSTOMERS table. (2 marks)
Entry example: +970591234567

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

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

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

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

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

9- Remove the DATE_CNST constraint from OrderDate 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