I want my primary key to allow certain duplicate entries, how do I write this? I want a song to be allowed to have multiple genres.
CREATE TABLE songs (
songid INTEGER PRIMARY KEY,
title TEXT
)
CREATE TABLE genres (
genreid INTEGER PRIMARY KEY,
name TEXT
CREATE TABLE has_a_genre (
songid INTEGER,
genreid INTEGER,
FOREIGN KEY (songid) REFERENCES songs (songid),
FOREIGN KEY (genreid) REFERENCES genres (genreid)
)
This is a snippet of the code im working on. This code doesn't take a duplicate entry value. Let's say we input these values into the database: Genres (genreid, name) 1, rock 2, country 3, pop 4, electronic
Songs
(songid, title)
10001, Tomorrow
10002, Sweet Child O' Mine
10003, Faded
When I input in has_a_genre
(songid, genreid)
10001, 2
10002, 1
10003, 4
10003, 4
This doesn't work because my current code doesn't allow for multiple inputs of 10003, 4 How do I make it allow this?