0% found this document useful (0 votes)
29 views

Database Case Study - Long

Course/Program: DBMS (Database Management System) Topic: Database Case Study - Long Question Topic Explain in Simple Format

Uploaded by

ok not
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Database Case Study - Long

Course/Program: DBMS (Database Management System) Topic: Database Case Study - Long Question Topic Explain in Simple Format

Uploaded by

ok not
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Certainly!

A "Database Creation Case Study" typically involves a practical scenario where you, as a database designer
or administrator, need to create a database to address specific business requirements. Let's go through a sample case
study to illustrate the process of creating a database:

Case Study: Online Bookstore Database

Background:

You are tasked with creating a database for an online bookstore. The bookstore sells various books, manages
customer information, processes orders, and tracks inventory.

Requirements:

1. Store book information, including ISBN, title, author, genre, and price.

2. Manage customer details, including name, address, email, and phone number.

3. Track orders, including order number, customer ID, book details, order date, and quantity.

4. Monitor inventory, including book quantity in stock.

5. Ensure data consistency, integrity, and security.

Database Design Steps:

1. Define the Tables:

- Books Table:

- ISBN (Primary Key)

- Title

- Author

- Genre

- Price

- Customers Table:

- CustomerID (Primary Key)

- Name

- Address

- Email

- Phone

- Orders Table:

- OrderNumber (Primary Key)

- CustomerID (Foreign Key referencing Customers)

- ISBN (Foreign Key referencing Books)

- OrderDate
- Quantity

- Inventory Table:

- ISBN (Primary Key, Foreign Key referencing Books)

- QuantityInStock

2. Establish Relationships:

- Books-Customers Relationship: One-to-Many (One book can be bought by multiple customers).

- Books-Orders Relationship: One-to-Many (One book can be in multiple orders).

- Customers-Orders Relationship: One-to-Many (One customer can place multiple orders).

- Books-Inventory Relationship: One-to-One (Each book has a unique entry in the inventory table).

3. Create the Database Schema:

Using SQL statements, create the tables and establish the relationships.

SQL Code:

CREATE TABLE Books (

ISBN VARCHAR(13) PRIMARY KEY,

Title VARCHAR(255),

Author VARCHAR(255),

Genre VARCHAR(50),

Price DECIMAL(10, 2)

);

CREATE TABLE Customers (

CustomerID INT PRIMARY KEY,

Name VARCHAR(100),

Address VARCHAR(255),

Email VARCHAR(100),

Phone VARCHAR(15)

);

CREATE TABLE Orders (

OrderNumber INT PRIMARY KEY,

CustomerID INT,
ISBN VARCHAR(13),

OrderDate DATE,

Quantity INT,

FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),

FOREIGN KEY (ISBN) REFERENCES Books(ISBN)

);

CREATE TABLE Inventory (

ISBN VARCHAR(13) PRIMARY KEY,

QuantityInStock INT,

FOREIGN KEY (ISBN) REFERENCES Books(ISBN)

);

```

4. Implement Data Integrity and Security:

Set up constraints, such as foreign key relationships and unique constraints, to maintain data integrity. Implement
access controls to ensure security.

5. Populate the Database:

Insert initial data into the tables to simulate real-world scenarios.

SQL Code:

INSERT INTO Books (ISBN, Title, Author, Genre, Price) VALUES ('978-3-16-148410-0', 'Database Management
Essentials', 'John Smith', 'Technology', 29.99);

INSERT INTO Customers (CustomerID, Name, Address, Email, Phone) VALUES (1, 'Alice Johnson', '123 Main St,
Cityville', '[email protected]', '123-456-7890');

-- Similar INSERT statements for Orders and Inventory tables.

```

6. Test the Database:

Run sample queries to ensure the database functions correctly. Test scenarios such as placing orders, updating
inventory, and retrieving customer details.

By following these steps, you have created a database tailored to the specific requirements of the online bookstore.
This case study demonstrates the practical application of database design principles and SQL commands to create a
functional and efficient database system.

You might also like