Membres du groupe : Mathéo Cassy, Xavier Sanchez, Mathias de Meulenaire, Alexandre Sanchez
Promotion : SN2
Date : 08/12/2025
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.
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é
- Centralisation des Tiers : Entité
Personneregroupant Clients et Vendeurs. - Découplage Stock/Produit : Entité associative
stock_rayon. - Typologie Client : Table de référence
Type_Client.
- 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
| 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 |
La base Librairie TOUTCA respecte l’intégrité référentielle.
- 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
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;
GOCREATE 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;
GOCREATE 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- 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];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- Full : Lundi 02h00
- Différentielles : Mercredi & Vendredi 00h00
Sauvegarde Complète tout les lundis à 02h00
Sauvegarde Différentielle tous les mercredis et vendredis à 00h00

Prototype fonctionnel répondant aux exigences : unicité des données, gestion de stock par rayon, sécurité des accès.
- Migration ISBN →
VARCHAR(13)ouBIGINT - Ajout du champ
QuantitédansAsso_16
