Bookstore Normalization Solution

Domain: Library Management System

The library management system tracks books, authors, borrowers, and borrow transactions.


Initial Unnormalized Data (UNF):

TransactionIDBorrowerNameBorrowerAddressBorrowedBooksTransactionDate
1Sarah Johnson123 Elm St, NY“Book1:Author1”, “Book2:Author2”2023-12-01

Full Library Management System Sample Data

Unnormalized Data (UNF):

TransactionIDBorrowerNameBorrowerAddressBorrowedBooksTransactionDate
1Sarah Johnson123 Elm St, NYBook1:Author1, Book2:Author22023-12-01
2Mark Spencer456 Pine Rd, CABook3:Author12023-12-02
3Sarah Johnson123 Elm St, NYBook4:Author3, Book5:Author22023-12-03

Goal: Normalize the data to 3NF

1NF: Remove multivalued attributes by creating individual rows for each book in the borrowed books column.

TransactionIDBorrowerNameBorrowerAddressBookTitleAuthorNameTransactionDate
1Sarah Johnson123 Elm St, NYBook1Author12023-12-01
1Sarah Johnson123 Elm St, NYBook2Author22023-12-01
2Mark Spencer456 Pine Rd, CABook3Author12023-12-02
3Sarah Johnson123 Elm St, NYBook4Author32023-12-03
3Sarah Johnson123 Elm St, NYBook5Author22023-12-03
erDiagram
Transaction {
int TransactionID PK
string BorrowerName
string BorrowerAddress
string BookTitle
string AuthorName
string TransactionDate
}

2NF: Eliminate partial dependencies by separating Borrowers, Books, and Transactions into different tables.

Borrower Table:

BorrowerIDBorrowerNameBorrowerAddress
1Sarah Johnson123 Elm St, NY
2Mark Spencer456 Pine Rd, CA

Book Table:

BookIDBookTitleAuthorName
1Book1Author1
2Book2Author2
3Book3Author1
4Book4Author3
5Book5Author2

Transaction Table:

TransactionIDBorrowerIDTransactionDate
112023-12-01
222023-12-02
312023-12-03

TransactionDetails Table:

TransactionDetailIDTransactionIDBookID
111
212
323
434
535
erDiagram
Borrower {
int BorrowerID PK
string BorrowerName
string BorrowerAddress
}

Book {
int BookID PK
string BookTitle
string AuthorName
}

Transaction {
int TransactionID PK
int BorrowerID FK
string TransactionDate
}

TransactionDetails {
int TransactionDetailID PK
int TransactionID FK
int BookID FK
}

3NF: Eliminate transitive dependencies by creating a separate Author table.

Author Table:

AuthorIDAuthorName
1Author1
2Author2
3Author3

Book Table (Updated):

BookIDBookTitleAuthorID
1Book11
2Book22
3Book31
4Book43
5Book52
erDiagram
Borrower {
int BorrowerID PK
string BorrowerName
string BorrowerAddress
}

Author {
int AuthorID PK
string AuthorName
}

Book {
int BookID PK
string BookTitle
int AuthorID FK
}

Transaction {
int TransactionID PK
int BorrowerID FK
string TransactionDate
}

TransactionDetails {
int TransactionDetailID PK
int TransactionID FK
int BookID FK
}

Book ||--o{ Author : "is written by"
Borrower ||--o{ Transaction : "borrows"
Transaction ||--o{ TransactionDetails : "contains"
Book ||--o{ TransactionDetails : "Book"

Summary

The data has been normalized from an unstructured format (UNF) to fully normalized (3NF), ensuring minimal redundancy, integrity, and consistency. This exercise can be applied to any domain requiring structured, relational data storage.

Scroll to Top