Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE Locations
- (
- Id int PRIMARY KEY IDENTITY,
- Latitude float NOT NULL,
- Longitude float NOT NULL
- )
- CREATE TABLE Credentials
- (
- Id int PRIMARY KEY IDENTITY,
- Email varchar(30) NOT NULL,
- Password varchar(20) NOT NULL
- )
- CREATE TABLE Users
- (
- Id int PRIMARY KEY IDENTITY,
- Nickname varchar(25) NOT NULL,
- Gender char(1) NOT NULL,
- Age int CHECK(Age >= 0) NOT NULL,
- LocationId int FOREIGN KEY REFERENCES Locations(Id) NOT NULL,
- CredentialId int UNIQUE FOREIGN KEY REFERENCES Credentials(Id) NOT NULL
- )
- CREATE TABLE Chats
- (
- Id int PRIMARY KEY IDENTITY,
- Title varchar(32) NOT NULL,
- StartDate date NOT NULL,
- IsActive bit NOT NULL
- )
- CREATE TABLE Messages
- (
- Id int PRIMARY KEY IDENTITY,
- Content varchar(200) NOT NULL,
- SentOn date NOT NULL,
- ChatId int FOREIGN KEY REFERENCES Chats(Id) NOT NULL,
- UserId int FOREIGN KEY REFERENCES Users(Id) NOT NULL
- )
- CREATE TABLE UsersChats
- (
- UserId int FOREIGN KEY REFERENCES Users(Id) NOT NULL,
- ChatId int FOREIGN KEY REFERENCES Chats(Id) NOT NULL,
- CONSTRAINT PK_UsersChats
- PRIMARY KEY (ChatId, UserId)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement