-- -- Users Table
-- CREATE TABLE users (
--     uid INT AUTO_INCREMENT PRIMARY KEY,
--     username VARCHAR(50) NOT NULL,
--     email VARCHAR(100) NOT NULL UNIQUE,
--     password_hash VARCHAR(255) NOT NULL,  -- store a hashed password, never plain text
--     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
-- );

-- -- Media Types Table (e.g., Film, Music)
-- CREATE TABLE media_types (
--     tid INT AUTO_INCREMENT PRIMARY KEY,
--     type_name VARCHAR(50) NOT NULL
-- );

-- -- Media Table
-- CREATE TABLE media (
--     mid INT AUTO_INCREMENT PRIMARY KEY,
--     uid INT NOT NULL,
--     tid INT NOT NULL,
--     name VARCHAR(100) NOT NULL,
--     length INT,
--     watched_count INT DEFAULT 0,
--     favorite BOOLEAN DEFAULT 0,
--     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
--     FOREIGN KEY (uid) REFERENCES users(uid) ON DELETE CASCADE,
--     FOREIGN KEY (tid) REFERENCES media_types(tid) ON DELETE CASCADE
-- );

-- -- Preferences Table
-- CREATE TABLE preferences (
--     pid INT AUTO_INCREMENT PRIMARY KEY,
--     uid INT NOT NULL,
--     theme_mode TINYINT(1) DEFAULT 0,   -- 0 = Light, 1 = Dark
--     preferred_path VARCHAR(255),
--     device_name VARCHAR(100),
--     FOREIGN KEY (uid) REFERENCES users(uid) ON DELETE CASCADE
-- );

-- -- Playlists Table (Future feature: Group media items into playlists)
-- CREATE TABLE playlists (
--     plid INT AUTO_INCREMENT PRIMARY KEY,
--     uid INT NOT NULL,
--     name VARCHAR(100) NOT NULL,
--     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
--     FOREIGN KEY (uid) REFERENCES users(uid) ON DELETE CASCADE
-- );

-- -- Playlist Items Table (Many-to-Many relation: media in playlists)
-- CREATE TABLE playlist_items (
--     plid INT NOT NULL,
--     mid INT NOT NULL,
--     added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
--     PRIMARY KEY (plid, mid),
--     FOREIGN KEY (plid) REFERENCES playlists(plid) ON DELETE CASCADE,
--     FOREIGN KEY (mid) REFERENCES media(mid) ON DELETE CASCADE
-- );