SHARE
TWEET

Untitled

a guest Feb 17th, 2017 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE Locations(
  2.     Id INT IDENTITY PRIMARY KEY,
  3.     Latitude FLOAT ,
  4.     Longitude FLOAT
  5. )
  6.  
  7. CREATE TABLE Credentials(
  8.     Id INT IDENTITY PRIMARY KEY,
  9.     Email VARCHAR(30) ,
  10.     Password VARCHAR(20)
  11. )
  12.  
  13. CREATE TABLE Chats(
  14.     Id INT IDENTITY PRIMARY KEY,
  15.     Title VARCHAR(32) ,
  16.     StartDate DATE ,
  17.     IsActive BIT
  18. )
  19.  
  20. CREATE TABLE Users(
  21.     Id INT IDENTITY PRIMARY KEY,
  22.     Nickname VARCHAR(25) ,
  23.     Gender CHAR(1) ,
  24.     Age INT ,
  25.     LocationId INT ,
  26.     FOREIGN KEY (LocationId) REFERENCES Locations(Id),
  27.     CredentialId INT UNIQUE,
  28.     FOREIGN KEY (CredentialId) REFERENCES Credentials(Id)
  29. )
  30.  
  31. CREATE TABLE Messages(
  32.     Id INT IDENTITY PRIMARY KEY,
  33.     Content VARCHAR(200) ,
  34.     SentOn DATE ,
  35.     ChatId INT ,
  36.     FOREIGN KEY (ChatId) REFERENCES Chats(Id),
  37.     UserId INT ,
  38.     FOREIGN KEY (UserId) REFERENCES Users(id)
  39. )
  40.  
  41. CREATE TABLE UsersChats(
  42.     constraint PK_UsersChats
  43.     primary key (ChatId, UserId),
  44.     UserId INT ,
  45.     FOREIGN KEY(UserId) REFERENCES Users(Id),
  46.     ChatId INT ,
  47.     FOREIGN KEY(ChatId) REFERENCES Chats(Id)
  48. )
RAW Paste Data
Top