0% found this document useful (0 votes)
4 views4 pages

PostgreSQL Database Assignment

The document outlines the creation of a PostgreSQL database named 'my_database' along with the design of three tables: Customers, Products, and Orders. It includes the structure of each table, sample data for customers and products, and SQL insert statements to populate these tables. The Orders table links customers to products with details on quantity and order date.

Uploaded by

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

PostgreSQL Database Assignment

The document outlines the creation of a PostgreSQL database named 'my_database' along with the design of three tables: Customers, Products, and Orders. It includes the structure of each table, sample data for customers and products, and SQL insert statements to populate these tables. The Orders table links customers to products with details on quantity and order date.

Uploaded by

James Kariuki
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PostgreSQL Database Assignment

1. Database Creation
CREATE DATABASE my_database;
2. 2. Table Design
Customers Table

customer_i name email city


d

1 Alice alice@[Link] Nairobi


Mwangi

2 John john@[Link] Mombasa


Ochieng

3 Grace grace@[Link] Kisumu


Wambui

4 Peter peter@[Link] Nakuru


Otieno

5 Samuel samuel@[Link] Eldoret


Kariuki m

6 Linda linda@[Link] Nairobi


Njeri

7 Brian brian@[Link] Kisumu


Mwenda

8 Faith faith@[Link] Mombasa


Achieng

9 James james@[Link] Nakuru


Mutua

10 Mary mary@[Link] Eldoret


Wanjiku
3. Products Table

product_id product_name price

1 Laptop 1200.00

2 Smartphone 700.00

3 Tablet 350.00

4 Printer 200.00

5 Monitor 300.00

6 Keyboard 50.00

7 Mouse 30.00

8 Headphones 80.00

9 Router 150.00

10 Webcam 100.00

4. Orders Table

order_id customer_id product_id quantity order_date

1 1 1 1 2026-02-10

2 2 2 2 2026-02-11

3 3 3 1 2026-02-12

4 4 4 3 2026-02-13

5 5 5 1 2026-02-14

6 6 6 2 2026-02-15

7 7 7 1 2026-02-16

8 8 8 1 2026-02-17

9 9 9 2 2026-02-18

10 10 10 1 2026-02-19
5. SQL Insert Statements
-- Customers
INSERT INTO customers (name, email, city) VALUES
('Alice Mwangi','alice@[Link]','Nairobi'),
('John Ochieng','john@[Link]','Mombasa'),
('Grace Wambui','grace@[Link]','Kisumu'),
('Peter Otieno','peter@[Link]','Nakuru'),
('Samuel Kariuki','samuel@[Link]','Eldoret'),
('Linda Njeri','linda@[Link]','Nairobi'),
('Brian Mwenda','brian@[Link]','Kisumu'),
('Faith Achieng','faith@[Link]','Mombasa'),
('James Mutua','james@[Link]','Nakuru'),
('Mary Wanjiku','mary@[Link]','Eldoret');
-- Products
INSERT INTO products (product_name, price) VALUES
('Laptop',1200.00),
('Smartphone',700.00),
('Tablet',350.00),
('Printer',200.00),
('Monitor',300.00),
('Keyboard',50.00),
('Mouse',30.00),
('Headphones',80.00),
('Router',150.00),
('Webcam',100.00);

-- Orders
INSERT INTO orders (customer_id, product_id, quantity, order_date) VALUES
(1,1,1,'2026-02-10'),
(2,2,2,'2026-02-11'),
(3,3,1,'2026-02-12'),
(4,4,3,'2026-02-13'),
(5,5,1,'2026-02-14'),
(6,6,2,'2026-02-15'),
(7,7,1,'2026-02-16'),
(8,8,1,'2026-02-17'),
(9,9,2,'2026-02-18'),
(10,10,1,'2026-02-19');

You might also like