SQL Database Normalization
Nora's Bagel Bin Database ER Diagram and Normalization
1st Normal Form
fist order

Using the Bagel Order Form Template, a 1st normal form was created for the relation (table) by grouping repeated attributes and maintaining single values in each cell.

2nd Normal Form
second order

After 1NF was completed, 2NF was achieved by making sure all non-key attributes (columns) were functionally dependent on the entire primary key (PK). Two new relations were created (Bagel Order Line Item and Bagel) with their respective non-key attributes to conform to 2NF standards. The Bagel relation contains all attributes that strictly describe bagels and not the order ID, so were separated from the Bagel Order relation. Bagel Quantity is the only attribute that is dependent on the entire composite primary key, so were separated in the Bagel Order Line Item relation. The rest of the attributes are dependent on the Bagel Order ID only, so were left in the original Bagel Order relation.

Cardinality between the Bagel Order entity and Bagel Order Line Item entity can be explained as one order can have many order line items, while each order line item instance can be on only one order (1 to Many). An Order Line Item can only have 1 type of bagel, while each bagel type can appear on multiple line items (Many to One).

3rd Normal Form
third order

Once 2NF is done, 3NF was performed to eliminate transitive dependencies (non-key attributes with dependencies on other non-key attributes). A new attribute (Customer ID) was created as a foreign key in the renamed Bagel Order (Bagel Invoice) and used as a PK in Bagel Customer to tie all customer attributes to the new PK.

Cardinality remained the same for the old relations, but for the new relations a bagel invoice can only have one customer, while a customer can have many invoices (many to one).

Final Physical Database Model
final model

All attributes were renamed to conform to database naming conventions (no spaces) and data types were described for each attribute. Some string (CHAR) and number (Numeric) data types were defined for attributes that are known to have a fixed length.

Jaunty Coffee Co. Database Creation in MySQL

sql tables

All tables were created as specified in the Entity Relationship Diagram (ERD) and added to the jaunty_coffee_co database.

insert rows

Three rows were added to each table with random values.

concat

First and Last name were concatenated with a space into a new column, then added to a view of the EMPLOYEE table.

index

An index named coffee_index was created on the column coffee_name in table COFFEE.

select from where

To demonstrate a SELECT FROM WHERE (SFW) query, an employee full name match with "John Smith" was selected from the EMPLOYEE_FULL_NAME view.

join

Inner join was used on the three tables COFFEE, COFFEE_SHOP, and SUPPLIER to display all attributes from all tables.