-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathÖrnekVeriTabanıOluşturma.sql
70 lines (56 loc) · 1.37 KB
/
ÖrnekVeriTabanıOluşturma.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
CREATE TABLE Cars(
CarId int PRIMARY KEY IDENTITY(1,1),
BrandId int,
ColorId int,
ModelYear nvarchar(25),
DailyPrice decimal,
Descriptions nvarchar(25),
FOREIGN KEY (ColorId) REFERENCES Colors(ColorId),
FOREIGN KEY (BrandId) REFERENCES Brands(BrandId)
)
CREATE TABLE Colors(
ColorId int PRIMARY KEY IDENTITY(1,1),
ColorName nvarchar(25),
)
CREATE TABLE Brands(
BrandId int PRIMARY KEY IDENTITY(1,1),
BrandName nvarchar(25),
)
CREATE TABLE Users(
UserId int PRIMARY KEY IDENTITY(1,1),
FirstName nvarchar(25),
LastName nvarchar(25),
Email nvarchar(55),
Password nvarchar(35),
)
CREATE TABLE Customers(
CustomerId int PRIMARY KEY IDENTITY(1,1),
UserId int,
CustomerName nvarchar(25),
FOREIGN KEY (UserId) REFERENCES Users(UserId),
)
CREATE TABLE Rentals(
RentalId int PRIMARY KEY IDENTITY(1,1),
CarId int,
CustomerID int,
RentDate datetime,
ReturnDate datetime,
FOREIGN KEY (CarId) REFERENCES Cars(CarId),
FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId),
)
INSERT INTO Cars(BrandId,ColorId,ModelYear,DailyPrice,Descriptions)
VALUES
('1','2','2012','1000','Manual Benzine'),
('1','3','2015','1500','Automatic Diesel'),
('2','1','2017','2000','Automatic Hybrid'),
('3','3','2014','1250','Manual Diesel');
INSERT INTO Colors(ColorName)
VALUES
('White'),
('Black'),
('Blue');
INSERT INTO Brands(BrandName)
VALUES
('Tesla'),
('BMW'),
('Renault');