118 lines
4.4 KiB
SQL
118 lines
4.4 KiB
SQL
CREATE TABLE users
|
|
(
|
|
id SERIAL PRIMARY KEY,
|
|
username VARCHAR(255) UNIQUE NOT NULL,
|
|
password VARCHAR(255) NOT NULL,
|
|
email VARCHAR(255) UNIQUE NOT NULL,
|
|
role VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMP NOT NULL,
|
|
updated_at TIMESTAMP NOT NULL
|
|
);
|
|
|
|
CREATE TABLE user_logins
|
|
(
|
|
id SERIAL PRIMARY KEY,
|
|
user_id BIGINT NOT NULL,
|
|
login_time TIMESTAMP NOT NULL,
|
|
login_ip VARCHAR(255) NOT NULL,
|
|
FOREIGN KEY (user_id) REFERENCES users (id)
|
|
);
|
|
|
|
CREATE TABLE bible_reading_plans
|
|
(
|
|
id SERIAL PRIMARY KEY,
|
|
plan_name VARCHAR(255) NOT NULL,
|
|
start_date TIMESTAMP NOT NULL,
|
|
chapter_per_day SMALLINT NOT NULL CHECK (chapter_per_day > 0),
|
|
creator_user_id BIGINT NOT NULL,
|
|
FOREIGN KEY (creator_user_id) REFERENCES users (id)
|
|
);
|
|
|
|
CREATE TABLE bible_books
|
|
(
|
|
id SERIAL PRIMARY KEY,
|
|
book_name_en VARCHAR(255) NOT NULL,
|
|
book_name_de VARCHAR(255) NOT NULL,
|
|
chapter_count INT NOT NULL CHECK (chapter_count > 0),
|
|
is_new_testament BOOLEAN NOT NULL
|
|
);
|
|
|
|
CREATE TABLE user_statistics
|
|
(
|
|
id SERIAL PRIMARY KEY,
|
|
user_id BIGINT NOT NULL,
|
|
current_book_id BIGINT,
|
|
current_chapter_id BIGINT,
|
|
bible_reading_plan_id BIGINT,
|
|
FOREIGN KEY (bible_reading_plan_id) REFERENCES bible_reading_plans (id),
|
|
FOREIGN KEY (current_chapter_id) REFERENCES bible_books (id),
|
|
FOREIGN KEY (user_id) REFERENCES users (id)
|
|
);
|
|
|
|
INSERT INTO bible_books (book_name_en, book_name_de, chapter_count, is_new_testament)
|
|
VALUES ('Genesis', '1. Mose (Genesis)', 50, FALSE),
|
|
('Exodus', '2. Mose (Exodus)', 40, FALSE),
|
|
('Leviticus', '3. Mose (Levitikus)', 27, FALSE),
|
|
('Numbers', '4. Mose (Numeri)', 36, FALSE),
|
|
('Deuteronomy', '5. Mose (Deuteronomium)', 34, FALSE),
|
|
('Joshua', 'Josua', 24, FALSE),
|
|
('Judges', 'Richter', 21, FALSE),
|
|
('Ruth', 'Ruth', 4, FALSE),
|
|
('1. Samuel', '1. Samuel', 31, FALSE),
|
|
('2. Samuel', '2. Samuel', 24, FALSE),
|
|
('1. Kings', '1. Könige', 22, FALSE),
|
|
('2. Kings', '2. Könige', 25, FALSE),
|
|
('1. Chronicles', '1. Chronik', 29, FALSE),
|
|
('2. Chronicles', '2. Chronik', 36, FALSE),
|
|
('Ezra', 'Esra', 10, FALSE),
|
|
('Nehemiah', 'Nehemia', 13, FALSE),
|
|
('Esther', 'Ester', 10, FALSE),
|
|
('Job', 'Hiob', 42, FALSE),
|
|
('Psalms', 'Psalmen', 150, FALSE),
|
|
('Proverbs', 'Sprüche', 31, FALSE),
|
|
('Ecclesiastes', 'Prediger', 12, FALSE),
|
|
('Song of Solomon', 'Hohelied', 8, FALSE),
|
|
('Isaiah', 'Jesaja', 66, FALSE),
|
|
('Jeremiah', 'Jeremia', 52, FALSE),
|
|
('Lamentations', 'Klagelieder', 5, FALSE),
|
|
('Ezekiel', 'Hesekiel', 48, FALSE),
|
|
('Daniel', 'Daniel', 12, FALSE),
|
|
('Hosea', 'Hosea', 14, FALSE),
|
|
('Joel', 'Joel', 3, FALSE),
|
|
('Amos', 'Amos', 9, FALSE),
|
|
('Obadiah', 'Obadja', 1, FALSE),
|
|
('Jonah', 'Jona', 4, FALSE),
|
|
('Micah', 'Micha', 7, FALSE),
|
|
('Nahum', 'Nahum', 3, FALSE),
|
|
('Habakkuk', 'Habakuk', 3, FALSE),
|
|
('Zephaniah', 'Zefanja', 3, FALSE),
|
|
('Haggai', 'Haggai', 2, FALSE),
|
|
('Zechariah', 'Sacharja', 14, FALSE),
|
|
('Malachi', 'Maleachi', 4, FALSE),
|
|
('Matthew', 'Matthäus', 28, TRUE),
|
|
('Mark', 'Markus', 16, TRUE),
|
|
('Luke', 'Lukas', 24, TRUE),
|
|
('John', 'Johannes', 21, TRUE),
|
|
('Acts', 'Apostelgeschichte', 28, TRUE),
|
|
('Romans', 'Römer', 16, TRUE),
|
|
('1. Corinthians', '1. Korinther', 16, TRUE),
|
|
('2. Corinthians', '2. Korinther', 13, TRUE),
|
|
('Galatians', 'Galater', 6, TRUE),
|
|
('Ephesians', 'Epheser', 6, TRUE),
|
|
('Philippians', 'Philipper', 4, TRUE),
|
|
('Colossians', 'Kolosser', 4, TRUE),
|
|
('1. Thessalonians', '1. Thessalonicher', 5, TRUE),
|
|
('2. Thessalonians', '2. Thessalonicher', 3, TRUE),
|
|
('1. Timothy', '1. Timotheus', 6, TRUE),
|
|
('2. Timothy', '2. Timotheus', 4, TRUE),
|
|
('Titus', 'Titus', 3, TRUE),
|
|
('Philemon', 'Philemon', 1, TRUE),
|
|
('Hebrews', 'Hebräer', 13, TRUE),
|
|
('James', 'Jakobus', 5, TRUE),
|
|
('1. Peter', '1. Petrus', 5, TRUE),
|
|
('2. Peter', '2. Petrus', 3, TRUE),
|
|
('1. John', '1. Johannes', 5, TRUE),
|
|
('2. John', '2. Johannes', 1, TRUE),
|
|
('3. John', '3. Johannes', 1, TRUE),
|
|
('Jude', 'Judas', 1, TRUE),
|
|
('Revelation', 'Offenbarung', 22, TRUE); |