1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
create table t_utilisateur (usr_id serial primary key, usr_name varchar(32));
create table t_usr_groupe (ugr_usr_id integer references t_utilisateur(usr_id) primary key);
create table t_usr_cluster (ucl_usr_id integer references t_utilisateur(usr_id) primary key);
create table R_USR_GRP (usr_id integer references t_usr_groupe(ugr_usr_id), grp_id integer references t_groupe(grp_id), primary key (usr_id, grp_id));
create table R_USR_CLR (usr_id integer references t_usr_cluster(ucl_usr_id), clr_id integer references t_cluster(clr_id), primary key (usr_id, clr_id));
create table t_cluster (clr_id serial primary key, clr_name varchar(32));
create table t_clust_seg (cls_id serial primary key, cls_clr_id integer references t_cluster(clr_id), cls_name varchar(32));
create table t_country (cou_id serial primary key, cou_name varchar(32));
create table t_year (yea_id serial primary key, yea_year integer);
create table t_quarter (qua_id serial primary key, qua_yea_id integer references t_year(yea_id), qua_quarter char(2));
create table t_groupe (grp_id serial primary key, grp_name varchar(32), grp_cls_id integer references t_clust_seg(cls_id));
create table t_filiale (fil_grp_id integer references t_groupe(grp_id), fil_cou_id integer references t_country(cou_id), primary key(fil_grp_id, fil_cou_id));
create table t_activity (act_id serial primary key, act_name varchar(32));
create table t_sale (sal_grp_id integer, sal_cou_id integer, sal_qua_id integer references t_quarter(qua_id), sal_act_id integer references t_activity(act_id),
sal_amount decimal(10,2),
foreign key (sal_grp_id, sal_cou_id) references t_filiale(fil_grp_id, fil_cou_id),
primary key(sal_grp_id, sal_cou_id, sal_qua_id, sal_act_id)); |
Partager