Bases de données réparties: TP1



Similar documents
site et appel d'offres

--Nom: Laurent Senécal-Léonard

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";! SET time_zone = "+00:00";!

--- Vincent Hamel, hamv

Personnalisez votre intérieur avec les revêtements imprimés ALYOS design


Troncatures dans les modèles linéaires simples et à effets mixtes sous R

Introduction au BIM. ESEB Seyssinet-Pariset Economie de la construction contact@eseb.fr

Modifier le texte d'un élément d'un feuillet, en le spécifiant par son numéro d'index:

Thursday, February 7, DOM via PHP

Contracts over $10,000: 1 April 2013 to 30 September 2013 Contrats de plus de $ : 1er avril 2013 au 30 septembre 2013

Superviser efficacement son IT avec Tivoli Monitoring

PostGIS Integration Tips

APPLICATION SPECIFICATION

SUN SEEBEYOND egate INTEGRATOR RELEASE NOTES. Release 5.1.1

Calcul parallèle avec R

ACP-EU Cooperation Programme in Science and Technology (S&T II) / Programme de Coopération ACP-UE pour la Science et la Technologie

Réponse à une question de Roger Bastide Document 40

Sur 1 Bit bit n 4 bit n 3 bit n 2 bit n 1 bit n 4 bit n 3 bit n 2 bit n 1 bit n 4 bit n 3 bit n 2 bit n 1

Sun Integrated Lights Out Manager (ILOM) 3.0 Supplement for the Sun Fire X4150, X4250 and X4450 Servers

Les fragments. Programmation Mobile Android Master CCI. Une application avec deux fragments. Premier layout : le formulaire

Liste d'adresses URL

"Internationalization vs. Localization: The Translation of Videogame Advertising"

Canada. ... Canadian Nuclear Commission canadienne. Violation. Relevant Facts I Faits pertinents

Archived Content. Contenu archivé

TP JSP : déployer chaque TP sous forme d'archive war

FINAL DRAFT INTERNATIONAL STANDARD

Product / Produit Description Duration /Days Total / Total

Annual Event 2016 Workshop New to Interreg, where to begin? Évènement annuel 2016 Atelier «Interreg pour les débutants, par où commencer?

Archived Content. Contenu archivé

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

Backup Scanner Module

Archived Content. Contenu archivé

Bienvenue au Forum Vector 2007

A Rational Software Whitepaper

Brazil + JDBC Juin 2001, douin@cnam.fr

In-Home Caregivers Teleconference with Canadian Bar Association September 17, 2015

COLLABORATIVE LCA. Rachel Arnould and Thomas Albisser. Hop-Cube, France

Sun Management Center Change Manager Release Notes

Archived Content. Contenu archivé

Archived Content. Contenu archivé

An overview of Web development (for PDL)

Life Sciences. Volume 5 August Issue date: August 7, 2008

Archived Content. Contenu archivé

SQL Server Introduction to SQL Server SQL Server 2005 basic tools. SQL Server Configuration Manager. SQL Server services management

Sun StorEdge Availability Suite Software Point-in-Time Copy Software Maximizing Backup Performance

Kenya : safari retro en terre Masaï...

The wolf who wanted to change his color Week 1. Day 0. Day 1. Day 2. Day 3. - Lecture de l album

AgroMarketDay. Research Application Summary pp: Abstract

Solaris 10 Documentation README

Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA)

Archived Content. Contenu archivé

Solaris 9 9/05 Installation Roadmap

Instruction de montage de voûte ISOLHIS petite portée

SUN SEEBEYOND ebam STUDIO RELEASE NOTES. Release 5.1.2

Measuring Policing Complexity: A Research Based Agenda

Numéro de projet CISPR Amd 2 Ed IEC/TC or SC: CISPR/A CEI/CE ou SC: Date of circulation Date de diffusion

CERN EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

"Templating as a Strategy for Translating Official Documents from Spanish to English"

Administrer les solutions Citrix XenApp et XenDesktop 7.6 CXD-203

Using Oracle TimesTen to Deploy Low Latency VOIP Applications in Remote Sites

SunFDDI 6.0 on the Sun Enterprise Server

Note concernant votre accord de souscription au service «Trusted Certificate Service» (TCS)

Distributed Application Management using Jini Connection Technology

CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design

Sun Enterprise Optional Power Sequencer Installation Guide

Integrate 'Oracle Forms', 'Oracle Reports', 'Oracle

Start Here. Installation and Documentation Reference. Sun StorEdgeTM 6120 Array

SUPPORTS DE TABLETTES SUR CABLES OU TIGES INOX CABLE AND ROD SUSPENDED DIPLAY SYSTEMS

Annexe - OAuth Introduction. Xavier de Rochefort xderoche@labri.fr - labri.fr/~xderoche 15 mai 2014

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

"Simultaneous Consecutive Interpreting: A New Technique Put to the Test"

STAGE YOGA & RANDONNEES à MADERE

types, but key declarations and constraints Similar CREATE X commands for other schema ëdrop X name" deletes the created element of beer VARCHARè20è,

Sun StorEdge RAID Manager Release Notes

French 8655/S 8655/S. AQA Level 1/2 Certificate June Teacher s Booklet. To be conducted by the teacher-examiner between 24 April and 15 May 2014

A web-based multilingual help desk

Active Offer of Service in both Official Languages

Installation troubleshooting guide

src Documentation Release Pierre Humblot

Corrigés des exercices SQL pour MySQL

Sélection adaptative de codes polyédriques pour GPU/CPU

Power Distribution System. Additional Information on page 2 See Page 2 Page 6. Eaton. See Page 2. Additional Information on page 2

Short Form Description / Sommaire: Carrying on a prescribed activity without or contrary to a licence

LAN-Free Backups Using the Sun StorEdge Instant Image 3.0 Software

General Certificate of Education Advanced Level Examination June 2012

Sun Fire V20z and Sun Fire V40z Servers Differences Between Server Versions

Archived Content. Contenu archivé

Oracle Database 10g Express

Unrealized Gains in Stocks from the Viewpoint of Investment Risk Management

READ AND FOLLOW ALL SAFETY INSTRUCTIONS 1. DANGER RISK OF SHOCK DISCONNECT POWER BEFORE INSTALLATION

Today we're going to officially start the program by working on a unit focused on Spoken production.

Transcription:

Bases de données réparties: TP1 Partie 1: répartition 1) et 2) Création d'un user avec les droits suffisants CREATE USER cuenot IDENTIFIED BY cuenot; GRANT connect, resource, create view, create database link, create snapshot TO cuenot; 3) Création d'une table répartie sur chaque DB (Employe1 et Employe2) # Sur base1 CREATE TABLE Employe1( nomemp VARCHAR(10), CONSTRAINT idemp_pk PRIMARY KEY (idemp)); # Sur base2 CREATE TABLE Employe2( nomemp VARCHAR(10), CONSTRAINT idemp_pk PRIMARY KEY (idemp)); 4) Mise en place d'une vue Employe sur chaque machine pour rendre la fragmentation transparente # Sur la base1 CREATE DATABASE LINK BASE2.RIA USING 'BASE2.RIA'; CREATE VIEW Employe AS SELECT Employe1.idemp, Employe1.nomemp FROM Employe1@BASE1.RIA SELECT Employe2.idemp, Employe2.nomemp FROM Employe2@BASE2.RIA; # Sur la base2 CREATE DATABASE LINK BASE1.RIA USING 'BASE1.RIA'; CREATE VIEW Employe AS SELECT Employe2.idemp, Employe2.nomemp FROM Employe2@BASE2.RIA SELECT Employe1.idemp, Employe1.nomemp FROM Employe1@BASE1.RIA; 5) Création de triggers pour gérer l'insertion et l'auto-increment: # Creation d'une sequence CREATE SEQUENCE new_emp; # Creation du trigger d'auto-increment /!\ Marche pas CREATE TRIGGER Tr_incemp BEFORE INSERT ON Employe 1

WHEN (new.idemp is null) SELECT new_emp.nextval INTO :New.idemp from DUAL; END; #Si pair: insertion sur la base1 #Si impair: insertion sur la base2 CREATE OR REPLACE TRIGGER Tr_repemp INSTEAD OF INSERT on Employe IF :New.idemp mod 2 = 0 THEN INSERT INTO Employe1@BASE1.RIA(idemp,nomemp) VALUES (:New.idemp,:New.nomemp); ELSE INSERT INTO Employe2@BASE2.RIA(idemp,nomemp) VALUES (:New.idemp,:New.nomemp); END IF; END; # Test: INSERT INTO Employe (idemp, nomemp) VALUES ('1', 'Test1'); INSERT INTO Employe (idemp, nomemp) VALUES ('2', 'Test2'); 6) Création d'une table fragmentée verticalement # Sur base1 CREATE TABLE Produit1( nomprod VARCHAR(10), prixachat FLOAT, CONSTRAINT idprod_pk PRIMARY KEY (idprod)); # Sur base2 CREATE TABLE Produit2( prixvente FLOAT, CONSTRAINT idprod_pk PRIMARY KEY (idprod)); # Création de la vue CREATE VIEW Produit AS SELECT Produit1.idprod, Produit1.nomprod, Produit1.prixachat, Produit2.prixvente FROM Produit1@BASE1.RIA, Produit2@BASE2.RIA #Création du trigger sur les 2 bases CREATE OR REPLACE TRIGGER Tr_prod1 INSTEAD OF INSERT on Produit INSERT INTO Produit1@BASE1.RIA(idprod,nomprod,prixachat) VALUES (:New.idprod,:New.nomprod,:New.prixachat); INSERT INTO Produit2@BASE2.RIA(idprod,prixvente) VALUES (:New.idprod,:New.prixvente); 2

END; #Test INSERT INTO Produit (idprod, nomprod, prixachat, prixvente) VALUES ('1', 'pain', '1', '2'); 7) Creation d'une page achat CREATE TABLE Achat1( idachat INTEGER, dateachat DATE, CONSTRAINT idachat_pk PRIMARY KEY (idachat), CONSTRAINT idachat_fk FOREIGN KEY (idemp) REFERENCES Employe1(idemp)); # Base2 CREATE TABLE Achat2( idachat INTEGER, dateachat DATE, CONSTRAINT idachat_pk PRIMARY KEY (idachat), CONSTRAINT idachat_fk FOREIGN KEY (idemp) REFERENCES Employe2(idemp)); # Vue CREATE VIEW Achat AS SELECT Achat1.idachat,Achat1.idprod,Achat1.idemp,Achat1.dateachat FROM Achat1@BASE1.RIA SELECT Achat2.idachat,Achat2.idprod,Achat2.idemp,Achat2.dateachat FROM Achat2@BASE2.RIA; # Base2 CREATE VIEW Achat AS SELECT Achat2.idachat,Achat2.idprod,Achat2.idemp,Achat2.dateachat FROM Achat2@BASE2.RIA SELECT Achat1.idachat,Achat1.idprod,Achat1.idemp,Achat1.dateachat FROM Achat1@BASE1.RIA; # Trigger CREATE OR REPLACE TRIGGER Tr_achat1 INSTEAD OF INSERT on Achat IF :New.idemp mod 2 = 0 THEN INSERT INTO Achat1@BASE1.RIA(idachat,idprod,idemp,dateachat) VALUES (:New.idachat,:New.idprod,:New.idemp,:New.dateachat); ELSE INSERT INTO Achat2@BASE2.RIA(idachat,idprod,idemp,dateachat) 3

VALUES (:New.idachat,:New.idprod,:New.idemp,:New.dateachat); END IF; END; # Test INSERT INTO Achat (idachat, idprod, idemp, dateachat) VALUES ('1', '5', '1', '20071210'); INSERT INTO Achat (idachat, idprod, idemp, dateachat) VALUES ('1', '8', '2', '20071220'); Partie 2: réplication # Sur la base1 CREATE DATABASE LINK BASE2.RIA CONNECT TO cuenot IDENTIFIED BY cuenot USING 'BASE2.RIA'; # Sur la base1 CREATE DATABASE LINK BASE1.RIA CONNECT TO cuenot IDENTIFIED BY cuenot USING 'BASE1.RIA'; 1) Création d'une table fournisseur # Création de la table CREATE TABLE Fournisseur1( idfourn INTEGER, nomfourn VARCHAR(10), adrfourn VARCHAR(20), CONSTRAINT idfourn_pk PRIMARY KEY (idfourn)); # Création des vues matérialisées pour la réplication complète CREATE VIEW Fournisseur AS SELECT * FROM Fournisseur1@BASE1.RIA; # Base2 CREATE MATERIALIZED VIEW Fournisseur REFRESH COMPLETE AS SELECT * FROM Fournisseur1@BASE1.RIA; # Test INSERT INTO Fournisseur(idfourn,nomfourn,adrfourn) VALUES('1', 'kugar', 'strasbourg'); INSERT INTO Fournisseur(idfourn,nomfourn,adrfourn) VALUES('2', 'roger', 'dtc'); # Remplacement par une réplication incrémentale #Base1 on crée un snapshot CREATE SNAPSHOT LOG ON Fournisseur1 ; 4

# Base 2 on met a jour la vue matérialisée ALTER MATERIALIZED VIEW Fournisseur REFRESH FAST; # ou on la drop et recrée CREATE MATERIALIZED VIEW Fournisseur REFRESH FAST AS SELECT * FROM Fournisseur1@BASE1.RIA; 2) # Donner les droits a quelqu'un d'autre GRANT select ON Fournisseur TO mikrobe; GRANT select ON MLOG$_Fournisseur TO mikrobe; # Réplication complète REFRESH COMPLETE AS SELECT * FROM Mikrobe.Fournisseur@BASE1.RIA; #Base2 REFRESH COMPLETE AS SELECT * FROM Mikrobe_Fourn@BASE1.RIA; # Réplication incrémentale REFRESH FAST AS SELECT * FROM Mikrobe.Fournisseur@BASE1.RIA; CREATE SNAPSHOT LOG ON Mikrobe_Fourn ; #Base2 REFRESH FAST AS SELECT * FROM Mikrobe_Fourn@BASE1.RIA; 5

3) # Mise en place d'un table catégorie CREATE TABLE Categorie1( idcat INTEGER, nomcat VARCHAR(10), CONSTRAINT idcat_pk PRIMARY KEY (idcat)); DBMS_REPCAT.CREATE 6