Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

ASSIGNMENT 1

Yashraj Kunwar
3125511
Database Systems – ACS-3902-003-U2022W
Due date : 1/16/2023
Exercise 1.1 Communication with the Lecturer

What is the format of an email you would send to Dr. Beck concerning this
lecture? In particular:
• What must the subject-line of your email be?

- No matter what I write, the email should have “ACS-3902-003[My name]” as


the subject line.

• What information must the email contain?

- The email should contain the name and student-id along with the subject line.

Exercise 1.2

Proper defined name for the highlighted part :

CAR – Relation Name


Engine_serial_number - Attribute
<”California RSK-629” “Y82935” “Toyota” “Camry” 04> – Tuple

1. t2 = < “Florida TVP-347”, “B43696”, “Oldsmobile”, “Cutlass”, 05 >


2. t2(3) = Oldsmobile
3. dom(Year) = { 02, 05, 01, 99, 04 }

Which of these examples are in dom(𝐴1 ) × … × dom(𝐴5)? For those which are
not explain why!
This relation needs to output result of 5-tuples which means these tuples should
contain 5 values inside it.

• <New York MBX-24, T202012, XJS, 12>


This is not in dom(𝐴1 ) × … × dom(𝐴5) as it contains 4-tuple.

• <New York, MBX-24, T202012, Jaguar, XJS, 12>


This is not in dom(𝐴1 ) × … × dom(𝐴5) as New York and MBX-24 should be the
same value of an attribute which is license number..

• <MBX-24 New York, T202012, Jaguar, XJS, 12> Incorrect, License number should
have city name in the front of it.

This is in dom(𝐴1 ) × … × dom(𝐴5) as it contains 5-tuple.

• <New York MBX-24, T202012, Jaguar, 12, XJS> Model year should be at last , incorrect
This is in dom(𝐴1 ) × … × dom(𝐴5) as it contains 5-tuple.

• <New York MBX-24, T202012, Jaguar, XJS, 12>


This is in dom(𝐴1 ) × … × dom(𝐴5) as it contains 5-tuple.

• <Winnipeg JET-18, T202012, Jaguar, XJS,

This is not in dom(𝐴1 ) × … × dom(𝐴5) as it contains 4-tuple.

Exercise 1.3

A relation is a set of tuples(rows) whereas a tuple is an ordered set of values.

Formally,
Given R(A1, A2, .........., An)
r(R) dom (A1) X dom (A2) X ....X dom(An)
R(A1, A2, ..., An) is the schema of the relation
R is the name of the relation
Whereas,

r(R): a specific state (or "value" or “population”) of


relation R – this is a set of tuples (rows)
r(R) = {t1, t2, ..., tn} where each ti is an n-tuple
ti = <v1, v2, ..., vn> where each vj element-of dom(Aj)

Exercise 1.4

Determine for each of the following constraints whether they are an “implicit
constraint”, an “explicit
constraint”, or a “semantic constraint”:

• A student cannot register for more than 20 courses per semester

Semantic constraint

• Each relation contains at least 1 attribute

Explicit constraint

• The attribute ENROLLMENT.StudentId refers to STUDENT.Id

Implicit constraint

• The number of values inside a tuple of a relation is equal to the number of


attributes in that
Relation

Explicit constraint

• The domain of STUDENT.Id are integers from 0 to 28

Impilicit constraint

• An employee cannot be their own manager


Semantic constraint

• The attribute COMPANY.RegistryNumber is the primary key of COMPANY.

Implicit constraint

• The value of primary keys of a relation must be distinct for each distinct tuple

Explicit constraint

Exercise 1.5

Suppose that each of the following Update operations is applied directly to the
database state shown
in Figure 5.6. Discuss all integrity constraints violated by each operation, if any,
and the different
ways of enforcing these constraints.

a. Insert <‘Robert’, ‘F’, ‘Scott’, ‘943775543’, ‘1972-06-21’, ‘2365 Newcastle Rd,


Bellaire, TX’, M,
58000, ‘888665555’, 1> into EMPLOYEE.

- There is no violation

b. Insert <‘ProductA’, 4, ‘Bellaire’, 2> into PROJECT.

- There is no violation

c. Insert <‘Production’, 4, ‘943775543’, ‘2007-10-01’> into DEPARTMENT.

- There is a violation in key constraint i.e. the value of the key attribute ‘4’
already exists in the another tuple in the relation

d. Insert <‘677678989’, NULL, ‘40.0’> into WORKS_ON.


- There is violation against Entity integrity : Essn and Pno creates a composit key
but the composite key value cannot be null.

e. Insert <‘453453453’, ‘John’, ‘M’, ‘1990-12-12’, ‘spouse’> into DEPENDENT.

- There is a violation
It violates key constraint : Attribute value I.e 453453453 is already in use by
another attribute because of which we cannot insert it

f. Delete the WORKS_ON tuples with Essn = ‘333445555’.

There is no violation

g. Delete the EMPLOYEE tuple with Ssn = ‘987654321’.

There is a violation

h. Delete the PROJECT tuple with Pname = ‘ProductX’.


There is no violation

i. Modify the Mgr_ssn and Mgr_start_date of the DEPARTMENT tuple with


Dnumber = 5 to
‘123456789’ and ‘2007-10-01’, respectively.

There is no violation

j. Modify the Super_ssn attribute of the EMPLOYEE tuple with Ssn =


‘999887777’ to
‘943775543’.

There is no violation

k. Modify the Hours attribute of the WORKS_ON tuple with Essn = ‘999887777’
and Pno = 10 to
‘5.0’.

There is no violation
Exercise 1.6

Consider the following relations for a database that keeps track of student
enrollment in courses and
the books adopted for each course:
STUDENT(Ssn, Name, Major, Bdate)
COURSE(Course#, Cname, Dept)
ENROLL(Ssn, Course#, Quarter, Grade)
BOOK_ADOPTION(Course#, Quarter, Book_isbn)
TEXT(Book_isbn, Book_title, Publisher, Author)
Specify the foreign keys for this schema, stating any assumptions you make

- Student ( Primary key – Ssn, Foreign key – N/a)


- Course (Primary key – Course#, Foreign key – N/a)
- Enroll (Foreign Key – SSn, Course#)
- Book_Adoption( Foreign key – Course#)
- TEXT(Foreign key – Book_isbn)

You might also like