Skip to content

sonical0/SQL-Projet-Trans-SN2

Repository files navigation

RAPPORT DE PROJET : CONCEPTION ET EXPLOITATION BDD - TOUTLA

Membres du groupe : Mathéo Cassy, Xavier Sanchez, Mathias de Meulenaire, Alexandre Sanchez
Promotion : SN2
Date : 08/12/2025


1. INTRODUCTION

1.1. Contexte du Projet

La librairie TOUTLA, acteur majeur de la distribution culturelle indépendante en France, a initié une refonte complète de son Système d'Information (SI). Face à un catalogue de dizaines de milliers de références et une logistique complexe (stocks multi-rayons, ventes omnicanales), le système actuel atteint ses limites.

1.2. Objectifs

Ce projet vise la conception et l'exploitation d'une base de données centrale sous Microsoft SQL Server.

Objectifs :

  • Structuration des données : catalogue (Livres, Auteurs, Éditeurs) + fichier client segmenté (Particuliers/Professionnels)
  • Logistique fine : gestion de stock par rayon, alertes automatiques
  • Sécurisation : droits d'accès stricts + plan de reprise d'activité

2. ANALYSE ET MODÉLISATION

2.1. Choix d'Architecture

  • Centralisation des Tiers : Entité Personne regroupant Clients et Vendeurs.
  • Découplage Stock/Produit : Entité associative stock_rayon.
  • Typologie Client : Table de référence Type_Client.

2.2. Règles de Gestion Implémentées

  • R01 : Livre → format, résumé, ISBN unique
  • R02 : Un éditeur / plusieurs auteurs (Asso_4)
  • R03 : Seuil d'alerte géré par couple (Livre, Rayon)
  • R04 : Une commande par client, plusieurs livres via Asso_16

2.3. Dictionnaire des Données (Extrait Critique)

Table Champ Type SQL Remarque Technique
Livre Id_Livre INT IDENTITY Clé primaire auto-incrémentée
ISBN INT Format numérique
resume TEXT Descriptif / Titre
prix_ht DECIMAL(10,2) Précision monétaire standard
stock_rayon quantité INT Stock physique réel
seuil_darlerte VARCHAR(50) Permet des annotations
Asso_16 Id_Livre INT Référence produit vendu
Id_Commandes INT Référence commande

Modèle Logique des Données de TOUTLA


3. IMPLÉMENTATION SQL SERVER

La base Librairie TOUTCA respecte l’intégrité référentielle.

3.1. Jeu de Données

  • Création référentiels : 10 Rayons, 4 Langues, 15 Auteurs
  • 80 Livres (réels + générés)
  • Simulation des ventes et stocks initiaux

4. EXPLOITATION ET REQUÊTES

4.1. Gestion des Stocks Critiques

CREATE OR ALTER VIEW Vue_StockCritique AS
SELECT 
    LivreRef.ISBN,
    LivreRef.Titre,
    EditeurRef.Nom        AS NomEditeur,
    StockRef.Quantite    AS StockActuel,
    LivreRef.SeuilAlerte AS StockMinimum
FROM Stock AS StockRef
JOIN Livre AS LivreRef 
    ON StockRef.ISBN = LivreRef.ISBN
JOIN Editeur AS EditeurRef 
    ON LivreRef.EditeurID = EditeurRef.EditeurID
WHERE StockRef.Quantite <= LivreRef.SeuilAlerte;
GO

4.2. Historique Client

CREATE OR ALTER PROCEDURE GetHistoriqueClient
    @ClientId INT
AS
BEGIN
    SET NOCOUNT ON;

    SELECT 
        ClientRef.Nom              AS NomClient,
        ClientRef.Prenom           AS PrenomClient,
        VenteRef.DateVente         AS DateVente,
        LivreRef.Titre             AS TitreLivre,
        LigneVenteRef.Quantite     AS QuantiteAchetee,
        LigneVenteRef.PrixUnitaire AS PrixUnitaire,
        (LigneVenteRef.Quantite * LigneVenteRef.PrixUnitaire)
            AS MontantLigne
    FROM Vente AS VenteRef
    JOIN Client AS ClientRef 
        ON VenteRef.ClientID = ClientRef.ClientID
    JOIN LigneVente AS LigneVenteRef 
        ON VenteRef.VenteID = LigneVenteRef.VenteID
    JOIN Livre AS LivreRef 
        ON LigneVenteRef.ISBN = LivreRef.ISBN
    WHERE ClientRef.ClientID = @ClientId
    ORDER BY VenteRef.DateVente DESC;
END;
GO

4.3. Export comptable des ventes (CSV)

CREATE OR ALTER PROCEDURE ExportVentesCSV
AS
BEGIN
    SET NOCOUNT ON;

    SELECT 
        FORMAT(VenteRef.DateVente, 'dd/MM/yyyy') AS DateVente,
        CAST(LigneVenteRef.Quantite * LigneVenteRef.PrixUnitaire 
             AS DECIMAL(10,2)) AS MontantHT,
        CAST((LigneVenteRef.Quantite * LigneVenteRef.PrixUnitaire) * 0.055 
             AS DECIMAL(10,2)) AS MontantTVA,
        CAST((LigneVenteRef.Quantite * LigneVenteRef.PrixUnitaire) * 1.055 
             AS DECIMAL(10,2)) AS MontantTTC,
        ClientRef.ClientID AS CodeClient,
        LigneVenteRef.ISBN AS CodeProduit
    FROM Vente AS VenteRef
    JOIN LigneVente AS LigneVenteRef 
        ON VenteRef.VenteID = LigneVenteRef.VenteID
    JOIN Client AS ClientRef 
        ON VenteRef.ClientID = ClientRef.ClientID
    ORDER BY VenteRef.DateVente ASC, ClientRef.ClientID ASC;
END;
GO

5. ADMINISTRATION ET SÉCURITÉ

5.1. Gestion des Rôles

  • Role_Vente : Commandes + Clients (RW), Catalogue (R)
  • Role_Gestion_Stock : Livres + stock_rayon (RW)
  • Role_Communication : Données publiques (R)
CREATE ROLE [Role_Vente];
GRANT SELECT, INSERT, UPDATE ON dbo.Commandes TO [Role_Vente];
GRANT SELECT ON dbo.Livre TO [Role_Vente];

5.2. Vues et Procédures Stockées

CREATE PROCEDURE [dbo].[ExportVentesCSV] AS
BEGIN
    SELECT
        FORMAT(C.Date_heure, 'yyyy-MM-dd') AS [date],
        L.prix_ht,
        CAST(L.prix_ht * 0.055 AS DECIMAL(10,2)) AS [montant tva],
        CAST(L.prix_ht * 1.055 AS DECIMAL(10,2)) AS [montant ttc],
        C.Id_Client, L.ISBN
    FROM dbo.Commandes C
    JOIN dbo.Asso_16 A ON C.Id_Commandes = A.Id_Commandes
    JOIN dbo.Livre L ON A.Id_Livre = L.Id_Livre
    ORDER BY C.Date_heure ASC;
END

5.3. Politique de Sauvegarde

  • Full : Lundi 02h00
  • Différentielles : Mercredi & Vendredi 00h00

Captures d'écran des plans de maintenance

Sauvegarde Complète tout les lundis à 02h00 Sauvegarde Complète Sauvegarde Différentielle tous les mercredis et vendredis à 00h00 Sauvegarde Différentielle


6. CONCLUSION ET PERSPECTIVES

6.1. Bilan

Prototype fonctionnel répondant aux exigences : unicité des données, gestion de stock par rayon, sécurité des accès.

6.2. Améliorations prévues (V2)

  • Migration ISBN → VARCHAR(13) ou BIGINT
  • Ajout du champ Quantité dans Asso_16

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages