<reponame>TheNewThinkTank/sqlite-app<filename>SQLiteAPP/Command/SQL_statements/create.py<gh_stars>1-10

create_tables = {"create_users_table": """
                CREATE TABLE IF NOT EXISTS users (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                name TEXT NOT NULL,
                age INTEGER,
                gender TEXT,
                nationality TEXT
                );
                """,
                 "create_posts_table": """
                CREATE TABLE IF NOT EXISTS posts(
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                title TEXT NOT NULL,
                description TEXT NOT NULL,
                user_id INTEGER NOT NULL,
                FOREIGN KEY (user_id) REFERENCES users (id)
                );
                """,
                 "create_comments_table": """
                    CREATE TABLE IF NOT EXISTS comments (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    text TEXT NOT NULL,
                    user_id INTEGER NOT NULL,
                    post_id INTEGER NOT NULL,
                    FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)
                    );
                    """,
                 "create_likes_table": """
                    CREATE TABLE IF NOT EXISTS likes (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    user_id INTEGER NOT NULL,
                    post_id integer NOT NULL,
                    FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)
                    );
                    """
                 }

create_tables = {"create_users_table": """
                CREATE TABLE IF NOT EXISTS users (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                name TEXT NOT NULL,
                age INTEGER,
                gender TEXT,
                nationality TEXT
                );
                """,
                 "create_posts_table": """
                CREATE TABLE IF NOT EXISTS posts(
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                title TEXT NOT NULL,
                description TEXT NOT NULL,
                user_id INTEGER NOT NULL,
                FOREIGN KEY (user_id) REFERENCES users (id)
                );
                """,
                 "create_comments_table": """
                    CREATE TABLE IF NOT EXISTS comments (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    text TEXT NOT NULL,
                    user_id INTEGER NOT NULL,
                    post_id INTEGER NOT NULL,
                    FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)
                    );
                    """,
                 "create_likes_table": """
                    CREATE TABLE IF NOT EXISTS likes (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    user_id INTEGER NOT NULL,
                    post_id integer NOT NULL,
                    FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)
                    );
                    """
                 }
CREATE TABLE IF NOT EXISTS users (                 id INTEGER PRIMARY KEY AUTOINCREMENT,                 name TEXT NOT NULL,                 age INTEGER,                 gender TEXT,                 nationality TEXT                 ); CREATE TABLE IF NOT EXISTS posts(                 id INTEGER PRIMARY KEY AUTOINCREMENT,                 title TEXT NOT NULL,                 description TEXT NOT NULL,                 user_id INTEGER NOT NULL,                 FOREIGN KEY (user_id) REFERENCES users (id)                 ); CREATE TABLE IF NOT EXISTS comments (                     id INTEGER PRIMARY KEY AUTOINCREMENT,                     text TEXT NOT NULL,                     user_id INTEGER NOT NULL,                     post_id INTEGER NOT NULL,                     FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)                     ); CREATE TABLE IF NOT EXISTS likes (                     id INTEGER PRIMARY KEY AUTOINCREMENT,                     user_id INTEGER NOT NULL,                     post_id integer NOT NULL,                     FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (post_id) REFERENCES posts (id)                     );