From d7e768641c12e963a9ae136705762fa07a8feefc Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Wed, 4 Sep 2019 18:35:29 -0400 Subject: [PATCH] Ammunition sourceEntry conversion --- data/ammunition.sql | 33 +++++++++++++++++++++++++++++---- schema/ammunition.sql | 15 +++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/data/ammunition.sql b/data/ammunition.sql index 9750470..9ba5d54 100644 --- a/data/ammunition.sql +++ b/data/ammunition.sql @@ -4,8 +4,33 @@ PRAGMA foreign_keys = ON; -- database requires foreign key checking to be turned -- on PER CONNECTION BEGIN TRANSACTION; -INSERT INTO ammunition VALUES(1,1,'282','Arrows',0.1,10,0.1,'These projectiles are the ammunition for bows. The shaft of an arrow is made of wood. It is stabilized in flight by fletching at one end and bears a metal head on the other.'); -INSERT INTO ammunition VALUES(2,1,'281','Blowgun Darts',0.05,10,0.1,'These thin, light darts are typically made of hardwood and stabilized with fletching of down or fur. They are often hollow so they can be used to deliver poison.'); -INSERT INTO ammunition VALUES(3,1,'281','Bolts',0.1,10,0.1,'Shorter than traditional arrows but similar in construction, bolts are the ammunition used by crossbows.'); -INSERT INTO ammunition VALUES(4,1,'281','Sling Bullets',0.01,10,0.1,'These are small metal balls, typically either iron or lead, designed to be used as ammunition in slings.'); +INSERT INTO ammunition () +VALUES(1,'Arrows',0.1,10,0.1,'These projectiles are the ammunition for bows. The shaft of an arrow is made of wood. It is stabilized in flight by fletching at one end and bears a metal head on the other.'); +INSERT INTO ammunition VALUES(2,'Blowgun Darts',0.05,10,0.1,'These thin, light darts are typically made of hardwood and stabilized with fletching of down or fur. They are often hollow so they can be used to deliver poison.'); +INSERT INTO ammunition VALUES(3,'Bolts',0.1,10,0.1,'Shorter than traditional arrows but similar in construction, bolts are the ammunition used by crossbows.'); +INSERT INTO ammunition VALUES(4,'Sling Bullets',0.01,10,0.1,'These are small metal balls, typically either iron or lead, designed to be used as ammunition in slings.'); + +INSERT INTO sourceentries ( + sourceentry_id + ,sources_id + ,page_start + ,page_stop +) +VALUES + -- 50 to 99 is reserved for ammunition -- + (50, 1, 282, 282) -- Arrows -- + (51, 1, 281, 281) -- Blowgun darts, Bolts, Sling bullets -- +; + +INSERT INTO ammunition_sourceentries ( + id + ,ammunition_id + ,sourceentry_id +) +VALUES + (1, 1, 50) -- Arrows -- + (2, 2, 51) -- Blowgun darts -- + (3, 3, 51) -- Bolts -- + (4, 4, 51) -- Sling bullets -- +; COMMIT; diff --git a/schema/ammunition.sql b/schema/ammunition.sql index 48d1cd4..8e2c291 100644 --- a/schema/ammunition.sql +++ b/schema/ammunition.sql @@ -5,12 +5,19 @@ PRAGMA foreign_keys = ON; -- database requires foreign key checking to be turned CREATE TABLE ammunition ( ammunition_id INTEGER PRIMARY KEY, - sources_id INTEGER, - sources_pages TEXT, "name" TEXT NOT NULL UNIQUE, price_gp REAL, amount INTEGER, bulk REAL, descr TEXT, - FOREIGN KEY (sources_id) REFERENCES sources(sources_id) -) +); + +-- Joining table -- +CREATE TABLE ammunition_sourceentries ( + id INTEGER PRIMARY KEY + ,ammunition_id INTEGER NOT NULL + ,sourceentry_id INTEGER NOT NULL + ,UNIQUE (id, ammunition_id, sourceentry_id), + ,FOREIGN KEY (ammunition_id) REFERENCES ammunition(ammunition_id) + ,FOREIGN KEY (sourceentry_id) REFERENCES sourceentry(sourceentry_id) +); \ No newline at end of file