0% found this document useful (0 votes)
5 views3 pages

Script Ex 2 Ex 3 TP4 SGBD

The document contains SQL scripts for creating and managing a database related to students, subjects, and their grades. It includes the creation of tables for students, subjects, grades, results, and rankings, along with sample data insertion. Additionally, it features a separate section for creating a film table with sample entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Script Ex 2 Ex 3 TP4 SGBD

The document contains SQL scripts for creating and managing a database related to students, subjects, and their grades. It includes the creation of tables for students, subjects, grades, results, and rankings, along with sample data insertion. Additionally, it features a separate section for creating a film table with sample entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

w3/* script Exercice 2*/

DROP TABLE note;


DROP TABLE etudiant;
DROP TABLE matiere;
drop table resultat;
drop table classement;

/* Cr�ation des Tables */

/* etudiant */

CREATE TABLE etudiant(


numE number primary key,
nomE VARCHAR2(30),
prenomE varchar(30),
date_naissance date);

/* matiere */

CREATE TABLE matiere(


codeM number primary key,
nomM varchar(20),
coeffcc number(8,2),
coeffexam number(8,2));

/* note */

CREATE TABLE note(


numE number,
codeM number,
notecc number(8,3),
noteexam number(8,3));

ALTER TABLE note


ADD ( CONSTRAINT C1_note PRIMARY KEY(numE, codeM),
CONSTRAINT C2_note FOREIGN KEY(numE) REFERENCES etudiant(numE),
CONSTRAINT C3_note FOREIGN KEY(codeM) REFERENCES matiere(codeM)
);

insert into etudiant


values (100,'Gharbi', 'imed', TO_DATE('12/05/1987','DD/MM/YY'));
insert into etudiant
values (101,'Gharbi', 'Mohamed', TO_DATE('11/04/1989','DD/MM/YY'));
insert into etudiant
values (102,'Gharbi', 'leila', TO_DATE('12/05/1988','DD/MM/YY'));
insert into etudiant
values (103,'hachani', 'salwa', TO_DATE('25/01/1988','DD/MM/YY'));
insert into matiere
values (11,'M1', 1, 2);
insert into matiere
values (12,'M2', 1.5, 3);
insert into matiere
values (13,'M3', 0.2, 0.8);

insert into note


values (100,11, 12, 14);
insert into note
values (100,12, 10, 8);
insert into note
values (100,13, 11, 11.5);

insert into note


values (101,11, 8, 10);
insert into note
values (101,12, 12, 14);
insert into note
values (101,13, 8, 8);

insert into note


values (102,11, 8, 10);
insert into note
values (102,12, 12, 14);
insert into note
values (102,13, 8, 8);

insert into note


values (103,11, 12, 10);
insert into note
values (103,12,13,null);
insert into note
values (103,13, 12.5, 16);

create table resultat (nume number, nome varchar2(30), codeM number,moy


number(10,3),
primary key(nume,codeM));
create table classement (nume number, nome varchar2(30), moyenne number(10,3), rang
number);

/* script exercice 3 */

drop table film;


create table film (titre varchar2(20) primary key, realisateur varchar2(20), duree
number(5));

insert into film values ('ABCD', 'Imed Gharbi', 2);


insert into film values ('AZER', 'Ali Bejaoui', 3);
insert into film values ('Arty', 'Imed Gharbi', 2);
insert into film values ('RTY', 'Fathi Bejaoui',2);
commit;

You might also like