Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table login(
  2.     idlogin serial primary key,
  3.     email varchar(128) not null,
  4.     "password" varchar(32) null,
  5.     isactive boolean not null,
  6.     iduser int references "user" (iduser),
  7.     constraint "required_email_length" check(length(email) > 8),
  8.     constraint "required_pass_length" check(length(email) > 4)
  9.     );
  10.  
  11. create table "user"(
  12.     iduser serial primary key,
  13.     firstname varchar(32) not null,
  14.     lastname varchar(32) not null,
  15.     salary money not null,
  16.     typeofemployee varchar(6) not null,
  17.     idcurrency int not null references currency (idcurrency),
  18.     constraint "required_employee_length" check(3 <= length(typeofemployee) and length(typeofemployee) <= 6),
  19.     constraint "required_firstName_length" check(length(firstname) > 0),
  20.     constraint "required_lastName_length" check(length(lastname) > 0),
  21.     constraint "required_lastName_length" check(salary > 0)
  22.     );
  23. create table userproject(
  24.     iduserproject serial primary key,
  25.     iduser int references "user" (iduser),
  26.     idproject int references project (idproject)
  27.     );
  28. create table project(
  29.     idproject serial primary key,
  30.     projectname varchar(64) not null,
  31.     budget money default 0.00,
  32.     typeofproject varchar(3) not null, -- jak dlouhy maji zkratky
  33.     isactive boolean not null, -- ujasnit si jak bude zaviset na datumu u startu projektu
  34.     startdate date not null,
  35.     enddate date not null,
  36.     idcurrency int not null references currency (idcurrency),
  37.     constraint "required_projectname_length" check(length(projectname) > 0),
  38.     constraint "required_typeofproject_length" check(length(typeofproject) > 0),
  39.     constraint "required_startDate" check(CURRENT_DATE <= startdate )
  40.     );
  41. create table timeonproject(
  42.     idtime serial primary key,
  43.     workdate date not null,
  44.     worktimebegin time not null,
  45.     worktimeend time null,
  46.     worktime int null,
  47.     iduser int references "user" (iduser),
  48.     idproject int references project (idproject),
  49.     constraint "required_worktime" check(worktime > 12 )
  50.     );
  51. create table invoice(
  52.     idinvoice serial primary key,
  53.     figure money null, -- muze byt castku zaporna nebo prazda ?
  54.     typeofinvoice varchar(10) not null,
  55.     dateofdue date not null, -- muze byt datum splatnosti v minulosti?
  56.     dateofissue date not null,
  57.     urlinvoice text null,
  58.     idcurrency int not null references currency (idcurrency),
  59.     iduser int null references "user" (iduser),
  60.     idproject int references project (idproject),
  61.     idcompany int references company (idcompany)
  62.     );
  63. create table "transaction"(
  64.     idtransaction serial primary key,
  65.     item -- musi byt dalsi tabulka
  66.     "type" varchar(10) not null,
  67.     figure money null, -- opravit podle invoice
  68.     url text null
  69.     "date" date not null,
  70.     idcurrency int not null references currency (idcurrency),
  71.     idinvoice int references invoice (idinvoice),
  72.     )
  73. create table currency(
  74.     idcurrency serial primary key,
  75.     currency varchar(3) not null,
  76.     constraint "required_currency_length" check(length(currency) = 3)
  77.     );
  78. create table company(
  79.     idcompany serial primary key,
  80.     companyname varchar(128) not null
  81.     );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement