You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.4 KiB
SQL
37 lines
1.4 KiB
SQL
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
|
|
DROP TABLE IF EXISTS topic_cards;
|
|
|
|
-- table creation
|
|
CREATE TABLE categories (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
category_name TEXT NOT NULL -- remember to not write the comma here at the end of each table
|
|
);
|
|
|
|
CREATE TABLE cards (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
category_id INTEGER NOT NULL,
|
|
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 PRIMARY KEY AUTOINCREMENT,
|
|
topic_id INTEGER,
|
|
card_id INTEGER,
|
|
FOREIGN KEY (topic_id) REFERENCES topics(id),
|
|
FOREIGN KEY (card_id) REFERENCES cards(id)
|
|
) |