Assignment Solution

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

Student Name:

Student ID:
1 (20 points) you want to create a database for computer lab management.
You want to keep track of the following information:

The information about computer/workstation such as station ID, model, etc.

The information about the software installed. Each computer station has various types of
software (e.g., word processor, spreadsheet, database, diagramming tools, etc.) Note you only
care about the types, version and vendors of the software, not the licensing information of each
piece of software. You just want to know which type of the software is used most frequently.

The information about projects that are running on some computer station. Including the project
ID, description, project leader and starting date, etc.

The information about users who are the employees currently working some projects. Including
employee’s ID and name, as well as job title.

The information about appointments made by users to use the lab. A user needs to make an
appointment to use a workstation. For an appointment, employee need to indicate (or assigned) a
station ID, indicating types of software to use, and the time period of using the station.

Note:   In each appointment, an employee can only indicate one computer with multiple software
to use.

a. Design an E/R diagram to model above situation.   

b. Convert the data model in (a) into tables, clearly indicate the keys and foreign keys
Answer:
Create ERD using given case

Part a:

Relational schema
Part b:

Create table:

With SQL:

Table 1:

Computer Station

Table attributes:

Computer station ( Station_ID PK ,Model )

Table Name : Computer station

Station_ID Model

Table 2:

Employee

Table attributes:
Employee ( Employee_ID INT PK , Employee Name VARCHAR , job tittle VATCHAR )

Table 3:

Project

SQL

Software ( word_processing varchar , spread_sheet varchar , data_base varchar ,


Diagrammming tool varchar , station_ID FK, Employee_ID FK )

Table 4:

Appointment

Appointment ( Station_ID FK INT , Employee_ID FK INT )

Table Project:

Project ( Project_ID INT PK , Project leader VARCHAR , starting date DATE)


2. (15 points) given a table used by a gallery to keep track all transactions (customer buy and
sell artists’ works from/to the gallery) Assuming the given data shows all possible FDs.)

artist artist Artwor Artwork Trans- Pric Custom Custom Custom Trans Agent
ID Name k-Title ID Type e er - er- er- -Date name
Numbe Name Locatio
r n

1 John A-Boy 1 Buy- 600 1 Stacy LA 1/2/2 Smith


from 0

1 John A-Boy 1 Sell-to 700 2 Chen LA 1/5/2 Mary


1

2 Roman Farmer 2 Buy- 100 2 Chen LA 1/2/2 Mary


s from 0

3 Shaw A-face 3 Buy- 100 3 Joy NY 1/2/2 Mary


from 0

3 Shaw XYZ 4 Sell-to 200 1 Stacy LA 1/2/2 Smith


0

3 Shaw No- 5 Sell-to 200 3 Joy NY 2/1/2 Smith


title 0

4 Peter No- 6 Buy- 240 4 Joy NY 2/1/2 Joe


title from 1

5  Kim No- 7  Sell-to  220 4  Joy NY  2/1/ Smith


title 21

 
Note: each artist has an agent who handles the transactions of his/her art pieces. But artist may
change their agent periodically. Customers can buy/sell a piece of art from/to the gallery. Type
your answer

a. Carefully exam the data shown in this table to list all FDs. 
b. If you want to create above table in a database, what is the primary KEY for this
table? Namely, what combination of attributes can provide the value to uniquely
identify a transaction record? Note this table is very bad design.
c. What normal form this table is in? Why?

d. How many “themes” (i.e., pieces of information) that are implied by above table?
State each “theme”.

e. Describe one modification anomaly this table has.

f. Normalize above table. In the normalization result you must show the table name and
the key, and FK if there is any.
Answer:
Normalize table

New table artist

Liberalization is a physical database technique which also eliminates downfalls such as Insertion,
Update, and Deletion Anomalies. Stabilization rules divide larger tables into smaller tables and
use relationships to connect them. The goal of SQL homogenization is to remove redundant
(repetitive) data and ensure that data is stored logically.

The inventor of the conceptual data Edgar Codd put forward the idea of normalization of data
with the intro of the First Relational Model, and he persisted to enlarge theory with Second and
Third Fourth Column. Subsequently, he collaborated with Raymond F. Boyce to establish the
Boyce-Codd Normal Form theory.

Why we use it:

This enhances the precision and quality of your data all the while making your database more
navigable. Simply said, data normalization guarantees that business data looks, reads, and can be
employed consistently across all the records in your customer information.

As a Database Management system, you usually operate with massive volumes of data contained
in various tables inside databases. If the info is not appropriately collected, it might be
challenging to find. We may use Convergence to fix that issue by arranging the database in
various ways. Through examples, this piece can assist you comprehend the notion of DBMS
normality.

We'll talk about the attribute values that can exist in a table and the anomalies that can develop as
a result of these functional dependencies. For eradicate the aberrations, tables will be translated
back conventional formats.
What is the purpose of Smoothing?

Normalization is the act of clustering into numerous two or more tables in an attempt to
minimize data redundancy and inconsistency. Its goal is to remove data abnormalities.

Data inconsistency is caused by anything that impairs data integrity. As a result, the data may be
valid in one spot but incorrect in another. This can result in untrustworthy and nonsensical data.
It happens across tables when similar data is stored in 2 different rows in various forms.

FD’s attributs:

artistID (PK INT)

artist Name( Varchar (50))

artwork ID , artwork title , customer number , customer name , customer location

Keys attributes:

Artist_ID (PK INT )

artworkID(PK INT)

Customer number (candidate KEY)

Artist ID (FK)

Database anomalies are simply mismatched or missing data produced by limits or defects in a
database. Databases are designed to collect data and sort or show it to the end user in certain
ways. If the database is restricted or contains 'bugs,' entering or removing information, whether
an update or a new record, might cause problems.

Modification or update anomalies are data discrepancies caused by redundancy or incomplete


updating. Update anomalies are issues that arise as a result of data redundancy in a database
table. If no changes are made to all relevant entries, the database will become inconsistent.

Table 1
artist ID artist Name

1 John

2 Roman

3 Shaw

4 Peter

5  Kim

Table 2:

Artwork-Title Artwork ID

A-Boy 1

Farmers 2

A-face 3

XYZ 4

Table 3:

Customer - Customer-Name Customer- Trans-Date Agent name


Number Location

1 Stacy LA 1/2/20 Smith

2 Chen LA 1/5/21 Mary

2 Chen LA 1/2/20 Mary


3 Joy NY 1/2/20 Mary

1 Stacy LA 1/2/20 Smith

3 Joy NY 2/1/20 Smith

4 Joy NY 2/1/21 Joe

4  Joy NY  2/1/21 Smith


3. (15 points) given the sheet of Order Record

Ord Custo Shippi Shippi Order Produ Prod Quant Disco


er Cumbe mer ng ng date cts uct ity of unt
No red Name Type Charg M/D/Y Name Unit Produ rate
e Price ct
246 XYZ Dan 12/20/20 A $12 40 10%
21. B $34 50 10%
Expre 12 C $12 30 0%
ss
298 ABC Sam 11/2/202 A $12 30 5%
Regul 8 0 B $34 60 5%
ar
341 ABC Sam 3/5/2022 A $12 40 0%
Groun 5 D $45 80 5%
d
519 ASD Larry 4/20/201 A $12 20
Expre 12 9 0%
ss

Answer the following questions, assuming all FDs are implied by given data. Note the
shipping charge depends on type of shipping. The products’ discount rates depend on quantities
and the Month when an order is placed.
a. List FD and multivalued dependencies (MVD), if there is any.
b. If a table include all columns of above sheet, what is the Key of this table?
c. What Normal Form this table is in? Why?
d. Normalize above table into a set of tables.
Answer:
List of attributes
But first of all we do normalize the table and first step is rearranged double single cell values

Ord Custo Shippi Shippi Order Produ Prod Quant Disco


er Cumbe mer ng ng date cts uct ity of unt
No red Name Type Charg M/D/Y Name Unit Produ rate
e Price ct
246 XYZ Dan 12/20/20 A $12 40 10%
21. B $34 50 10%
Expre 12 C $12 30 0%
ss
298 ABC Sam 11/2/202 A $12 30 5%
Regul 8 0 B $34 60 5%
ar
341 ABC Sam 3/5/2022 A $12 40 0%
Groun 5 D $45 80 5%
d
519 ASD Larry 4/20/201 A $12 20
Expre 12 9 0%
ss

Normalization of this table


Liberalization is a physical database technique which also eliminates downfalls such as Insertion,
Update, and Deletion Anomalies. Stabilization rules divide larger tables into smaller tables and
use relationships to connect them. The goal of SQL homogenization is to remove redundant
(repetitive) data and ensure that data is stored logically.
The inventor of the conceptual data Edgar Codd put forward the idea of normalization of data
with the intro of the First Relational Model, and he persisted to enlarge theory with Second and
Third Fourth Column. Subsequently, he collaborated with Raymond F. Boyce to establish the
Boyce-Codd Normal Form theory.
What is the purpose of Smoothing?
Normalization is the act of clustering into numerous two or more tables in an attempt to
minimize data redundancy and inconsistency. Its goal is to remove data abnormalities.

Data inconsistency is caused by anything that impairs data integrity. As a result, the data may be
valid in one spot but incorrect in another. This can result in untrustworthy and nonsensical data.
It happens across tables when similar data is stored in 2 different rows in various forms.

Functional dependency
Functional dependence ensures that the same data does not appear again throughout a database or
network of databases. Preserve data quality and integrity. Because functional dependence factors
frequently result in a more effective and less redundant system, the quality and integrity of your
data are often greater.
The Advantages of Data Normalization

 Reduces the amount of duplicated data.


 Data consistency inside the database is provided.
 A more adaptable database design.
 Increased database security.
 Improved and faster execution.
 Improved database structure in general.

FD’s attributes:
Order no, customer ID, customer Name, products name, products unit price, quantity of product
Table 1
Ord Custo Shippi Shippi Order Produ Prod Quant Disco
er Cutome mer ng ng date cts uct ity of unt
No rID Name Type Charg M/D/Y Name Unit Produ rate
e Price ct
246 XYZ Dan 12/20/20 A $12 40 10%
21.
Expre 12
ss
246 XYZ Dan 12/20/20
21. B $34 50 10%
Expre 12
ss
246 XYZ Dan 12/20/20 C $12 30 0%
21.
Expre 12
ss
298 ABC Sam 11/2/202 A $12 30 5%
Regul 8 0
ar
298 ABC Sam 11/2/202
Regul 8 0 B $34 60 5%
ar
341 ABC Sam 3/5/2022 A $12 40 0%
Groun 5
d
341 ABC Sam 3/5/2022
Groun 5 D $45 80 5%
d
519 ASD Larry 4/20/201 A $12 20
Expre 12 9 0%
ss

Key attributes

Order no (INT PK)


Product unit price (INT PK)
Product Name (Candidate key)
Table 2:
Order Custome Shippin Shippin Order date
No CutomerI r g g M/D/Y
D Name Type Charge
246 XYZ Dan 12/20/2021
.
Express 12
298 ABC Sam 11/2/2020
Regular 8
341 ABC Sam 3/5/2022
Ground 5
519 ASD Larry 4/20/2019
Express 12

Table 3:
Products Product Quantity of Discount rate
Name Unit Price Product
A $12 40 10%

B $34 50 5%

C $12 30 0%

A $12 30
0%
B $34 60 10%

A $12 40 5%
D $45 80 0%
A $12 20
0%
Products Product
Name Unit Price
A $12

B $34

C $12

D $45

4. (10 points) A law firm proposed the following table to keep track the information about cases
and the lawyers who handle the cases:

CASE (caseNumber, caseDescription, lawyerInCharge, caseAssistant, beginningdate,


endingDate, lawyerRate, accumulatedHours, clientsName., clientPhone, clientAdress,
clientType, laywerPhone, caseResultDescription, clientCurrentPayment, paymentMethod, salary,
bonus)

Among above attributes,

CaseNumber, is the ID of the case

LawyerInCharge is the name of the lawyer (a single person) who is in charge of the case.

NOTE: There may be also several staffs in the firm serve as the caseAssistant working for one
LawyerInCharge in a case

BeginningDate, ending, Date indicate the period of the case

LawyerRate, is the lawyer’s hourly payrate for the case.

accumulatedHours is the total hours of the client service for a case,  

clientType can be either individual or cooporate,

laywerPhone is the phone number of the lawyerInCharge,


caseResultDescription gives the description about the case result.

clientCurrentPayment shows the total payment from a client currently

paymentMethod can be credit card, cash or check, payment method cannot be changed once a
case is on file.

salary and bonus are paid to the lawyerInCharge. Bonus depends on the case, salary is not.

Answer the following questions carefully

a. List Function Dependencies based on above information. Also list the multivalued-
dependency given by above narrative.
b. What is the KEY for table Case? (hint: the caseID cannot be the key for above table
because knowing the caseID only cannot identify the values of some other attributes in
this table uniquely.)
c. What normal form the table CASE is in? Why? Give a clear explanation.
d. Normalize this table. Show your result.

Answer:

Create table

Key attributes

Case_ID (INT PK)

CREATE TABLE `computer
lab`.`case` (`casenumber` INT(50) NOT NULL , `casedescription` VA
RCHAR(100) NOT NULL , `lawyerincharge` VARCHAR(50) NOT NULL , `ca
seAssitent` VARCHAR(50) NOT NULL , `beginningdate` DATE NOT NULL 
, `endingdate` DATE NOT NULL , `lawyerrate` INT(50) NOT NULL , `a
ccumulateedhours` INT(50) NOT NULL , `clientname` VARCHAR(50) NOT 
NULL , `clientphone` VARCHAR(100) NOT NULL , `clientAdress` VARCH
AR(100) NOT NULL , `clienttype` VARCHAR(50) NOT NULL , `lawyerpho
ne` VARCHAR(50) NOT NULL , `caseresultdescription` VARCHAR(100) N
OT NULL , `clientcurrentpayment` INT(50) NOT NULL , `paymentmetho
d` VARCHAR(50) NOT NULL , `salary` INT(50) NOT NULL , `bouns` INT
(50) NOT NULL , PRIMARY KEY (`casenumber`)) ENGINE = InnoDB;

The act of structuring data into tables in such a manner that the outcomes of utilising the
database are always clear and as intended is known as database normalisation. This type of
normalisation is inherent in relational database theory. It has the potential to duplicate data inside
the database and frequently leads in the development of new tables.

Database normalisation is widely credited to E.F. Codd, an IBM researcher who presented a
paper explaining the relational database paradigm in 1970. What Codd referred to as "a normal
form for database relations" was a critical component of the relational method. Such data
normalisation found an eager audience in the 1970s and 1980s, when disc drives were relatively
expensive and a very efficient source of data storage.

Data normalization guidelines

While data normalization procedures increase data duplication, they do not introduce data
redundancy, or unneeded duplication. Following the initial exercise of selecting the data items
that should be in the relational database, establishing their relationships, and defining the rows
and columns inside each table, database normalization is often a refining process.

Database normalisation is a procedure that should be completed for each database that you
construct. Normal Forms refers to the act of taking a database design and applying a set of
formal criteria and rules to it.

The database normalisation procedure is further classified as follows:

The First Normal Form (1 NF)

Second Standard Form (2 NF)


Third Standard Form (3 NF)

Fourth Normal Form or Boyce Codd Normal Form ( BCNF or 4 NF)

Fifth Standard Form (5 NF)

Normal Form Sixth (6 NF)

The rows are not arranged in any particular sequence.

The columns are not sorted.

There is data duplication.

Row-and-column intersections are always unique.

There are no hidden values in any of the columns.

If all of an entity's properties are dependent on the whole primary key, it is in a second normal
form. As a result, the values in the various columns are dependent on the values in the other
columns.

The table must already be in 1 NF, and all non-key columns must be dependent on the
PRIMARY KEY.

The partial dependencies are eliminated and relocated to a new table.

You might also like