· 4 years ago · Jan 07, 2021, 08:32 PM
1##----------------------------------------------------------
2##
3## creare tabele client, cont, tip_operatiune, tranzactie_cont
4##
5##-------------------------------------------------------------
6create DATABASE IF NOT EXISTS colocviu;
7USE colocviu;
8DROP TABLE IF EXISTS cont;
9DROP TABLE IF EXISTS client;
10
11CREATE TABLE IF NOT EXISTS client
12(id int unique auto_increment primary key,
13nume char(20),
14prenume char(20),
15adresa char(50));
16
17CREATE TABLE IF NOT EXISTS cont
18(id int unique auto_increment primary key,
19client_id int,
20cod int,
21valoare float,
22FOREIGN KEY (client_id) REFERENCES client(id));
23
24CREATE TABLE IF NOT EXISTS tip_operatiune
25(id int unique auto_increment primary key,
26nume char(40));
27
28CREATE TABLE IF NOT EXISTS tranzactie_cont
29(id int unique auto_increment primary key,
30cont_sursa_id int,
31cont_destinatie_id int,
32tip int,
33data date,
34timp time,
35valoare float,
36detaliu char(20),
37FOREIGN KEY (cont_sursa_id) REFERENCES cont(id),
38FOREIGN KEY (cont_destinatie_id) REFERENCES cont(id),
39FOREIGN KEY (tip) REFERENCES tip_operatiune(id));
40