Database
|
Pg. 01 |
|
Question Four |
|
|
|
|
Assignment 2
Deadline: Day 06/04/2021 @ 23:59
[Total Mark for this Assignment is 5]
Introduction to Database
IT244
College of Computing and Informatics
|
|
|
|
|
|
|
|
Question One
1 Marks
Learning Outcome(s):
Create entity-relationship model, relational model, and write SQL queries.
Consider the following relations Company and Product. Give the result for the following relational algebra operations:
A) PName, Price (country=“USA”(Company Product))
B) PName, StockPrice (Product Company)
Company
|
CName |
StockPrice |
Country |
|
Works |
25 |
USA |
|
Canon |
65 |
Japan |
|
Hitachi |
15 |
Japan |
Product
|
PName |
Price |
Category |
CName |
|
Gizmo |
$19.99 |
Gadgets |
Works |
|
Power |
$29.99 |
Gadgets |
Works |
|
SingleTouch |
$149.99 |
Photography |
Canon |
|
MultiTouch |
$203.99 |
Household |
Samsong |
Question Two
2 Marks
Learning Outcome(s):
Create entity-relationship model, relational model, and write SQL queries.
Consider the following relations database schema. The primary key is underlined, and all attributes are of type string if not indicated otherwise.
branch(branch_name, branch_city)
customer(customer_id, customer_name,customer_street,customer_city)
account(account_number, branch_name, balance: integer)
depositor(customer_id, account_number)
Write SQL queries to:
a) Find all the branch names with customers who have accounts of balance less than $2000 and the branch is located in LA.
b) Delete all customers who do not have an account. (Assume the bank keeps the customer information even if the account is closed.
Question Three
1 Marks
Learning Outcome(s):
Create entity-relationship model, relational model, and write SQL queries.
Construct truth table for the following logical expressions.
(𝑃∧𝑄)∨¬(P∧Q)∨¬P
|
𝑃 |
𝑄 |
𝑃∧𝑄 |
¬(P∧Q) |
¬P |
(𝑃∧𝑄)∨¬(P∧Q)∨¬P |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Question Four
1 Mark
Learning Outcome(s):
Create entity-relationship model, relational model, and write SQL queries.
What is the purpose of LIKE operator in SQL? Support your answer with an example.