0% found this document useful (0 votes)
19 views2 pages

Ass 7

The document outlines various types of databases, including hierarchical, network, relational, object-oriented, document-oriented, and graph databases, with examples for each. For the company FreshBites, PostgreSQL was selected as the database due to its suitability for structured data, ACID compliance, scalability, and open-source nature. The document also provides an SQL script for the database schema, detailing tables for customers, products, orders, and order items.

Uploaded by

kalyk.aselai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Ass 7

The document outlines various types of databases, including hierarchical, network, relational, object-oriented, document-oriented, and graph databases, with examples for each. For the company FreshBites, PostgreSQL was selected as the database due to its suitability for structured data, ACID compliance, scalability, and open-source nature. The document also provides an SQL script for the database schema, detailing tables for customers, products, orders, and order items.

Uploaded by

kalyk.aselai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A database management system (DBMS)

1. Types of Databases and Their Features


Hierarchical Databases
Data is stored in a tree structure (parent-child). Example: IBM IMS.
Network Databases
Data is connected through multiple relationships. Example: IDS.
Relational Databases (RDBMS)
Data is stored in tables (SQL). Examples: MySQL, PostgreSQL.
Object-Oriented Databases
Data is represented as objects. Example: db4o.
Document-Oriented (NoSQL) Databases
Data is stored in JSON format. Example: MongoDB.
Graph Databases
Data is stored as nodes and relationships. Example: Neo4j.

2. Choosing a Database for a Company

Company: FreshBites – an online bakery specializing in high-quality cakes and pastries.


Database Requirements:
- Storage of orders, customers, and suppliers.
- High performance and reliability.
- Scalability for future growth.
- Integration with web and mobile applications.

Selected Database: PostgreSQL

- Relational model is suitable for storing structured business data.


- ACID compliance ensures data integrity and reliability.
- Supports JSON for semi-structured data storage.
- Scalability allows transition to a clustered architecture.
- Open-source and free to use.
Alternative Option: MongoDB – useful for high-speed operations on unstructured data.

3. Conclusion

The selected database, PostgreSQL, meets the company's needs, ensuring efficiency, reliability,
and scalability for business growth.
4. Database Schema

Below is the SQL script for the database schema:

-- Customers Table
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
phone VARCHAR(20) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE,
address TEXT
);

-- Products Table (Cakes and Pastries)


CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL CHECK (price > 0),
stock INT NOT NULL DEFAULT 0 CHECK (stock >= 0)
);

-- Orders Table
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
customer_id INT NOT NULL,
order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status VARCHAR(50) DEFAULT 'New',
total_price DECIMAL(10,2) NOT NULL CHECK (total_price >= 0),
FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE CASCADE
);

-- Order Items Table (What products are in an order)


CREATE TABLE order_items (
id SERIAL PRIMARY KEY,
order_id INT NOT NULL,
product_id INT NOT NULL,
quantity INT NOT NULL CHECK (quantity > 0),
price DECIMAL(10,2) NOT NULL CHECK (price > 0),
FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE,
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE
);

You might also like