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

Advanced Database Concepts4a-Create Database Business

The document creates a database and tables for a business database including customers, products, orders, and order details tables. It then inserts sample records into each table.
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)
21 views2 pages

Advanced Database Concepts4a-Create Database Business

The document creates a database and tables for a business database including customers, products, orders, and order details tables. It then inserts sample records into each table.
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
You are on page 1/ 2

create database Business

go

use Business
go

CREATE TABLE Customers (


CustomerID INT Identity (1,1) PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100),
PhoneNumber VARCHAR(15)
)

CREATE TABLE Products (


ProductID INT Identity (1,1) PRIMARY KEY,
ProductName VARCHAR(100),
ProductDescription TEXT,
Price DECIMAL(10, 2)
)

CREATE TABLE Orders (


OrderID INT Identity (1,1) PRIMARY KEY,
CustomerID INT,
OrderDate DATE,
TotalAmount DECIMAL(10, 2),
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
)

CREATE TABLE OrderDetails (


OrderDetailID INT Identity (1,1) PRIMARY KEY,
OrderID INT,
ProductID INT,
Quantity INT,
UnitPrice DECIMAL(10, 2),
FOREIGN KEY (OrderID) REFERENCES Orders(OrderID),
FOREIGN KEY (ProductID) REFERENCES Products(ProductID)
)

-- INSERTING RECORDS INTO THE TABLES --

-- Insert Customers
INSERT INTO Customers (FirstName, LastName, Email, PhoneNumber) VALUES
('Nbaba', 'Kallon', 'john.doe@example.com', '123-456-7890'),
('Jane', 'Kamara', 'jane.smith@example.com', '987-654-3210'),
('Alice', 'Johnson', 'alice.johnson@example.com', '555-666-7777'),
('Bob', 'Brown', 'bob.brown@example.com', '222-333-4444'),
('Charlie', 'Davis', 'charlie.davis@example.com', '888-999-0000')

-- Insert Products
INSERT INTO Products (ProductName, ProductDescription, Price) VALUES
('Laptop', 'High performance laptop', 999.99),
('Smartphone', 'Latest model smartphone', 799.99),
('Tablet', '10 inch screen tablet', 499.99),
('Headphones', 'Noise cancelling headphones', 199.99),
('Smartwatch', 'Wearable smart device', 299.99)
-- Insert Orders
INSERT INTO Orders (CustomerID, OrderDate, TotalAmount) VALUES
(1, '2023-06-01', 999.99),
(2, '2023-06-02', 1799.98),
(3, '2023-06-03', 499.99),
(4, '2023-06-04', 399.98),
(5, '2023-06-05', 299.99)

-- Insert OrderDetails
INSERT INTO OrderDetails (OrderID, ProductID, Quantity, UnitPrice) VALUES
(1, 1, 1, 999.99),
(2, 2, 1, 799.99),
(2, 3, 1, 999.99),
(3, 3, 1, 499.99),
(4, 4, 2, 199.99),
(5, 5, 1, 299.99)

select * from Customers


select * from Products
select * from Orders
select * from OrderDetails

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy