Advertisement
LaughingMan

Untitled

Mar 8th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.75 KB | None | 0 0
  1. CREATE TABLE Customer -- You for example
  2. (
  3.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  4.     FirstName               VARCHAR(32)                                             NOT NULL,
  5.     LastName                VARCHAR(32)                                             NOT NULL,
  6.     [Address]               VARCHAR(128)                                            NOT NULL,
  7.     Email                   VARCHAR(32)                                             NOT NULL,
  8.     PhoneNo                 VARCHAR(32)                                             NOT NULL,
  9.     CONSTRAINT PK_Customer PRIMARY KEY (ID ASC)
  10. )
  11.  
  12. CREATE TABLE [Port] -- The port that people can go to
  13. (  
  14.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  15.     [Name]                  VARCHAR(32)                                             NOT NULL, -- The name of the port
  16.     [Location]              VARCHAR(32)                                             NOT NULL, -- Where the port is located
  17.     Capacity                INT                                                     NOT NULL, -- How many Yachts can fit in this port
  18.     CONSTRAINT PK_Port PRIMARY KEY (ID ASC)
  19. )
  20.  
  21. CREATE TABLE Yacht -- The boat that people can get on
  22. (
  23.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  24.     [Name]                  VARCHAR(32)                                             NOT NULL, -- The name of the boat... U.S.S. Minnow!
  25.     Capacity                INT                                                     NOT NULL, -- How many people can fit on the boat
  26.     CONSTRAINT PK_Yacht PRIMARY KEY (ID ASC)
  27. )
  28.  
  29. CREATE TABLE Charter -- When the boat gets to the port and for how many days
  30. (
  31.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  32.     PortID                  INT                                                     NOT NULL, -- Which port they are going to
  33.     YachtID                 INT                                                     NOT NULL, -- Which yacht they are riding on
  34.     ArrivalDate             DATETIME                                                NOT NULL, -- When they arrive
  35.     DurationInDays          INT                                                     NOT NULL, -- How many days they are staying
  36.     CONSTRAINT PK_Customer PRIMARY KEY (ID ASC),
  37.     CONSTRAINT FK_Charter_Port FOREIGN KEY (PortID) REFERENCES [Port] (ID),
  38.     CONSTRAINT FK_Charter_Yacht FOREIGN KEY (YachtID) REFERENCES Yacht (ID),
  39. )
  40.  
  41. CREATE TABLE Booking -- An order placed by a customer for them and/or their family
  42. (
  43.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  44.     CharterID               INT                                                     NOT NULL, -- Port/Yacht/Timeframe association
  45.     TotalCost               MONEY                                                   NOT NULL, -- How much the customer paid for them and/or their family to travel
  46.     StartDate               DATETIME                                                NOT NULL, -- The date that their trip starts
  47.     TotalDays               INT                                                     NOT NULL, -- How many days in duration their trip is
  48.     CONSTRAINT PK_Booking PRIMARY KEY (ID),
  49.     CONSTRAINT FK_Booking_CharterID FOREIGN KEY (CharterID) REFERENCES Charter (ID)
  50. )
  51.  
  52. CREATE TABLE BookingCustomer
  53. (
  54.     ID                      INT                     IDENTITY(1,1)                   NOT NULL,
  55.     BookingID               INT                                                     NOT NULL, -- Reference to the customer order
  56.     CustomerID              INT                                                     NOT NULL, -- Reference to the customer associated with the order
  57.     CONSTRAINT PK_BookingCustomer PRIMARY KEY (ID),
  58.     CONSTRAINT FK_BookingCustomer_Booking FOREIGN KEY (BookingID) REFERENCES Booking (ID),
  59.     CONSTRAINT FK_BookingCustomer_Customer FOREIGN KEY (CustomerID) REFERENCES Customer (ID)
  60. )
  61. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement