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

Name

The document outlines SQL commands for creating and managing a database with three tables: Customers, Shippings, and Orders. It includes commands for inserting data, updating customer information, and querying specific records based on criteria. Additionally, it demonstrates the use of foreign keys to maintain data integrity between the tables.
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)
3 views

Name

The document outlines SQL commands for creating and managing a database with three tables: Customers, Shippings, and Orders. It includes commands for inserting data, updating customer information, and querying specific records based on criteria. Additionally, it demonstrates the use of foreign keys to maintain data integrity between the tables.
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/ 5

Name:ghada mohamed mostafa

ID:200047779

PRAGMA foreign_keys = OFF;

DROP TABLE IF EXISTS Customers;

DROP TABLE IF EXISTS Shippings;

DROP TABLE IF EXISTS Orders;

CREATE TABLE Customers (

CustomerID VARCHAR(20) PRIMARY KEY,

Name VARCHAR(50),

Nationality VARCHAR(50),

Zip INT,

Age INT,

Email VARCHAR(100)

);

CREATE TABLE Shippings (

ShippingID INTEGER PRIMARY KEY,

CustomerID VARCHAR(20),

ShippingAddress TEXT,

FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID) ON DELETE CASCADE

);

CREATE TABLE Orders (


OrderID INTEGER PRIMARY KEY,

CustomerID VARCHAR(20),

OrderDate TEXT,

TotalAmount REAL,

FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID) ON DELETE CASCADE

);

INSERT INTO Customers (CustomerID, Name, Nationality, Zip, Age, Email)

VALUES

('MOR9117', 'James', 'Egyptian', 98310, 18, 'jmorgan@cti.net'),

('PCI3760', 'Kate', 'Palestinian', 64085, 20, 'picadilly@monet.com'),

('BEL2456', 'Rex', 'Libyan', 59701, 30, 'rexbell@iyxz.com');

INSERT INTO Shippings (CustomerID, ShippingAddress)

VALUES

('MOR9117', '123 Nile St, Cairo'),

('PCI3760', '45 Gaza Blvd, Palestine'),

('BEL2456', '89 Tripoli Rd, Libya');

INSERT INTO Orders (CustomerID, OrderDate, TotalAmount)

VALUES

('MOR9117', '2025-04-01', 120.50),

('PCI3760', '2025-04-02', 75.00),

('BEL2456', '2025-04-03', 200.25);

SELECT * FROM Customers;

SELECT * FROM Shippings;


SELECT * FROM Orders;

UPDATE Customers

SET Zip = 56785

WHERE Name = 'James';

SELECT * FROM Customers;

SELECT Name, CustomerID

FROM Customers

WHERE Nationality = 'Egyptian';

SELECT *

FROM Customers

WHERE Age < 20;

DELETE FROM Customers;

PRAGMA foreign_keys = ON;

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