-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoutput.sql
More file actions
53 lines (45 loc) · 1.45 KB
/
output.sql
File metadata and controls
53 lines (45 loc) · 1.45 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
-- create tables
create table Departement (
id number generated by default on null as identity constraint Departement_id_pk primary key constraint Departement_id_pk primary key,
name varchar(20 char) constraint Departement_name_cc check (name in ('IT','Finance','Accounting'))
)
;
create table Employee (
id number generated by default on null as identity constraint Employee_id_pk primary key constraint Employee_id_pk primary key,
name varchar(20 char),
CIN varchar(10 char) constraint Employee_CIN_unq unique,
hireDate date,
salary integer,
departement_id number constraint Employee_departement_id_fk references Departement on delete cascade
)
;
--comments
comment on column Employee.CIN is 'numéro de la carte d'identité nationale ';
create table Project (
id number generated by default on null as identity constraint Project_id_pk primary key constraint Project_id_pk primary key,
description varchar(200 char),
Employee_id number constraint Project_Employee_id_fk references Employee on delete cascade
)
;
-- table index
-- create views
create or replace view V1 as
select
Employee.name Employee_name,
Employee.CIN Employee_CIN,
Employee.hireDate Employee_hireDate,
Employee.salary Employee_salary,
Employee.departement_id Employee_departement_id,
Departement.name Departement_name
from
Employee, Departement
where
/
-- load data
select
name,
CIN,
hireDate,
salary,
departement_id
from Employee;