In a DB there's a table called decks which looks like this:
ID | Name
------------
1 | Deck 1
2 | Deck 2
3 | Deck 3
And then another table called words which should look like this
Deck ID | Word ID | Text
-------------------------------
1 | 1 | Cat
2 | 1 | Elephant
1 | 2 | Dog
1 | 3 | Elephant
3 | 1 | Shark
So basically this table should have a Foreign Key which points to the deck and then a key which is set to auto-increment according to the foreign key. Also, note that the ID of this table would be the combination of Deck Id and Word Id. Is this possible in MYSQL 8?
Basically what I have is this:
CREATE TABLE my_db.words (
deck_id INT,
text VARCHAR(100),
FOREIGN KEY(deck_id) REFERENCES decks(id)
);
But no idea how to create this auto-increment field.
Not sure if it's important but the text column should have no effect whatsoever in the result of this generated ID.