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 33 34 35 36 37 38 39 40
| create table ut_utilisateur
( ut_id integer identity primary key
, ut_nom varchar(50) not null
, ut_mail varchar(128) not null
)
;
insert into ut_utilisateur (ut_nom, ut_mail)
values ('dupond', 'dupond@orange.fr')
, ('abadie', 'abadie@gmail.com')
, ('durand', 'durand@yahoo.fr')
;
create table ml_mail
( ml_id integer identity primary key
, ml_date date not null
, ml_obj varchar(30) not null
, ml_txt varchar(255) not null
)
;
insert into ml_mail (ml_date, ml_obj, ml_txt)
values ('2022-05-16', 'votre commande n° 12345', 'fdsq fdsq fds qf fdsqf dsq fdf sq')
, ('2022-05-28', 'information', 'rez r ezrez ar f dsqfg ds eza fv qfdsq fsq fdsf')
, ('2022-06-02', 'RF44 : point hebdo', ' aze r dsqf qsftr avb xcgh ytrrear sdq')
, ('2022-06-10', 'bienvenue !', ' tezoanfgd sqsqfhkjhtabfd f dsqfsqlkjfdsq fdsqf')
;
create table ut_ml
( ut_id integer not null
, ml_id integer not null
, primary key (ut_id, ml_id)
, foreign key (ut_id) references ut_utilisateur (ut_id)
, foreign key (ml_id) references ml_mail (ml_id)
)
;
-- insertion d'un mail particulier pour tous les utilisateurs dans la table des liens mail<->utilisateur
insert into ut_ml (ut_id, ml_id)
( select ut_id, ml_id
from ut_utilisateur
cross join ml_mail
where ml_obj='RF44 : point hebdo'
)
; |
Partager