create join table topic_cards

master
grgr 2 years ago
parent 8f7f127937
commit c61e813f72

@ -17,6 +17,10 @@ cur.execute("INSERT INTO cards (category_id, content) VALUES (?,?)",
cur.execute("INSERT INTO cards (category_id, content) VALUES (?,?)",
(1, 'This is not an Atlas'))
cur.execute("INSERT INTO topics (content) VALUES (?)", ('mapping process',))
cur.execute("INSERT INTO topics (content) VALUES (?)", ('Radical Neutrality',))
cur.execute("INSERT INTO topics (content) VALUES (?)", ('Honeycomb documentation',))
cur.execute("INSERT INTO topics (content) VALUES (?)", ('Metabolic Publishing',))
# close conenction
connection.commit()

Binary file not shown.

@ -1,12 +1,12 @@
DROP TABLE IF EXISTS categories; -- is a list of categories(lists): type: reading_list, authors, notes, etc it's a type but type is also a keyword in python so better avoiding it
DROP TABLE IF EXISTS cards; --the single entry of any category/type
DROP TABLE IF EXISTS topics; -- test table weaved on measure for this test
-- table creation
CREATE TABLE categories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
title TEXT NOT NULL
title TEXT NOT NULL -- remember to not write the comma here at the end of each table
);
CREATE TABLE cards (
@ -15,4 +15,22 @@ CREATE TABLE cards (
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
content TEXT NOT NULL,
FOREIGN KEY (category_id) REFERENCES categories (id)
);
);
-- CREATE TABLE relations (
-- id INTEGER PRIMARY KEY AUTOINCREMENT,
-- )
CREATE TABLE topics (
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT NOT NULL
);
-- join table cards-topic but will i need also topic-card?? having a table of relations would maybe be a better approach? and a table of actions? (like upload file)
CREATE TABLE topic_cards (
id INTEGER NOT NULL,
topic_id INTEGER,
card_id INTEGER,
FOREIGN KEY (topic_id) REFERENCES topics(id)
FOREIGN KEY (card_id) REFERENCES cards(id)
)
Loading…
Cancel
Save