-
Notifications
You must be signed in to change notification settings - Fork 3
/
Database
38 lines (29 loc) · 1.3 KB
/
Database
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
I created a AWS RDS database and made two tables. One called User which contains UserID, LastName, FirstName, Mail and PrivilegedID, and the second one PrivilegeID and Privilege.
AWS RDS
endpoint connection: database.cwghi2srchfe.eu-west-2.rds.amazonaws.com
port: 3306
user: admin
password: administrator
database name: database
commands used:
CREATE TABLE `database`.`Users` (
`UserID` INT NOT NULL,
`LastName` VARCHAR(45) NULL,
`FirstName` VARCHAR(45) NULL,
`Mail` VARCHAR(255) NULL,
`PrivilegeID` INT NULL,
PRIMARY KEY (`UserID`));
CREATE TABLE `database`.`Privileges` (
`PrivilegeID` INT NOT NULL,
`Privilege` VARCHAR(45) NULL,
PRIMARY KEY (`PrivilegeID`));
INSERT INTO Privileges VALUES (1, 'Admin');
INSERT INTO Privileges VALUES (0, 'User');
24.5.
I added three tables to this database, Bill, BillID and Product. Table Bill has bill_id, company_name, company_address, date, place, product_id, total_price and responsible_person.
Table BillID has only bill_id that I inner joined with bill_id from Bill.
Table Product has product_id, description and price. product_id is inner joined with product_id from Bill.
SELECT Bill.product_id FROM Bill
INNER JOIN Product ON Product.product_id=Bill.product_id;
SELECT Bill.bill_id FROM Bill
INNER JOIN BillID ON BillID.bill_id=Bill.bill_id;