db.sql
author viric@vicerveza
Thu, 18 May 2006 23:47:03 +0200
changeset 0 c270c8b5ddea
permissions -rw-r--r--
Initial release. Usable.
viric@0
     1
-- use prova_pis;
viric@0
     2
drop table if exists moviments ;
viric@0
     3
drop table if exists ingressos ;
viric@0
     4
drop table if exists butxaques ;
viric@0
     5
viric@0
     6
CREATE TABLE butxaques (
viric@0
     7
	id	MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
viric@0
     8
	nom	VARCHAR(50) NOT NULL,
viric@0
     9
	principal	BOOL,
viric@0
    10
viric@0
    11
	PRIMARY KEY (id)
viric@0
    12
	) TYPE = InnoDB;
viric@0
    13
viric@0
    14
-- ingressos i despeses
viric@0
    15
CREATE TABLE ingressos (
viric@0
    16
	data	TIMESTAMP NOT NULL,
viric@0
    17
	data_modif	TIMESTAMP NOT NULL,
viric@0
    18
	rao	TINYTEXT NULL,
viric@0
    19
	quantitat	DECIMAL(18,10) SIGNED NOT NULL,
viric@0
    20
	butxaca		MEDIUMINT UNSIGNED NOT NULL,
viric@0
    21
	comentari	TEXT,
viric@0
    22
viric@0
    23
	PRIMARY KEY (data),
viric@0
    24
	INDEX (butxaca),
viric@0
    25
	FOREIGN KEY (butxaca) REFERENCES butxaques (id)
viric@0
    26
	) TYPE = InnoDB;
viric@0
    27
viric@0
    28
-- moviments de diners entre butxaques
viric@0
    29
CREATE TABLE moviments (
viric@0
    30
	data	TIMESTAMP NOT NULL,
viric@0
    31
	data_modif	TIMESTAMP NOT NULL,
viric@0
    32
	rao	TINYTEXT NOT NULL,
viric@0
    33
	quantitat	DECIMAL(18,10) SIGNED NOT NULL,
viric@0
    34
	comentari	TEXT,
viric@0
    35
	butxaca_origen		MEDIUMINT UNSIGNED NOT NULL,
viric@0
    36
	butxaca_desti		MEDIUMINT UNSIGNED NOT NULL,
viric@0
    37
viric@0
    38
	PRIMARY KEY (data),
viric@0
    39
	INDEX (butxaca_origen),
viric@0
    40
	INDEX (butxaca_desti),
viric@0
    41
	FOREIGN KEY (butxaca_origen) REFERENCES butxaques (id),
viric@0
    42
	FOREIGN KEY (butxaca_desti) REFERENCES butxaques (id)
viric@0
    43
	) TYPE = InnoDB;
viric@0
    44