-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.2 Tables
130 lines (117 loc) · 3.98 KB
/
1.2 Tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use GestionareMagazinPlante
drop table if exists plants
drop table if exists orders
drop table if exists customers
drop table if exists Suppliers
GO
CREATE TABLE Plants (
plantid INT PRIMARY KEY not null,
name VARCHAR(100),
species VARCHAR(100),
origincountry VARCHAR(100),
price DECIMAL(10, 2),
sunlightdemand VARCHAR(100),
size VARCHAR(100),
quantity INT
);
INSERT INTO Plants
(plantid,
name,
species,
origincountry,
price,
sunlightdemand,
size,
quantity)
VALUES
(1, 'Rose', 'Rosa', 'England', 10.99, 'High', 'Medium', 100),
(2, 'Tulip', 'Tulipa', 'Netherlands', 5.99, 'Medium', 'Small', 100),
(3, 'Lavender', 'Lavandula', 'France', 7.99, 'High', 'Small', 100),
(4, 'Sunflower', 'Helianthus', 'United States', 3.99, 'High', 'Large', 100),
(5, 'Orchid', 'Orchidaceae', 'Various', 12.99, 'Medium', 'Small', 100),
(6, 'Fern', 'Polypodiopsida', 'Various', 6.99, 'Medium', 'Medium', 100),
(7, 'Cactus', 'Cactaceae', 'Mexico', 8.99, 'Low', 'Small', 100),
(8, 'Daisy', 'Bellis perennis', 'Europe', 4.99, 'Medium', 'Small', 100),
(9, 'Bamboo', 'Bambusoideae', 'China', 9.99, 'High', 'Large', 100),
(10, 'Palm', 'Arecaceae', 'Tropical regions', 11.99, 'High', 'Large', 100);
CREATE TABLE Customers
(
customerid INT PRIMARY KEY not null,
customername VARCHAR(100),
contactnumber VARCHAR(20),
email VARCHAR(100),
address VARCHAR(200),
country VARCHAR(100),
plantid INT not null,
FOREIGN KEY(plantid) references plants(plantid)
);
INSERT INTO Customers
(customerid,
customername,
contactnumber,
email,
address,
country,
plantid)
VALUES
(1, 'John Smith', '1234567890', '[email protected]', '123 Main St', 'USA', 1),
(2, 'Jane Doe', '2345678901', '[email protected]', '456 Elm St', 'USA', 1),
(3, 'Bob Johnson', '3456789012', '[email protected]', '789 Oak Ave', 'USA', 3),
(4, 'Mary Brown', '4567890123', '[email protected]', '321 Maple Ln', 'USA', 4),
(5, 'Tom Davis', '5678901234', '[email protected]', '654 Pine Dr', 'USA', 5),
(6, 'Samantha Lee', '6789012345', '[email protected]', '987 Cedar Rd', 'USA', 6),
(7, 'David Kim', '7890123456', '[email protected]', '159 Walnut Blvd', 'USA', 7),
(8, 'Michelle Chen', '8901234567', '[email protected]', '357 Birch Rd', 'USA', 8),
(9, 'Eric Liu', '9012345678', '[email protected]', '753 Spruce Dr', 'USA', 9),
(10, 'Jennifer Nguyen', '0123456789', '[email protected]', '246 Willow Ave', 'USA', 10);
CREATE TABLE Orders (
orderid INT PRIMARY KEY,
orderdate DATE,
customerid INT,
plantid INT,
quantity INT,
FOREIGN KEY (customerid) REFERENCES customers (customerid),
FOREIGN KEY (plantid) REFERENCES plants (plantid)
);
INSERT INTO Orders
(orderid,
orderdate,
customerid,
plantid,
quantity)
VALUES
(1, '2022-05-20', 1, 1, 5),
(2, '2022-05-22', 2, 2, 2),
(3, '2022-05-23', 3, 3, 1),
(4, '2022-05-25', 4, 4, 3),
(5, '2022-05-27', 5, 5, 2),
(6, '2022-05-30', 6, 6, 1),
(7, '2022-06-02', 7, 7, 4),
(8, '2022-06-05', 8, 8, 2),
(9, '2022-06-08', 9, 9, 3),
(10, '2022-06-11', 10, 10, 1);
CREATE TABLE Suppliers
(
id INT PRIMARY KEY,
name VARCHAR(100),
number VARCHAR(20),
address VARCHAR(255),
plantid int,
foreign key (plantid) references plants(plantid)
);
INSERT INTO Suppliers
(id,
name,
number,
address)
VALUES
(1, 'Plant Nursery', '1234567890', '456 Elm St'),
(2, 'Your Favourite Plants', '9876543210', '789 Oak St'),
(3, 'Green Thumb Growers', '5551234567', '123 Main St'),
(4, 'Floral Gardens', '4449876543', '321 Pine St'),
(5, 'Botanical Suppliers.', '1112223333', '987 Maple Ave'),
(6, 'Plant Paradise', '9998887777', '654 Cedar Ln'),
(7, 'Nature Paradise', '2223334444', '246 Birch Rd'),
(8, 'Sunshine Viridis', '7778889999', '135 Spruce Dr'),
(9, 'Flower Power', '6665554444', '753 Willow Ave'),
(10, 'Green Obsessed', '3331112222', '369 Oak Ln');