text: USE [TheGarage]
  GO
  -------------------------------------------------------------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [VEHICLE_TYPE](
  	[VEHICLE_TYPE_ID] TINYINT NOT NULL,
  	[DESCRIPTION] NVARCHAR(20) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [VEHICLE_TYPE_PK] PRIMARY KEY ([VEHICLE_TYPE_ID]),
      CONSTRAINT [VEHICLE_TYPE_DESCRIPTION_UK] UNIQUE ([DESCRIPTION]),
      CONSTRAINT [VEHICLE_TYPE_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [VEHICLE](
      [VEHICLE_PLATE] NVARCHAR(10) NOT NULL, --PLATE HAS TEN LETTERS MAXIMUM ACCORDING TO RUNT
      [PLATE_CITY] NVARCHAR(100) NOT NULL,
      [VEHICLE_TYPE_ID] TINYINT NOT NULL,
      [BRAND] NVARCHAR(50) NOT NULL,
      [LINE] NVARCHAR(50) NOT NULL,
  	[MODEL] NVARCHAR(4) NOT NULL,
      [COLOR] NVARCHAR(50) NOT NULL,
  	[DESCRIPTION] NVARCHAR(50) NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [VEHICLE_PK] PRIMARY KEY ([VEHICLE_PLATE]),
      CONSTRAINT [VEHICLE_FK--VEHICLE_TYPE_ID] FOREIGN KEY ([VEHICLE_TYPE_ID]) REFERENCES [VEHICLE_TYPE]([VEHICLE_TYPE_ID]),
      CONSTRAINT [VEHICLE_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0) 
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [USER_TYPE](
  	[USER_TYPE_ID] TINYINT NOT NULL,
  	[DESCRIPTION] NVARCHAR(20) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [USER_TYPE_PK] PRIMARY KEY ([USER_TYPE_ID]),
      CONSTRAINT [USER_TYPE_DESCRIPTION_UK] UNIQUE ([DESCRIPTION]),
      CONSTRAINT [USER_TYPE_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [DATA_USER](
      [DATA_USER_ID] NVARCHAR(10) NOT NULL,
      [FIRST_NAME] NVARCHAR(50) NOT NULL,
      [SECOND_NAME] NVARCHAR(50) NULL,
  	[FIRST_SURNAME] NVARCHAR(50) NOT NULL,
  	[SECOND_SURNAME] NVARCHAR(50) NOT NULL,
  	[PASSWORD_HASH] VARBINARY(128) NULL,
      [PASSWORD_SALT] VARBINARY(128) NULL,
  	[EMAIL] NVARCHAR(50) NULL,
      [MOBILE] NVARCHAR(14) NOT NULL,
  	[PROFILE_PICTURE] IMAGE NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      [USER_TYPE_ID] TINYINT NOT NULL,
      CONSTRAINT [DATA_USER_PK] PRIMARY KEY ([DATA_USER_ID]),
      CONSTRAINT [DATA_USER_FK--USER_TYPE] FOREIGN KEY ([USER_TYPE_ID]) REFERENCES [USER_TYPE](USER_TYPE_ID),
      CONSTRAINT [DATA_USER_EMAIL_UK] UNIQUE ([EMAIL]),
      CONSTRAINT [DATA_USER_EMAIL_CK] CHECK([EMAIL] LIKE '%@%.%'),
      CONSTRAINT [DATA_USER_MOBILE_UK] UNIQUE ([MOBILE]),
      CONSTRAINT [DATA_USER_MOBILE_CK] CHECK([MOBILE] LIKE '+%'),
      CONSTRAINT [DATA_USER_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0) 
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [R-DATA_USER-VEHICLE](
      [RELATION_ID] NVARCHAR(10) NOT NULL,
      [DATA_USER_ID] NVARCHAR(10) NOT NULL,
      [VEHICLE_PLATE] NVARCHAR(10) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [R-DATA_USER-VEHICLE_PK] PRIMARY KEY ([RELATION_ID]),
      CONSTRAINT [R-DATA_USER-VEHICLE_FK--DATA_USER] FOREIGN KEY ([DATA_USER_ID]) REFERENCES [DATA_USER]([DATA_USER_ID]),
      CONSTRAINT [R-DATA_USER-VEHICLE_FK--VEHICLE] FOREIGN KEY ([VEHICLE_PLATE]) REFERENCES [VEHICLE]([VEHICLE_PLATE]),
      CONSTRAINT [R-DATA_USER-VEHICLE_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [SLOT_STATUS](
  	[SLOT_STATUS_ID] TINYINT NOT NULL,
  	[DESCRIPTION] NVARCHAR(20) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [SLOT_STATUS_PK] PRIMARY KEY ([SLOT_STATUS_ID]),
      CONSTRAINT [SLOT_STATUS_DESCRIPTION_UK] UNIQUE ([DESCRIPTION]),
      CONSTRAINT [SLOT_STATUS_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [SLOT](
      [SLOT_ID] NVARCHAR(10) NOT NULL,
      [FLOOR] NVARCHAR(10) NOT NULL,
      [LOCATION] NVARCHAR(50) NOT NULL,
  	[SLOT_STATUS_ID] TINYINT NOT NULL,
      CONSTRAINT [SLOT_PK] PRIMARY KEY ([SLOT_ID]),
      CONSTRAINT [SLOT_FK--SLOT_STATUS] FOREIGN KEY ([SLOT_STATUS_ID]) REFERENCES [SLOT_STATUS]([SLOT_STATUS_ID]),
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [RESERVATION_STATUS](
  	[RESERVATION_STATUS_ID] TINYINT NOT NULL,
  	[DESCRIPTION] NVARCHAR(20) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [RESERVATION_STATUS_PK] PRIMARY KEY ([RESERVATION_STATUS_ID]),
      CONSTRAINT [RESERVATION_STATUS_DESCRIPTION_UK] UNIQUE ([DESCRIPTION]),
      CONSTRAINT [RESERVATION_STATUS_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [RESERVATION](
      [RESERVATION_ID] NVARCHAR(10) NOT NULL,
      [DATA_USER_ID] NVARCHAR(10) NOT NULL,
      [VEHICLE_PLATE] NVARCHAR(10) NOT NULL,
      [SLOT_ID] NVARCHAR(10) NOT NULL,
      [START] SMALLDATETIME NOT NULL,
      [END] SMALLDATETIME NULL,
  	[RESERVATION_STATUS_ID] TINYINT NOT NULL,
      CONSTRAINT [RESERVATION_PK] PRIMARY KEY ([RESERVATION_ID]),
      CONSTRAINT [RESERVATION_FK--USER] FOREIGN KEY ([DATA_USER_ID]) REFERENCES [DATA_USER]([DATA_USER_ID]),
      CONSTRAINT [RESERVATION_FK--VEHICLE] FOREIGN KEY ([VEHICLE_PLATE]) REFERENCES [VEHICLE]([VEHICLE_PLATE]),
      CONSTRAINT [RESERVATION_FK--SLOT] FOREIGN KEY ([SLOT_ID]) REFERENCES [SLOT]([SLOT_ID]),
      CONSTRAINT [RESERVATION_FK--RESERVATION_STATUS] FOREIGN KEY ([RESERVATION_STATUS_ID]) REFERENCES [RESERVATION_STATUS]([RESERVATION_STATUS_ID]),
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [INVOICE_STATUS](
  	[INVOICE_STATUS_ID] TINYINT NOT NULL,
  	[DESCRIPTION] NVARCHAR(20) NOT NULL,
      [STATUS] BIT DEFAULT 1 NOT NULL,
      CONSTRAINT [INVOICE_STATUS_PK] PRIMARY KEY ([INVOICE_STATUS_ID]),
      CONSTRAINT [INVOICE_STATUS_DESCRIPTION_UK] UNIQUE ([DESCRIPTION]),
      CONSTRAINT [INVOICE_STATUS_STATUS_CK] CHECK([STATUS] = 1 OR [STATUS] = 0)
  );
  GO
  SET ANSI_PADDING OFF
  GO
  --------------------------------------
  --CHECK_TRUE
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  SET ANSI_PADDING ON
  GO
  CREATE TABLE [INVOICE](
      [INVOICE_ID] NVARCHAR(10) NOT NULL,
      [RESERVATION_ID] NVARCHAR(10) NOT NULL,
      [PRICE] DECIMAL(19,4) NOT NULL,
      [PAID_DATE] SMALLDATETIME NOT NULL,
  	[INVOICE_STATUS_ID] TINYINT NOT NULL,
      CONSTRAINT [INVOICE_PK] PRIMARY KEY ([INVOICE_ID]),
      CONSTRAINT [INVOICE_FK--RESERVATION] FOREIGN KEY ([RESERVATION_ID]) REFERENCES [RESERVATION]([RESERVATION_ID]),
      CONSTRAINT [INVOICE_FK--INVOICE_STATUS] FOREIGN KEY ([INVOICE_STATUS_ID]) REFERENCES [INVOICE_STATUS]([INVOICE_STATUS_ID]),
  );
  GO
  SET ANSI_PADDING OFF
  GO
  