Advertisement
Neveles

sql

Dec 19th, 2021
1,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.85 KB | None | 0 0
  1. create table Administator
  2. (
  3.     id_admin int identity(1,1) primary key,
  4.     login varchar(50) unique not null,
  5.     password_hash binary(64) not null,
  6.     surname nvarchar(50) not null,
  7.     name nvarchar(50) not null,
  8.     patronymic nvarchar(50)
  9. )
  10.  
  11. create table Doctor
  12. (
  13.     id_doc int identity(1,1) primary key,
  14.     login varchar(50) unique not null,
  15.     password_hash binary(64) not null,
  16.     surname nvarchar(50) not null,
  17.     name nvarchar(50) unique not null,
  18.     patronymic nvarchar(50),
  19.     phone varchar(20) not null,
  20.     id_spec tinyint not null foreign key references Specialty,
  21.     sex nchar(1) not null,
  22.     birthdate date not null,
  23.     passport varchar(12) not null,
  24.     room varchar(3) not null,
  25.     is_active bit not null default 'true'
  26. )
  27.  
  28. create table Patient
  29. (
  30.     id_pat int identity(1,1) primary key,
  31.     login varchar(50) unique not null,
  32.     password_hash binary(64) not null,
  33.     surname nvarchar(50) not null,
  34.     name nvarchar(50) not null,
  35.     patronymic nvarchar(50),
  36.     phone varchar(20) not null,
  37.     sex nchar(1) not null,
  38.     birthdate date not null,
  39.     passport varchar(12) not null
  40. )
  41.  
  42. create table Appointment
  43. (
  44.     id_app int identity(1,1) primary key,
  45.     id_pat int foreign key references Patient not null,
  46.     id_proc int foreign key references [Procedure] not null,
  47.     date datetime2(7) not null,
  48.     is_canceled bit not null default 'false',
  49.     is_paid bit not null default 'false',
  50. )
  51.  
  52. create table [Procedure]
  53. (
  54.     id_proc int identity(1,1) primary key,
  55.     name nvarchar(100) not null,
  56.     price money not null,
  57.     id_doc int foreign key references Doctor not null
  58. )
  59.  
  60. create table Report
  61. (
  62.     id_rep int identity(1,1) primary key,
  63.     complaints nvarchar(MAX) not null,
  64.     diagnosis nvarchar(MAX) not null,
  65.     recommendations nvarchar(MAX) not null,
  66.     id_app int foreign key references Appointment not null
  67. )
  68.  
  69. create table Specialty
  70. (
  71.     id_spec tinyint identity(1,1) primary key,
  72.     name nvarchar(50) not null,
  73. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement