Search code examples
mysqlmysql-helper

MYSQL UPDATES, DELETES, INSERTS, CREATE clauses


I'm trying to create a database schema for Game achievements which should include these:

Users: username, avatar image file location, achievements their received in each game

Each achievement has achievement name achievement level
achievement type a game that achievement was part of. Each achievement is specific per game. You can’t have the same achievement across different games

Each game has a title and game type.

It also must have clear relationship definitions (crow’s feet for 1 to many), primary key and foreign keys should be marked.

I've started it but I'm not sure if I did it right and I'm not really sure which of the information types are supposed to be primary keys and which supposed to be foreign keys

The image shows what I have so far and where I'm stuck (stuck on the keys) database schema for Game achievements

So this is what I've gotten now after some comments had explained a bit of this for me database schema for Game achievements with foreign keys relationship

But I'm still not really sure if I did these foreign keys correctly database schema for Game achievements fk for game database schema for Game achievements fk for achievement


Solution

  • Primary keys must be unique value, You should give appropriate primary keys for each, as:

    Users: user_id,

    games: game_id,

    achievements: achievement_id,

    Then you can specify the foreign keys accordingly, like in achievements, user_id, and game_id will be foreign keys.