This commit is contained in:
2025-09-30 07:40:56 +02:00
parent 1d35e1b184
commit 39c73db7e8
3 changed files with 16425 additions and 93 deletions

View File

@@ -13,6 +13,7 @@ drop table if exists editions;
drop table if exists exemplaires; drop table if exists exemplaires;
drop table if exists genres; drop table if exists genres;
drop table if exists collections; drop table if exists collections;
drop table if exists incorpore;
drop table if exists adherents; drop table if exists adherents;
drop table if exists adresses; drop table if exists adresses;
@@ -24,155 +25,233 @@ drop table if exists commande;
drop table if exists commande_statut; drop table if exists commande_statut;
drop table if exists livraison_methode; drop table if exists livraison_methode;
-- -- ************************************************************
PRAGMA integrity_check;
PRAGMA foreign_key_check; pragma integrity_check;
pragma foreign_key_check;
-- ************************************************************
CREATE TABLE statuts (
statutId INTEGER PRIMARY KEY,
statut TEXT NOT NULL
);
CREATE TABLE pays (
code TEXT PRIMARY KEY CHECK (LENGTH(code) = 2),
nom TEXT NOT NULL
);
insert into pays values
('FR', 'France'), ('GB', 'Royaume-Uni'), ('US', 'États-Unis'), ('TR', 'Türkiye');
CREATE TABLE langues ( CREATE TABLE langues (
langue_id INTEGER, code TEXT PRIMARY KEY CHECK (LENGTH(code) = 2 or LENGTH(code) = 5),
langue_code VARCHAR(5) PRIMARY KEY, nom TEXT NOT NULL
langue TEXT
); );
insert into langues values
('fr', 'français'), ('tr', 'turc'),
('en', 'anglais'), ('en-gb', 'anglais britannique'), ('en-us', 'anglais américain');
CREATE TABLE genres (
genreId INTEGER PRIMARY KEY,
nom TEXT NOT NULL
);
insert into genres (nom) values
('space opera'), ('horreur'), ('fiction historique');
CREATE TABLE auteurs ( CREATE TABLE auteurs (
auteur_id INTEGER PRIMARY KEY, auteurId INTEGER PRIMARY KEY,
Nom TEXT DEFAULT NULL nom TEXT NOT NULL,
[references] TEXT DEFAULT NULL
); );
insert into auteurs values
(3076,'Graham Masterton','https://www.noosfere.org/livres/auteur.asp?numauteur=19'),
(8222,'Stephen King','https://www.noosfere.org/livres/auteur.asp?NumAuteur=97'),
(9256,'Pierre Bordage','https://www.noosfere.org/livres/auteur.asp?NumAuteur=28'),
(9912,'Elif Şafak', 'https://www.babelio.com/auteur/Elif-Shafak/22574');
CREATE TABLE editeurs ( CREATE TABLE editeurs (
editeur_id INTEGER PRIMARY KEY, editeurId INTEGER PRIMARY KEY,
Nom TEXT nom TEXT NOT NULL
); );
insert into editeurs (nom) values
('L''Atalante'), ('J''Ai Lu'), ('10/18'), ('Viking'), ('Penguin Books'), ('Le Livre de Poche');
CREATE TABLE collections (
collectionId INTEGER PRIMARY KEY,
nom TEXT NOT NULL
);
insert into collections (nom) values
('Bibliothèque de l''évasion'), ('Science-Fiction');
CREATE TABLE series ( CREATE TABLE series (
serie_id INTEGER PRIMARY KEY, serieId INTEGER PRIMARY KEY,
Nom TEXT nom TEXT NOT NULL
); );
insert into series values
(1, 'Les Guerriers du silence');
-- ************************************************************
CREATE TABLE oeuvres ( CREATE TABLE oeuvres (
oeuvre_id INTEGER PRIMARY KEY, oeuvreId INTEGER PRIMARY KEY,
titre TEXT, titre TEXT,
isbn13 TEXT, langueCode TEXT REFERENCES langues (langue_code),
langue_code VARCHAR(5) REFERENCES langues (langue_code), publicationDate DATE,
num_pages INTEGER, genreId integer references genres (genreId),
publication_date DATE, serie_id integer references series (serie_id)
editeur_id INTEGER,
genre_id INTEGER,
serie_id INTEGER,
CONSTRAINT fk_oeuvre_editeur FOREIGN KEY (editeur_id) REFERENCES editeurs (editeur_id),
CONSTRAINT fk_oeuvre_genre FOREIGN KEY (genre_id) REFERENCES genres (genre_id),
CONSTRAINT fk_oeuvre_serie FOREIGN KEY (serie_id) REFERENCES series (serie_id)
); );
insert into oeuvres values
(1, 'Les Guerriers du silence','fr', 1993, 1, 1),
(2, 'Terra Mater', 'fr', 1994, 1, 1),
(3, 'La Citadelle Hyponéros', 'fr', 1995, 1, 1),
(4, 'The Forty Rules of Love', 'en', 2009, 3, NULL),
(5, 'Salem''s Lot', 'en', 1975, 2, NULL),
(6, 'The Shining', 'en', 1977, 2, NULL),
(7, 'The Stand', 'en', 1978, 2, NULL),
(8, 'The Long Walk', 'en', 1975, 2, NULL),
(9, 'Charlie', 'en', 1980, 2, NULL),
(10, 'IT', 'en', 1986, 2, NULL),
(11, 'The Stand: The Complete & Uncut Edition', 'en', 1990, 2, NULL),
(12, 'The Tommyknockers', 'en', 1987,2,NULL),
(13, 'Pet Sematary', 'en', 1983, 2,NULL),
(14, 'Chritine', 'en', 1983, 2,NULL),
(15, 'Firestarter', 'en', 1980, 2,NULL);
create table participe (
oeuvre_id INTEGER NOT NULL REFERENCES oeuvres (oeuvre_id),
auteur_id INTEGER NOT NULL REFERENCES auteurs (auteur_id),
fonction TEXT,
alias TEXT,
CONSTRAINT pk_oeuvreauteur PRIMARY KEY (oeuvre_id, auteur_id)
);
insert into participe values
(1, 8222, 'auteur', NULL), (2, 8222, 'auteur', NULL), (3, 8222, 'auteur', NULL),
(4, 9912, 'auteur', NULL),
(5, 8222, 'auteur', NULL),(6, 8222, 'auteur', NULL),(7, 8222, 'auteur', NULL),
(8, 8222, 'auteur', 'Richard Bachman'),(9, 8222, 'auteur', NULL),(10, 8222, 'auteur', NULL),
(11, 8222, 'auteur', NULL),(12, 8222, 'auteur', NULL),(13, 8222, 'auteur', NULL),
(14, 8222, 'auteur', NULL), (15, 8222, 'auteur', NULL);
CREATE TABLE editions ( CREATE TABLE editions (
edition_id INTEGER PRIMARY KEY, editionId INTEGER PRIMARY KEY,
oeuvre_id INTEGER REFERENCES oeuvres (oeuvre_id), editeurId INTEGER REFERENCES editeurs (editeurId),
editeur_id INTEGER REFERENCES editeurs (editeur_id),
isbn13 TEXT, isbn13 TEXT,
langue_code VARCHAR(5) REFERENCES langues (langue_code), langueCode TEXT REFERENCES langues (langueCode),
publication_date DATE, publication_date DATE,
num_pages INTEGER, num_pages INTEGER,
num_catalogue INTEGER titre TEXT,
informations TEXT informations TEXT
); );
insert into editions values
(1, 1, '978-2-9051-5869-7', 'fr', '1993-04-01', 704, 'Les Guerriers du silence', NULL),
(2, 1, '978-2-2903-1901-7', 'fr', '1994-05-01', 672, 'Terra Mater', NULL),
(3, 1, '978-2-2903-3137-8', 'fr', '1995-06-01', 720, 'La Citadelle Hyponéros', NULL),
(4, 4, '978-0-1410-4718-8', 'en', '2010-02-18', 354, 'The Forty Rules of Love', NULL),
(5, 3, '978-2-2640-5406-7', 'fr', '2011-08-18', 480, 'Soufi, mon amour', '{ "traducteur": "Dominique Letellier" }'),
(6, 2, '978-2-277-22326-3', 'fr', '1988-01-01', 576, 'Le Fléau', '{ "traducteur": "Richard Matas", "couverture": "Matthieu Blanchin", "catégorie": "6", "collection": "Épouvante", "num catalogue": 2326 }'),
(7, 2, '978-2-277-23311-0', 'fr', '1992-09-01', 512, 'Le Fléau - 1', '{ "traducteur": "Jean-Pierre Quijano", "couverture": "Matthieu Blanchin", "catégorie": "6", "collection": "Épouvante", "num catalogue": 3311 }'),
(8, 2, '978-2-277-23312-9', 'fr', '1992-09-01', 512, 'Le Fléau - 2', '{ "traducteur": "Jean-Pierre Quijano", "couverture": "Matthieu Blanchin", "catégorie": "6", "collection": "Épouvante", "num catalogue": 3312 }'),
(9, 2, '978-2-277-23313-7', 'fr', '1992-09-01', 512, 'Le Fléau - 3', '{ "traducteur": "Jean-Pierre Quijano", "couverture": "Matthieu Blanchin", "catégorie": "6", "collection": "Épouvante", "num catalogue": 3313 }'),
(10, 6, '978-2-253-15141-8', 'fr', '2003-08-01', 768, 'Le Fléau - 1', '{ "traducteur": "Jean-Pierre Quijano", "couverture": "Philippe Brault", "num catalogue": 15141 }'),
(11, 6, '978-2-253-15142-4', 'fr', '2003-08-01', 800, 'Le Fléau - 2', '{ "traducteur": "Jean-Pierre Quijano", "couverture": "Philippe Brault", "num catalogue": 15142 }')
;
CREATE TABLE incorpore (
oeuvreId INTEGER NOT NULL REFERENCES oeuvres (oeuvreId),
editionId INTEGER NOT NULL REFERENCES editions (editionId),
CONSTRAINT pk_oeuvreauteur PRIMARY KEY (oeuvreId, editionId)
);
insert into incorpore values
(1, 1), (2, 2), (3, 3), (4, 4), (4, 5),
(7, 6), (11, 7), (11, 8), (11, 9), (11, 10), (11, 11);
CREATE TABLE exemplaires ( CREATE TABLE exemplaires (
exemplaire_id INTEGER PRIMARY KEY, exemplaireId INTEGER PRIMARY KEY,
edition_id INTEGER REFERENCES editions (edition_id), editionId INTEGER REFERENCES editions (edition_id),
date_achat DATE, date_achat DATE,
prix_achat NUMERIC, prix_achat NUMERIC,
etat TEXT etat TEXT
); );
CREATE TABLE relations ( insert into exemplaires values
reference_id INTEGER REFERENCES oeuvres (oeuvre_id), (1, 1, '1993-10-30', 22.71, 'bon'),
oeuvre_id INTEGER REFERENCES oeuvres (oeuvre_id), (2, 2, '1995-02-15', 22.71, 'bon'),
[type] TEXT, (3, 3, '1996-03-22', 22.71, 'bon'),
CONSTRAINT pk_relation PRIMARY KEY (reference_id, oeuvre_id) (4, 4, '2009-12-22', 15.45, 'bon'),
(5, 5, '2012-09-05', 8.69, 'bon'),
(6, 7, '1993-01-17', 7.50, 'bon'),
(7, 10, '2014-11-05', 8.00, 'bon'),
(8, 11, '2014-09-05', 8.00, 'bon');
-- ************************************************************
CREATE TABLE adherents (
adherentId INTEGER PRIMARY KEY,
prenom TEXT NOT NULL,
nom TEXT NOT NULL,
email TEXT,
naissance DATE,
statutId INTEGER REFERENCES statuts (statutId)
); );
CREATE TABLE genres (
genre_id INTEGER PRIMARY KEY,
genre TEXT
);
CREATE TABLE participe (
oeuvre_id INTEGER NOT NULL REFERENCES oeuvres (oeuvre_id),
auteur_id INTEGER NOT NULL REFERENCES auteurs (auteur_id),
fonction TEXT,
alias TEXT
CONSTRAINT pk_oeuvreauteur PRIMARY KEY (oeuvre_id, auteur_id)
);
CREATE TABLE incorpore (
oeuvre_id INTEGER NOT NULL REFERENCES oeuvres (oeuvre_id),
edition_id INTEGER NOT NULL REFERENCES editions (edition_id)
)
CREATE TABLE statuts (
statut_id INTEGER PRIMARY KEY,
statut TEXT
);
CREATE TABLE pays (
pays_id INTEGER PRIMARY KEY,
pays_name TEXT
);
CREATE TABLE adresses ( CREATE TABLE adresses (
adresse_id INTEGER PRIMARY KEY, adresseId INTEGER PRIMARY KEY,
numero TEXT, numero TEXT,
voie TEXT, voie TEXT,
ville TEXT, ville TEXT,
pays_id INTEGER REFERENCES pays (pays_id) pays_id INTEGER REFERENCES pays (pays_id)
); );
CREATE TABLE adherents ( CREATE TABLE adherent_adresse (
adherent_id INTEGER PRIMARY KEY, adherentId INTEGER NOT NULL,
prenom TEXT NOT NULL, adresseId INTEGER NOT NULL,
nom TEXT NOT NULL, statutId INTEGER,
email TEXT, CONSTRAINT pk_adherent_adresse PRIMARY KEY (adherentId, adresseId),
naissance CHAR(10), CONSTRAINT fk_aa_adherent FOREIGN KEY (adherentId) REFERENCES adherents (adherentId),
statut_id INTEGER, CONSTRAINT fk_aa_adresse FOREIGN KEY (adresseId) REFERENCES adresses (adresseId),
CONSTRAINT fk_a_statut FOREIGN KEY (statut_id) REFERENCES statuts (statut_id) CONSTRAINT fk_aa_statut FOREIGN KEY (statutId) REFERENCES statuts (statutId)
); );
CREATE TABLE adherent_adresse ( -- ************************************************************
adherent_id INTEGER NOT NULL,
adresse_id INTEGER NOT NULL,
statut_id INTEGER,
CONSTRAINT pk_adherent_adresse PRIMARY KEY (adherent_id, adresse_id),
CONSTRAINT fk_aa_adherent FOREIGN KEY (adherent_id) REFERENCES adherents (adherent_id),
CONSTRAINT fk_aa_adresse FOREIGN KEY (adresse_id) REFERENCES adresses (adresse_id),
CONSTRAINT fk_aa_statut FOREIGN KEY (statut_id) REFERENCES statuts (statut_id)
);
CREATE TABLE livraison_methode ( CREATE TABLE livraison_methode (
methode_id INTEGER PRIMARY KEY, methodeId INTEGER PRIMARY KEY,
methode_name TEXT, methode_name TEXT,
cout NUMERIC cout NUMERIC
); );
CREATE TABLE commande ( CREATE TABLE commande (
commande_id INTEGER PRIMARY KEY, commandeId INTEGER PRIMARY KEY,
commande_date DATETIME, commande_date DATETIME,
date_echeance DATE, date_echeance DATE,
adherent_id INTEGER REFERENCES adherents (adherent_id), adherentId INTEGER REFERENCES adherents (adherentId),
livraison_methode_id INTEGER REFERENCES livraison_methode (methode_id), livraison_methode_id INTEGER REFERENCES livraison_methode (methodeId),
dest_adresse_id INTEGER REFERENCES adresses (adresse_id) dest_adresseId INTEGER REFERENCES adresses (adresseId)
); );
CREATE TABLE commande_statut ( CREATE TABLE commande_statut (
statut_id INTEGER PRIMARY KEY, statutId INTEGER PRIMARY KEY,
statut_value TEXT statut_value TEXT
); );
CREATE TABLE commande_ligne ( CREATE TABLE commande_ligne (
ligne_id INTEGER PRIMARY KEY, ligne_id INTEGER PRIMARY KEY,
commande_id INTEGER REFERENCES commande (commande_id), commandeId INTEGER REFERENCES commande (commandeId),
exemplaire_id INTEGER REFERENCES exemplaires (exemplaire_id), exemplaire_id INTEGER REFERENCES exemplaires (exemplaire_id),
cout NUMERIC, cout NUMERIC,
date_retour DATETIME date_retour DATETIME
@@ -180,9 +259,10 @@ CREATE TABLE commande_ligne (
CREATE TABLE commande_historique ( CREATE TABLE commande_historique (
historique_id INTEGER PRIMARY KEY, historique_id INTEGER PRIMARY KEY,
commande_id INTEGER REFERENCES commande (commande_id), commandeId INTEGER REFERENCES commande (commandeId),
statut_id INTEGER REFERENCES commande_statut (statut_id), statutId INTEGER REFERENCES commande_statut (statutId),
statut_date DATETIME statut_date DATETIME
); );
-- *****
-- ************************************************************

15880
chinook.sql Normal file

File diff suppressed because it is too large Load Diff

372
jardin.sql Normal file
View File

@@ -0,0 +1,372 @@
drop table if exists jardin;
drop table if exists saison;
drop table if exists fermeture;
drop table if exists ferie;
drop table if exists profil;
drop table if exists cotisation;
drop table if exists adherent;
drop table if exists adhesion;
drop table if exists produit;
drop table if exists panier;
drop table if exists depot;
drop table if exists frequence;
drop table if exists preparation;
drop table if exists calendrier;
drop table if exists tournee;
drop table if exists distribution;
drop table if exists planning;
drop table if exists abonnement;
drop table if exists livraison;
select load_extension('mod_spatialite');
select InitSpatialMetaData();
--pragma
create table jardin
(
id integer primary key,
jardin text not null,
tva text,
adresse text,
code_postal text,
ville text,
contact text,
telephone text,
email text
);
select AddGeometryColumn('jardin', 'geom', 4326, 'POINT', 'XY');
insert into jardin (id, jardin, tva, adresse, code_postal, ville, geom, contact, telephone, email) values
(1,'jardin de Cocagne Thaon les Vosges','FR42400245775',
'Prairie Claudel','88150','Thaon-les-Vosges', MakePoint(6.427672, 48.2531016, 4326),
'Elvire Helle','0329316498','compta@jdc-thaon.fr');
/* Calendrier */
create table saison
(
id integer primary key,
jardin_id integer references jardin(id),
saison text not null,
date_debut date not null,
date_fin date not null
);
insert into saison (id,jardin_id,saison,date_debut,date_fin) values
(2009,1,'2009','2009-01-01','2009-12-31'),
(2010,1,'2010','2010-01-01','2010-12-31'),
(2011,1,'2011','2011-01-01','2011-12-31'),
(2012,1,'2012','2012-01-01','2012-12-31'),
(2013,1,'2013','2013-01-01','2013-12-31'),
(2014,1,'2014','2014-01-01','2014-12-31'),
(2015,1,'2015','2015-01-01','2015-12-31'),
(2016,1,'2016','2016-01-01','2016-12-31'),
(2017,1,'2017','2017-01-01','2017-12-31'),
(2018,1,'2018','2018-01-01','2018-12-31'),
(2019,1,'2019','2019-01-01','2019-12-31'),
(2020,1,'2020','2020-01-01','2020-12-31'),
(2021,1,'2021','2021-01-01','2021-12-31'),
(2022,1,'2022','2022-01-01','2022-12-31'),
(2023,1,'2023','2023-01-01','2023-12-31'),
(2024,1,'2024','2024-01-01','2024-12-31'),
(2025,1,'2025','2025-01-01','2025-12-31');
create table fermeture
(
id integer primary key,
saison_id integer not null references saison(id),
semaine integer not null
);
insert into fermeture (id,saison_id,semaine) values
(1,2020,52),
(2,2021,1),
(3,2021,52),
(4,2022,51),
(5,2022,52),
(6,2023,52),
(7,2024,1),
(8,2024,52),
(9,2025,1),
(10,2025,52);
create table ferie
(
id integer primary key,
saison_id integer not null references saison(id),
ferie text not null,
jour date not null
);
insert into ferie (id,saison_id,ferie,jour) values
(1,2025,'Lundi de Pâques','2025-04-21'),
(2,2025,'Fête du Travail','2025-05-01'),
(3,2025,'Victoire 1945','2025-05-08'),
(4,2025,'Ascension','2025-05-29'),
(5,2025,'Pentecôte','2025-06-09'),
(6,2025,'Fête nationale','2025-07-14'),
(7,2025,'Assomption','2025-08-15'),
(8,2025,'Toussaint','2025-11-01'),
(9,2025,'Armistice 1918','2025-11-11');
create table profil
(
id integer primary key,
profil text not null
);
insert into profil (id, profil) values
(1, 'adhérent'),
(2, 'non adhérent'),
(3, 'professionnel'),
(4, 'salarié');
create table cotisation
(
id integer primary key,
saison_id integer not null references saison(id),
profil_id integer not null references profil(id),
montant numeric(8, 2) not null
);
insert into cotisation (id, saison_id, profil_id, montant) values
(1,2025,1,15.0),
(2,2025,2,0.0),
(3,2025,3,100.0),
(4,2025,4,2.0);
create table adherent
(
id integer primary key,
adherent text not null,
profil_id integer not null references profil(id),
depot_id integer not null references depot(id),
email text,
telephone text,
date_sortie date
);
create table adhesion
(
id integer primary key,
adherent_id integer not null references adherent(id),
date_adhesion date not null,
montant numeric(8, 2) not null,
saison_id integer not null references saison(id)
);
create table depot
(
id integer not null primary key,
depot text not null,
capacite integer not null default 10,
adresse text,
code_postal text,
ville text
);
select AddGeometryColumn('depot', 'geom', 4326, 'POINT', 'XY');
insert into depot (id,depot,capacite,adresse,code_postal,ville,geom) values
(0,'Livraison à domicile',100, NULL, NULL, NULL, NULL),
(1,'Jardins de Cocagne',100,'Prairie Claudel','88150','Thaon-les-Vosges',MakePoint(6.427672, 48.2531016, 4326)),
(2,'Asso Étudiant Universitaire',20,'9 rue de la Louvière','88000','Épinal',MakePoint(6.4531588, 48.1723212, 4326)),
(3,'Conseil Départemental des Vosges',20,'8 rue de la Préfecture','88000','Épinal',MakePoint(6.4445154, 48.1721724, 4326)),
(4,'Asso Rhyzome',20,'15 rue des Jardiniers','88000','Épinal',MakePoint(6.452224, 48.1706099, 4326)),
(6,'Pharmacie Saint Nabord',20,'24 rue du Gal de Gaulle','88200','St Nabord',MakePoint(6.5807814, 48.0510352, 4326)),
(8,'Denninger',20,'36 bis rue de la Plaine','88190','Golbey',MakePoint(6.4426982, 48.1929337, 4326)),
(9,'3e Rive (Café Associatif)',20,'15 rue du Maréchal Lyautey','88000','Épinal',MakePoint(6.4457306, 48.177777, 4326)),
(10,'Crédit Agricole',20,'Allée des Érables','88000','Épinal',MakePoint(6.454908, 48.203990, 4326)),
(12,'Centre Léo Lagrange',60,'6 av. Salvador Allende','88000','Épinal',MakePoint(6.4599403, 48.1938105, 4326)),
(13,'Boulassel Docelles',20,'1 rue Moncey','88460','Docelles',MakePoint(6.6162166, 48.1460719, 4326)),
(14,'Ligue de lenseignement',40,'15 rue Général de Reffye','88000','Épinal',MakePoint(6.4323215, 48.1819469, 4326)),
(15,'Garage Renault- Station Service',20,'664 rue de la Gare','88550', 'Pouxeux',MakePoint(6.5760129, 48.1051197, 4326)),
(16,'Adinolfi',40,'7 allée des Primevères','88390','Les Forges',MakePoint(6.397633, 48.171791, 4326)),
(17,'Lecompte François',40,'24 route du Noirpré','88530','Le Tholy',MakePoint(6.7477787, 48.0812967, 4326)),
(18,'Papeterie Norske Skog',20,'ZI Route Charles Pellerin','88190','Golbey',MakePoint(6.423976, 48.208795, 4326)),
(19,'Botanic',20,'9 av. des Terres St Jean','88000','Épinal',MakePoint(6.4692286, 48.1891998, 4326)),
(20,'Pro & Cie',40,'7 rue de la République','88400','Gérardmer',MakePoint(6.877433, 48.074172, 4326)),
(21,'Mme Pierot Charmes',40,'15 rue Ste Barbe','88130','Charmes',MakePoint(6.2951122, 48.3777043, 4326)),
(25,'DVIS Epinal',20,'1 Rue de la Préfecture','88000','Épinal',MakePoint(6.44875, 48.172438, 4326)),
(26,'Peridon',20,'7 rue du Savron','88220','Raon-aux-Bois',MakePoint(6.5036466, 48.0504027, 4326)),
(31,'Chambre dAgriculture',20,'17 rue André Vitu','88000','Épinal',MakePoint(6.465403, 48.1775685, 4326)),
(34,'Biocoop',20,'7 rue du Boudiou','88000','Épinal',MakePoint(6.447245, 48.174228)),
(36,'Moustaches Bikes',20,'5 rue du Ruisseau','88150','Thaon-les-Vosges',MakePoint(6.4005773, 48.2576491)),
(38,'Vosgelis Remiremont',20,'4 place de lAbbaye','88200','Remiremont',MakePoint(6.592068, 48.015964)),
(42,'Église Saint Antoine',60,'12 rue Armand Colle','88000','Épinal',MakePoint(6.4489619, 48.1604568)),
(46,'Maison de lEnvironnement',20,'12 rue Raymond Poincaré','88000','Épinal',MakePoint(6.449693, 48.175374, 4326)),
(48,'Vosgelis',20,'8 quai Barbier','88000','Épinal',MakePoint(6.445190, 48.171198, 4326)),
(50,'Association GACI',20,'26 rue de la Joncherie','88200','Remiremont',MakePoint(6.5934293, 48.0189339, 4326)),
(55,'Brico Marché',20,'2 rue de Fraisne','88600','Bruyères',MakePoint(6.7196903, 48.2050495, 4326)),
(57,'Office du tourisme',20,'6 place C. Poncelet','88200','Remiremont',MakePoint(6.5917178, 48.0159918, 4326)),
(60,'Point Vert Mafra',20,'5 rue des Résistants Zac Barbazan','88600','Bruyères',MakePoint(6.7208371, 48.2032056, 4326)),
(61,'La quarterelle',20,'3 rue Carterelle','88200','Épinal',MakePoint(6.7208371, 48.2032056, 4326)),
(62,'Léo Lagrange',20,'Chemin du Tambour Major','88000','Épinal',MakePoint(6.7208371, 48.2032056, 4326)),
(65,'Bouvier Emmanuel',20,'557 rue du Chêne','88220','Hadol',MakePoint(6.484004, 48.108499, 4326)),
(75,'APF - Local extérieur ESAT',20,'rue de la papeterie','88000','Dinozé',MakePoint(6.4738942, 48.1383687, 4326)),
(77,'La tête à Toto',20,'26 quai des Bons Enfants','88000','Épinal',MakePoint(6.4409549, 48.1748623, 4326)),
(78,'UIMM',20,'Label Initiative','88150','Thaon les Vosges',MakePoint(6.4409549, 48.1748623, 4326)),
(80,'Résidence du Monsey',20,'Ruelle de Monsey', '88450', 'Vincey', MakePoint(6.330850, 48.337907, 4326)),
(81,'Complexe Sportif',40,'Bld Georges Clemenceau','88130','Charmes',MakePoint(6.298452, 48.375298, 4326)),
(83,'Fives',20,'2 rue des Amériques','88190','Golbey',MakePoint(6.428831, 48.200150, 4326)),
(84,'Nomexy Secours Catholique',20,'1 place de Verdun', '88440', 'Nomexy', MakePoint(6.386527, 48.305704, 4326));
create table produit
(
id integer primary key,
produit text not null,
prix numeric(8, 2) not null,
marge numeric(8, 2) not null
);
insert into produit values
(1,'Panier simple',13.80,40.0),
(2,'Panier familial',23.70,40.0),
(3,'Panier fruité 1',14.00,70.0),
(4,'Panier fruité 3',23.00,70.0),
(5,'Panier fruité 2',17.00,70.0),
(6,'Oeufs x6',3.05,50.0),
(7,'Panier fruité entreprise',23.50,70.0);
create table frequence
(
id integer primary key,
frequence text not null
);
insert into frequence (id,frequence) values
(1,'hebdomadaire'),
(2,'15 jours'),
(3,'libre');
create table panier
(
id integer primary key,
produit_id integer not null references produit(id),
panier text not null,
frequence_id integer not null references frequence(id),
quantite integer not null,
prix numeric(8, 2) not null
);
insert into panier (id,produit_id,panier,frequence_id,quantite,prix) values
(1,1,'Panier simple hebdomadaire',1,50,690.0),
(2,1,'Panier simple 15 jours',2,25,404.0),
(3,2,'Panier familial hebdomadaire',1,50,1185.0),
(4,2,'Panier familial 15 jours',2,25,658.0),
(5,1,'Panier simple unité',3,1,13.8),
(6,2,'Panier familial unité',3,1,23.7),
(7,1,'Panier solidaire',3,1,2.5),
(8,3,'Panier fruité 1',3,1,14.0),
(9,4,'Panier fruité 2',3,1,17.0),
(10,5,'Panier fruité 3',3,1,23.0),
(11,6,'Oeufs x6',3,1,3.05),
(12,7,'Panier fruité 4',3,1,23.5);
insert into panier (id,produit_id,panier,frequence_id,quantite,prix) values
(13,1,'Panier simple hebdomadaire à domicile',1,50,894.0),
(14,1,'Panier simple 15 jours à domicile',2,25,497.0),
(15,1,'Panier familial hebdomadaire à domicile',1,50,894.0),
(16,1,'Panier familial 15 jours à domicile',2,25,497.0),
(17,1,'Panier simple soutien x12',1,12,196.0),
(18,1,'Panier simple soutien x6',2,6,98.0),
(19,1,'Panier familial soutien x12',1,12,196.0),
(20,1,'Panier familial soutien x6',2,6,98.0);
create table preparation
(
id integer primary key,
preparation text not null,
jour integer not null
);
insert into preparation (id,preparation,jour) values
(1,'Mardi',1),
(2,'Jeudi',3);
create table calendrier
(
id integer primary key,
saison_id integer not null references saison(id),
calendrier text not null
);
insert into calendrier (id,saison_id,calendrier) values
(1,2025,'Livraisons du mardi'),
(2,2025,'Livraisons du mercredi'),
(3,2025,'Livraisons du jeudi'),
(4,2025,'Livraisons du vendredi');
create table tournee
(
id integer primary key,
tournee text,
preparation_id integer not null references preparation(id),
calendrier_id integer not null references calendrier(id),
ordre integer not null,
couleur text not null
);
insert into tournee values
(1,'Mardi (Épinal)',1,1,1,'yellow'),
(2,'Mardi (Jardins)',1,1,2,'orange'),
(3,'Mercredi matin',1,2,3,'red'),
(4,'Mercredi après-midi',1,2,4,'pink'),
(5,'Mercredi (Jardins)',1,2,6,'purple'),
(6,'Jeudi (Salariés)',2,3,8,'indigo'),
(7,'Vendredi (Épinal)',2,4,9,'azure'),
(8,'Vendredi (Jardins)',2,4,12,'lime'),
(9,'Jeudi (Charmes)',2,3,7,'green'),
(10,'Vendredi (Gérardmer)',2,4,10,'maroon'),
(11,'Mercredi (Ent.)',1,2,5,'gray-700'),
(12,'Vendredi (Ent.)',2,4,11,'khaki');
create table distribution
(
id integer primary key,
distribution text not null,
tournee_id integer not null references tournee(id),
depot_id integer,
adherent_id integer,
ordre integer not null
);
create table planning
(
id integer primary key,
calendrier_id integer not null references calendrier(id),
jour date not null
);
create table abonnement
(
id integer primary key,
adherent_id integer not null references adherent(id),
panier_id integer,
date_debut date not null,
nombre integer not null,
montant numeric(8, 2) not null,
mode_paiement_id integer null,
saison_id integer null references saison(id)
);
create table livraison
(
id integer primary key,
abonnement_id integer not null references abonnement(id),
distribution_id integer not null references distribution(id),
produit_id integer not null references produit(id),
qte integer not null default 1,
livre etat_livraison not null default 'à livrer',
planning_id integer not null references planning(id)
);