This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathReCapProjectDB.sql
103 lines (92 loc) · 3.96 KB
/
ReCapProjectDB.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
CREATE TABLE [dbo].[Brands] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Name] NVARCHAR (25) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[Cars] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Name] NVARCHAR (50) NOT NULL,
[BrandId] INT NOT NULL,
[ColorId] INT NOT NULL,
[DailyPrice] DECIMAL (18) NOT NULL,
[ModelYear] SMALLINT NOT NULL,
[Description] NVARCHAR (50) NULL,
[MinFindeksScore] SMALLINT DEFAULT ((0)) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Cars_Brands] FOREIGN KEY ([BrandId]) REFERENCES [dbo].[Brands] ([Id]),
CONSTRAINT [FK_Cars_Colors] FOREIGN KEY ([ColorId]) REFERENCES [dbo].[Colors] ([Id])
);
CREATE TABLE [dbo].[Colors] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Name] NVARCHAR (25) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[Customers] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[UserId] INT NOT NULL,
[CompanyName] NVARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Customers_Users] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([Id])
);
CREATE TABLE [dbo].[Rentals] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[CarId] INT NOT NULL,
[CustomerId] INT NOT NULL,
[RentStartDate] DATETIME NOT NULL,
[RentEndDate] DATETIME NOT NULL,
[ReturnDate] DATETIME NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Rentals_Customers] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customers] ([Id]),
CONSTRAINT [FK_Rentals_Cars] FOREIGN KEY ([CarId]) REFERENCES [dbo].[Cars] ([Id])
);
CREATE TABLE [dbo].[Users] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[FirstName] NVARCHAR (50) NOT NULL,
[LastName] NVARCHAR (50) NOT NULL,
[Email] NVARCHAR (50) NOT NULL,
[PasswordHash] VARBINARY (500) NOT NULL,
[PasswordSalt] VARBINARY (500) NOT NULL,
[Status] BIT NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[CarImages] (
[Id] INT NOT NULL IDENTITY,
[CarId] INT NOT NULL,
[ImagePath] NVARCHAR (MAX) NOT NULL,
[Date] DATETIME NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_CarImages_Cars] FOREIGN KEY ([CarId]) REFERENCES [dbo].[Cars] ([Id])
);
CREATE TABLE [dbo].[OperationClaims] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Name] VARCHAR (250) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[UserOperationClaims] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[UserId] INT NOT NULL,
[OperationClaimId] INT NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_UserOperationClaims_Users] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([Id]),
CONSTRAINT [FK_UserOperationClaims_OperationClaims] FOREIGN KEY ([OperationClaimId]) REFERENCES [dbo].[OperationClaims] ([Id])
);
CREATE TABLE [dbo].[Findeks] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[CustomerId] INT NOT NULL,
[NationalIdentity] NVARCHAR (50) NOT NULL,
[Score] SMALLINT DEFAULT ((0)) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Findeks_Customers] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customers] ([Id])
);
CREATE TABLE [dbo].[CreditCards] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[CustomerId] INT NOT NULL,
[NameSurname] NVARCHAR (100) NOT NULL,
[CardNumber] NVARCHAR (25) NOT NULL,
[ExpMonth] TINYINT NOT NULL,
[ExpYear] TINYINT NOT NULL,
[Cvc] NVARCHAR (3) NOT NULL,
[CardType] NVARCHAR (20) NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_CreditCards_Customers] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customers] ([Id])
);