LaDissertation.com - Dissertations, fiches de lectures, exemples du BAC
Recherche

INF 1250 TN2

Dissertation : INF 1250 TN2. Recherche parmi 298 000+ dissertations

Par   •  9 Octobre 2021  •  Dissertation  •  1 724 Mots (7 Pages)  •  651 Vues

Page 1 sur 7

INF1250

Le langage SQL

Introduction aux bases de données

Exercice #1

Question #1

create database IF not exists JEGERE;

USE JEGERE;

[pic 1]

[pic 2]

Explication :

On doit commence par créer la base de données jegere en s’assurant quel n’existe pas déjà.  Par la suis on la sélectionne pour commencer le travail.


Question #2

CREATE TABLE IF NOT EXISTS jegere.Client

(

idClient INT NOT NULL,

nomClient VARCHAR(45) NOT NULL,

adresse VARCHAR(45) NOT NULL,

telephone VARCHAR(45) NOT NULL,

adresseCourriel VARCHAR (45) NOT NULL,

nomPays VARCHAR (7),

PRIMARY KEY (idClient)

);

Explication :

Création de la table Client si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide. On ajoute aussi la clé primaire « idClient ».

CREATE table if not exists jegere.Employe

(

idEmploye INT not null,

nomEmploye varchar(45) not null,

adresse varchar(45) not null,

telephone varchar(45) not null,

adresseCourriel varchar(45) not null,

primary key (idEmploye)

);

Explication :

Création de la table Employe si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide. On ajoute aussi la clé primaire « idEmploye ».

create table if not exists jegere.Etape

(

idEtape int not null,

nomEtape varchar(45) not null,

livrable varchar(45) not null,

primary key (idEtape)

);

Explication :

Création de la table Etape si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide. On ajoute aussi la clé primaire « idEtape ».

create table if not exists jegere.Projet

(

idProjet int not null,

idClient int not null,

nomProjet varchar(45),

dateDebut date not null,

dateFin date,

idResponsable int not null,

primary key (idProjet),

foreign key (idClient) references jegere.Client (idclient),

foreign key (idResponsable) references jegere.Employe (idEmploye),

check (idProjet between 0 and 4000)

);

Explication :

Création de la table Projet si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide à l’exception de « dateFin » car on ne peut déterminer a tous les insertion cette information. On ajoute aussi la clé primaire « idProjet », et les clés secondaires « idClient » en référence sur « Client.idClient » & « idResponsable » en référence sur « Employe.idEmploye ».

create index idClient

on jegere.Projet (idClient);

create index idEmploye

on jegere.projet (idResponsable);

create table if not exists jegere.EtapexProjet

(

idEtape int not null,

idProjet int not null,

dateDebut date not null,

dateFin date,

foreign key (idEtape) references jegere.Etape (idEtape),

foreign key (idProjet) references jegere.Projet (idProjet)

);

Explication :

Création de la table EtapexProjet si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide à l’exception de « dateFin » car on ne peut déterminer a tous les insertion cette information. On ajoute aussi les clés secondaires « idEtape » en référence sur « Etape.idEtape » & « idProjet » en référence sur « Projet.idProjet ».

create table if not exists jegere.RessourcesProjet

(

idProjet int not null,

idEmploye int not null,

nbrHeures int not null,

prixHeure float not null,

foreign key (idProjet) references jegere.Projet (idProjet),

foreign key (idEmploye) references jegere.Employe (idEmploye)

);

Explication :

Création de la table RessourcesProjet si elle n’existe pas, ajoute des attributs avec mention « not null » pour ceux qui ne doivent pas etre vide. On ajoute aussi les clés secondaires « idProjet » en référence sur « Projet.idProjet » & « idEmploye » en référence sur « Employe.idEmploye ».

Output SGBD :

[pic 3]


Question #3

insert into client (idClient,nomClient,adresse,telephone,adresseCourriel)

value (321,'Financière Quebec','1234 Rue La Montagne, Trois Rivières, QC','8193765244','info@fquebec.qc.ca'),

(345,'services Comptables Garneau','8721 Rue St Laurent, Montreal, QC','5143217896','services@comptablegarneau.ca');

idClient

nomClient

adresse

telephone

adresseCourriel

nomPays

321

Financière Quebec

1234 Rue La Montagne, Trois Rivières, QC

8193765244

info@fquebec.qc.ca

NULL

345

services Comptables Garneau

8721 Rue St Laurent, Montreal, QC

5143217896

services@comptablegarneau.ca

NULL

...

Télécharger au format  txt (16.4 Kb)   pdf (520.5 Kb)   docx (364.2 Kb)  
Voir 6 pages de plus »
Uniquement disponible sur LaDissertation.com