attachment_1Data Modeling and Design
Learner’s Name
Capella University
ITEC5020 Application and Database Development
Data Modeling and Design
August 2020
In this example, we will review various source documents related to an order entry system and identify the data fields that should be present in the order entry system. These data fields can be converted to a database format by eliminating redundant data fields.
We will review various source documents such as the “Add Customer” document, “Categories and Product Report” document, “Place Order” document, and “Order Details Report” document.
First, let us analyze the “Add Customer” document. The fields present in the document are as follows:
- First Name
- Last Name
- Address
- City
- State
- Zip
- Phone
- Email
Next, we will consolidate these data fields. We can create a database table called “customer,” which will contain the fields present in the “Add Customer” document. This table should have a primary key that uniquely identifies each row in the table “customer.” Among the fields, first name, last name, address, city, state, or zip cannot be considered as the primary key because two customers might have the same first name, last name, address, city, state, or zip. Phone and email are unique to each customer. However, considering the size of these fields, they should not be declared as primary keys. ITEC 5020 Capella University Data Modeling and Design Paper
To solve the issue of the primary key, each customer can be assigned a unique id. The “customer” table will look something like the following:
id |
first_name |
last_name |
address |
city |
state |
zip |
phone |
email |
1 |
Harry |
Smith |
107 Pega Street |
Los Angeles |
California |
90086 |
357-8076 |
harrysmith@abc.com |
2 |
Kane |
Williams |
897 Harwin Street |
Miami |
Florida |
33120 |
231-9065 |
kanewilliams@abc.com |
Table “customer”
The “customer” table does not contain any redundant data. Hence, this table should not be normalized.
The “id” of a customer will be an integer value. However, we will declare the data type of “id” as “serial.” The advantage of using “serial” data type is that when a new customer is added, his/her “id” will be automatically generated. Suppose there are three customers. When a new customer is added, his/her “id” will be 4. For the rest of the fields, we will declare the data type as “varchar.” The data type “varchar” is used when the size of the data entered in a column is not fixed.
Now, let’s see the data types and size of the fields of “customer” table:
Fields |
Data Type |
Data Size |
id (primary key) |
serial |
4 bytes |
first_name |
varchar |
The field can hold a maximum of 20 characters. |
last_name |
varchar |
The field can hold a maximum of 20 characters. |
address |
varchar |
The field can hold a maximum of 200 characters. |
city |
varchar |
The field can hold a maximum of 50 characters. |
state |
varchar |
The field can hold a maximum of 50 characters. |
zip |
varchar |
The field can hold a maximum of 10 characters. |
phone |
varchar |
The field can hold a maximum of 12 characters. |
email |
varchar |
The field can hold a maximum of 50 characters. |
Next, let us analyze the “Product Report” document. The fields present in the report are as follows:
- category_name
- product_name
We can create the table “product and category” considering the fields present in the “Product and Categories Report” document as follows:
category_name |
product_name |
Bedroom |
Krys solid wood king-size bed, Olivia solid wood queen-size bed |
Dining |
Kelly solid wood dining chair, Imara solid wood dining table |
We can see that one category of furniture can have more than one product. In that case, the table “product and category” has a multi-valued field “product_name.” Hence, this table is not normalized. We will have to convert this table to the first normal form (1NF) so that one field contains a single value. The following table is in 1NF:
category_name |
product_name |
Bedroom |
Krys solid wood king-size bed |
Bedroom |
Olivia solid wood queen-size bed |
Dining |
Kelly solid wood dining chair |
Dining |
Imara solid wood dining table |
The primary key of the “product_and_category” table is a composite key that contains the fields “category_name” and “product_name.” The table also contains redundant data. A database must have a single-column primary key in the second normal form (2NF). Hence, the table “product and category” is not in 2NF. We must split the table into two different tables: “category” and “product.”
Let us assign a unique id to each category that will be the primary key of the table “category.” The “category” table will look something like the following:
id |
category_name |
1 |
Bedroom |
2 |
Dining |
Table “category”
The “category” does not contain any redundant data; hence, it should not be normalized again.
Now, let’s see the data types and size of the fields of “category” table:
Field |
Data Type |
Data Size |
id (primary key) |
serial |
4 bytes |
category_name |
varchar |
The field can hold a maximum of 50 characters. |
We will also assign a unique id to each product that will be the primary key of the table “product.” In the “product” table, “category_key” is a foreign key that references the primary key “id” of the “category table.” The “product” table can also have some extra fields such as “product_description” and “unit_price.” The “product” table will look something like the following:
id |
product_name |
product_description |
unit_price |
category_key |
1 |
Krys solid wood king-size bed |
The dimensions (in inches) of the bed are H 36.5 × W 78 × D 82.5; the color is white; the warranty is 36 months. |
$350 |
1 |
2 |
Olivia solid wood queen-size bed |
The dimensions (in inches) of the bed are H 39.2 × W 65.5 × D 85.5; the color is provincial teak; the warranty is 48 months. |
$275 |
1 |
3 |
Kelly solid wood dining chair |
The dimensions (inches) of the dining chair are H 37 × W 17 × D 18; the color is provincial teak; the warranty is 24 months. |
$40 |
2 |
4 |
Imara solid wood dining table |
The dimensions (in inches) of the dining are H 45 × W 40 × D 30; the color is provincial teak; the warranty is 36 months. |
$300 |
2 |
Table “product”
Now, let’s see the data types and size of the fields of “product” table:
Fields |
Data Type |
Data Size |
id (primary key) |
serial |
4 bytes |
product_name |
varchar |
The field can hold a maximum of 200 characters. |
product_description |
varchar |
The field can hold a maximum of 1,000 characters. |
unit_price |
varchar |
The field can hold a maximum of 10 characters. |
category_key (foreign key) |
int |
4 bytes |
Now, we will analyze the “Place Order” document. The data fields present in the “Place Order” document are “customer_id” and “product_id,” and they are already present in the tables “customer” and “product,” respectively. When the “customer_id” and “product_id” are selected and the “Place Order” button is pressed, a new order will be placed. We will create a table named “order” to store information about the orders. The “order” table will have the following fields: “id,” which will uniquely identify an order; “customer_id,” which is a foreign key that references the primary key of the table “customer;” “order_date;” and “status.” The “order” table will look something like the following:
id |
customer_id |
order_date |
status |
1 |
1 |
2018-02-15 |
Delivered |
2 |
2 |
2018-03-19 |
Pending |
Table “order”
The “order” table does not contain any redundant data. Hence, it should not be normalized.
Now, let’s see the data types and size of the fields of “order” table:
Field |
Data Type |
Data Size |
id (primary key) |
serial |
4 bytes |
customer_id (foreign key) |
int |
4 bytes |
order_date |
date |
3 bytes |
status |
varchar |
The field can hold a maximum of 10 characters. |
Next, we will analyze the “Order Details Report” document. We can create a table “order_details” based on the Order Details Report with the following fields:
- order_id
- order_date
- status
- customer_id
- first_name
- last_name
- address
- city
- state
- zip
- phone
- email
- product_id
- quantity
However, the fields “order_id, “order_date,” and “status” are already present in the “order” table. Similarly, “customer_id,” “first_name,” “last_name,” “address,” “city,” “state,” “zip,” “phone,” and “email” are already present in the “customer” table. Instead of including the fields that are already present in the “order” and the “customer” table, we can include the following fields in the “order details” table.
- order_id, which references the primary key “id” of the table “order”
- product_id, which references the primary key “id” of the table “product”
- quantity
order_id |
product_id |
quantity |
1 |
2 |
3 |
2 |
4 |
2 |
Table “order_detail”
The table “order_detail” does not contain any redundant data; hence, it should not be normalized.
Now, let’s see the data types and size of the fields of “order details” table:
Field |
Data Type |
Data Size |
order_id |
int |
4 bytes |
product_id |
int |
4 bytes |
quantity |
int |
4 bytes |