You are on page 1of 7

Name: Marco Mclean

ID#: 2209181

Define the following terms:


a. Normalization - Normalization is a process of organizing data in a database to
reduce redundancy and improve data integrity. It involves dividing a large table
into smaller tables and linking them together using relationships. Normalization is
important because it helps to ensure that data is accurate, consistent, and easy to
access.
b. Functional Dependency (Give examples) - Functional dependency (FD) is a
relationship between two or more attributes in a database. It states that the value of
one attribute (the determinant) determines the value of another attribute (the
dependent).
For example, in a student database, there is an FD between the student ID and the
student name. This means that the value of the student ID determines the value of
the student name. In other words, there is only one student with a given student ID.

c. Update, Insertion and Delete Anomalies (Give Examples) - Update, insertion,


and delete anomalies are three types of data anomalies that can occur in a database
that is not normalized.
• Update anomalies occur when updating the value of one attribute in a table
causes unintended changes to the values of other attributes in the table.
• Insertion anomalies occur when you cannot insert a new record into a table
because the table does not have the necessary information.
• Delete anomalies occur when deleting a record from a table causes the loss
of other data that should not have been deleted.

Examples of update, insertion, and delete anomalies:


Update anomaly: A table that stores student information, including the student's
name, student ID, and major. The student ID is the primary key of the table. If you
update a student's name, you also need to update the student's major, even though
the major has not changed.

Insertion anomaly: A table that stores employee information, including the


employee's name, employee ID, and department. The employee ID is the primary
key of the table. If you try to insert a new employee record without specifying the
employee's department, you will not be able to insert the record.

Delete anomaly: A table that stores order information, including the order ID,
customer ID, and order date. The order ID is the primary key of the table. If you
delete an order record, you will also lose the customer ID and order date for that
order.

2. Consider a relation with the schema: sales(seller,producer,product,amount) The following is a legal


instance of Sales

Which of the following potential FDs do not hold, based on the instance above?

i) amount → product
ii) amount → product seller
iii) product → producer
iv) producer → product
v) seller product → amount

Answer: producer → product

3. Circle the functional dependencies that seem to apply to Z


a. E D b. D E c. C A d. E B
e. E A f. B C g. B D h. B A
Answer: A, B, C and H
4. Explain what are the following normalization levels giving examples of how
each are violated:
a. 0NF - A table is in 0NF if it does not contain any normalization at all. This
means that the table can contain repeating groups, redundant data, and anomalies.
Example of Violation:
Consider a table that stores student information, including the student's name,
student ID, course information (course name, instructor name, and grade), and
address information (street address, city, state, and zip code). This table is not in
0NF because it contains repeating groups (course information and address
information) and redundant data (student name and student ID are repeated in the
course information and address information).

b. 1NF - Definition: A table is in 1NF if each cell in the table contains a single
value, and each column has a unique name.
Example of Violation:
Consider a table that stores student information, including the student's name,
student ID, course information (course name, instructor name, grade), and address
information (street address, city, state, and zip code). This table is not in 1NF
because the course information and address information are repeating groups. To
normalize this table, you would create separate tables for course information and
address information.

c. 2NF - A table is in 2NF if it is in 1NF and all non-key attributes are fully
dependent on the primary key.

Example of Violation:
Consider a table that stores employee information, including the employee ID,
employee name, department ID, department name, and manager ID. This table is in
1NF but not in 2NF because the department name and manager ID are not fully
dependent on the primary key (employee ID). To normalize this table, you would
create a separate table for department information and link it to the employee table
using the department ID.

d. 3NF - A table is in 3NF if it is in 2NF and no non-key attribute is transitively


dependent on the primary key.
Example of Violation:
Consider a table that stores student information, including the student ID, student
name, course ID, course name, department ID, department name, and instructor ID.
This table is in 2NF but not in 3NF because the instructor ID is transitively
dependent on the primary key (student ID). To normalize this table, you would
create a separate table for instructor information and link it to the course table
using the instructor ID.

6. The following dependency diagram below shows a number of dependencies.


Identify each dependency (partial, transitive and functional) and discuss their
implications.

Answer: Here is an analysis of the dependency diagram in the image you sent:

*Partial Dependencies*

* A1 → A2
* A1 → A3
A partial dependency is a functional dependency where the determinant is a subset
of the primary key. In this case, the primary key is A1, but A2 and A3 are only
functionally dependent on A1. This means that there could be multiple rows with
the same value for A1 but different values for A2 and A3. This can lead to data
redundancy and anomalies.
*Transitive Dependencies*
* A1 → A3 → A4
* A1 → A5 → A4
A transitive dependency is a functional dependency where the dependent attribute
is functionally dependent on an attribute that is not part of the primary key. In this
case, A3 and A5 are functionally dependent on A4, but A4 is not part of the
primary key. This means that we can infer the value of A4 from the value of A1,
even though A4 is not explicitly stored in the table. This can also lead to data
redundancy and anomalies.

*Functional Dependencies*
* A1 → A2, A3
* A1 → A5
A functional dependency is a relationship between two or more attributes in a
database table where the value of one attribute (or set of attributes) determines the
value of another attribute. In this case, the primary key, A1, determines the values
of all the other attributes in the table.

*Implications*
The partial and transitive dependencies in this dependency diagram indicate that
the table is not in third normal form (3NF). To normalize the table to 3NF, we
would need to split it into two or more tables, each with its own primary key.

* Partial dependencies: A1 → A2, A1 → A3


* Transitive dependencies: A1 → A3 → A4, A1 → A5 → A4
* Functional dependencies: A1 → A2, A3, A1 → A5
The partial and transitive dependencies indicate that the table is not in 3NF. To
normalize the table to 3NF, we would need to split it into two or more tables, each
with its own primary key.

7. State the normal form of the following and determine how you would get it to 4 th
Normal Form
i) Customer (customer_id, name, dob, emails)
ii) Purchase(date, product_id, customer_id, qty, product_price, name, email)
FD: customer_id name, email
FD: product_id product_price
iii) Building (building_code, location, description)
FD: building_code - > location, description
Room (room_number, building_code, room_type, rental_cost)
FD: room_number -> building_code
FD: room_type -> rental_cost

Answer: The normal forms of the given relations are as follows:

i) Customer (customer_id, name, dob, emails): This relation is in 1st Normal Form
(1NF) as it appears to have atomic values for each attribute. To get it to 4th Normal
Form (4NF), we need to ensure that there are no multi-valued dependencies. If
‘emails’ is a multi-valued attribute (a customer can have multiple emails), we should
break it into a separate relation to achieve 4NF.

ii) Purchase(date, product_id, customer_id, qty, product_price, name, email):


This relation is not in 1st Normal Form (1NF) because ‘name’ and ‘email’ are
dependent on ‘customer_id’, not on the whole key (‘date’, ‘product_id’,
‘customer_id’). To get it to 4th Normal Form (4NF), we need to remove partial and
transitive dependencies (to achieve 2NF and 3NF), and then remove any multi-valued
dependencies.
iii) Building (building_code, location, description) and Room (room_number,
building_code, room_type, rental_cost): These relations are in 1st Normal Form
(1NF). To get them to 4th Normal Form (4NF), we need to ensure there are no
multi-valued dependencies. If ‘room_type’ in the Room relation is a multi-valued
attribute (a room can have multiple types), we should break it into a separate relation
to achieve 4NF.

You might also like