-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.sql
103 lines (87 loc) · 3.71 KB
/
schema.sql
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
CREATE TABLE `admin` (
`UserID` int NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`role` varchar(40) DEFAULT 'admin',
`SNo` int NOT NULL,
PRIMARY KEY (`UserID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `allotment` (
`AllotmentID` int NOT NULL AUTO_INCREMENT,
`VehicleID` int NOT NULL,
`SNo` int NOT NULL,
`username` varchar(100) NOT NULL,
`date` date NOT NULL,
`TimeFrom` time NOT NULL,
`TimeTo` time NOT NULL,
`duration` varchar(30) NOT NULL,
`name` varchar(50) NOT NULL,
`contact` bigint NOT NULL,
`TotalPrice` int NOT NULL,
`mode` varchar(40) NOT NULL,
`VehicleType` varchar(40) NOT NULL,
`VehicleNumber` varchar(40) NOT NULL,
PRIMARY KEY (`AllotmentID`),
KEY `fk_sno` (`SNo`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `bookingslot` (
`BSlotID` int NOT NULL AUTO_INCREMENT,
`Date` date DEFAULT NULL,
`TimeFrom` time DEFAULT NULL,
`TimeTo` time DEFAULT NULL,
`duration` varchar(30) DEFAULT NULL,
`SNo` int NOT NULL DEFAULT '1',
`VehicleID` int NOT NULL,
PRIMARY KEY (`BSlotID`),
CONSTRAINT `bookingslot_ibfk_1` FOREIGN KEY (`BSlotID`) REFERENCES `slots` (`SlotID`),
CONSTRAINT `bookingslot_ibfk_2` FOREIGN KEY (`BSlotID`) REFERENCES `vehicle` (`VehicleID`),
CONSTRAINT `bookingslot_ibfk_3` FOREIGN KEY (`BSlotID`) REFERENCES `user` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `owner` (
`OwnerID` int NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`address` varchar(100) DEFAULT NULL,
`contact` bigint DEFAULT NULL,
`SNo` int NOT NULL DEFAULT '0',
PRIMARY KEY (`OwnerID`),
CONSTRAINT `owner_ibfk_1` FOREIGN KEY (`OwnerID`) REFERENCES `user` (`UserID`)
) ENGINE=InnoDB AUTO_INCREMENT=220 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `payment` (
`PaymentID` int NOT NULL AUTO_INCREMENT,
`TotalPrice` int DEFAULT NULL,
`mode` varchar(30) DEFAULT NULL,
`SNo` int NOT NULL,
`VehicleID` int NOT NULL,
PRIMARY KEY (`PaymentID`),
CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`PaymentID`) REFERENCES `user` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `payment_ibfk_2` FOREIGN KEY (`PaymentID`) REFERENCES `bookingslot` (`BSlotID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `sensor` (
`SensorID` int NOT NULL AUTO_INCREMENT,
`isParked` tinyint DEFAULT NULL,
PRIMARY KEY (`SensorID`),
CONSTRAINT `sensor_ibfk_1` FOREIGN KEY (`SensorID`) REFERENCES `slots` (`SlotID`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `slots` (
`SlotID` int NOT NULL AUTO_INCREMENT,
`space` varchar(30) DEFAULT NULL,
`price` int DEFAULT NULL,
PRIMARY KEY (`SlotID`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `user` (
`UserID` int NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`role` varchar(40) DEFAULT 'user',
`SNo` int NOT NULL DEFAULT '0',
PRIMARY KEY (`UserID`),
UNIQUE KEY `SNo` (`SNo`)
) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `vehicle` (
`VehicleID` int NOT NULL AUTO_INCREMENT,
`VehicleType` varchar(40) DEFAULT NULL,
`VehicleNumber` varchar(40) DEFAULT NULL,
`SNo` int NOT NULL,
`VehicleName` varchar(40) DEFAULT NULL,
PRIMARY KEY (`VehicleID`)
) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci