initlal
This commit is contained in:
commit
d890c1b8c2
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
98
schema/initial-create-schema.sql
Normal file
98
schema/initial-create-schema.sql
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
create database hausverwaltung;
|
||||||
|
|
||||||
|
use hausverwaltung;
|
||||||
|
|
||||||
|
create table objekt (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
shortname varchar(32) not null,
|
||||||
|
flaeche decimal (20, 10) not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint unique key uk_objekt_shortname (shortname)
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table wohnung (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
objekt integer unsigned not null,
|
||||||
|
shortname varchar(64) not null,
|
||||||
|
flaeche decimal (20, 10) not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint unique key uk_wohnung_objekt_shortname (objekt, shortname),
|
||||||
|
constraint foreign key fk_wohnung_objekt (objekt)
|
||||||
|
references objekt (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table mieter (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
wohnung integer unsigned not null,
|
||||||
|
anrede varchar(32),
|
||||||
|
vorname varchar(128),
|
||||||
|
nachname varchar(128) not null,
|
||||||
|
strasse varchar(128),
|
||||||
|
plz varchar(10),
|
||||||
|
ort varchar(128),
|
||||||
|
telefon varchar(64),
|
||||||
|
einzug date not null,
|
||||||
|
auszug date,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint foreign key fk_mieter_wohnung (wohnung)
|
||||||
|
references wohnung (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table zahlung (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
mieter integer unsigned not null,
|
||||||
|
datum date not null,
|
||||||
|
betrag decimal (20, 10) not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint foreign key fk_zahlung_mieter (mieter)
|
||||||
|
references mieter (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table miete (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
wohnung integer unsigned not null,
|
||||||
|
betrag decimal (20, 10) not null,
|
||||||
|
gueltig_ab date not null,
|
||||||
|
gueltig_bis date not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint unique key uk_miete_wohnung_gueltig_ab (wohnung, gueltig_ab),
|
||||||
|
constraint unique key uk_miete_wohnung_gueltig_bis (wohnung, gueltig_bis),
|
||||||
|
constraint foreign key fk_miete_wohnung (wohnung)
|
||||||
|
references wohnung (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table betriebskosten_vorauszahlung (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
objekt integer unsigned not null,
|
||||||
|
betrag decimal (20, 10) not null,
|
||||||
|
gueltig_ab date not null,
|
||||||
|
gueltig_bis date not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint unique key uk_betriebskosten_vorauszahlung_objekt_gueltig_ab (objekt, gueltig_ab),
|
||||||
|
constraint unique key uk_betriebskosten_vorauszahlung_objekt_gueltig_bis (objekt, gueltig_bis),
|
||||||
|
constraint foreign key fk_betriebskosten_vorauszahlung_objekt (objekt)
|
||||||
|
references objekt (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
||||||
|
|
||||||
|
create table betriebskosten_abrechnung (
|
||||||
|
id integer unsigned not null auto_increment,
|
||||||
|
objekt integer unsigned not null,
|
||||||
|
jahr year not null,
|
||||||
|
betrag decimal (20, 10) not null,
|
||||||
|
constraint primary key (id),
|
||||||
|
constraint unique key uk_betriebskosten_abrechnung_objekt_jahr (objekt, jahr),
|
||||||
|
constraint foreign key fk_betriebskosten_abrechnung_objekt (objekt)
|
||||||
|
references objekt (id)
|
||||||
|
on delete restrict
|
||||||
|
on update cascade
|
||||||
|
) engine=InnoDB;
|
Loading…
x
Reference in New Issue
Block a user