-1

I have to normalize my database up to BCNF but I'm a little bit confused about 1NF.

My main table is about video games and it looks like this:

game_id(PK, AI)    title    developer_id(FK)    publisher_id(FK)    genre                   modes                               release_date  
    1              XYZ          3                   5               FPS, Battle Royale      Single-player, multiplayer          2019-02-04

My confusion is about the "modes" and "genre" columns because sometimes I have more than one value so it's not atomic, right? This comment says the same Explain Like I am Five -> How a Primary Key Satisfies First Normal Form BUT the comment right below him says the opposite...

I've read about normalization and I found this example of a table in 1NF. Looking back at my table, I realized I can't do the same because I have an 'id' which is a PK so it can't have duplicate values. Other sources say that once you have a PK it means that the table is in 1NF because all rows are different.

I'm thinking about creating another two tables where I store only the 'modes' which are (Single-player/Multiplayer/Single-player, multiplayer) and the 'genres'. But, how would I insert the 'mode_id' as an FK in the 'game' table if, again, a game has only one 'id' which is also a PK?

Then I guess it also satisfies NF2? And for NF3 I should create two more tables where I store the n-m relationships between games-modes and games-genres...

I'd be glad if anyone wants to look at my whole database (it's small and simple) and tell me where I should apply normalization. Thank you!

Kerox
  • 590
  • 1
  • 8
  • 14
  • Please [use text, not images/links, for text--including tables & ERDs](https://meta.stackoverflow.com/q/285551/3404097). Paraphrase or quote from other text. Give just what you need & relate it to your problem. Use images only for what cannot be expressed as text or to augment text. Insert images/links using edit functions. Make your post self-contained. SO/SE comments can be deleted at any time. ["1NF" has no single meaning.](https://stackoverflow.com/a/40640962/3404097) Nor for that matter "relation". So you need to tell us your definitions & preferably also textbook name & edition. – philipxy Jun 16 '20 at 23:11
  • What is your 1 question? PS Right now you are just asking for us to rewrite your textbook with a bespoke tutorial. Please see [ask], hits googling 'stackexchange homework' & the voting arrow mouseover texts. Show the steps of your work following your textbook with justification & ask 1 specific researched non-duplicate question re the first place you are stuck. Quote definitions & algorithms you rely on. Also all steps are SO faqs; but there are many poor & confused answers. And you must know *your* "1NF"--see my post at your linked comment! PS "review my design" is not a valid SO question. – philipxy Jun 17 '20 at 00:00

1 Answers1

1

The comment you linked is correct, the comment below that is wrong.

1NF says that each attribute needs to be atomic (which is usually meant semantically, not technically. Technically, the string "FPS, Battle Royale" is as atomic as any other, because technically any string is as atomic as any other.

But 1NF is meant semantically: you should not store multiple values in a single column of a single row.

The easiest way to make your table 1NF is just to transform it into

game_id(PK, AI)    title    developer_id(FK)    publisher_id(FK)    genre          modes                               release_date  
1                  xyz      3                   5                   FPS            Single-player          2019-02-04
1                  xyz      3                   5                   FPS            multiplayer          2019-02-04
1                  xyz      3                   5                   Battle Royale  Single-player          2019-02-04
1                  xyz      3                   5                   Battle Royale  multiplayer          2019-02-04

Of course, this is only 1NF. Fully normalized, it should be something along:

table GAMES
game_id(PK, AI)    title    developer_id(FK)    publisher_id(FK)    release_date  
1                  xyz      3                   5                   2019-02-04

table GENRES
genre_id(PK)       name
1                  FPS
2                  Battle Royale

table MODES
mode_id(PK)        name
1                  Single-player
2                  multiplayer

table GAME_GENRE
id      game_id      genre_id
1       1            1
2       1            2

table GAME_MODE
id      game_id      mode_id
1       1            1
2       1            2

``




Stefan Winkler
  • 3,871
  • 1
  • 18
  • 35
  • but how could I insert another row with the same 'game_id' if it's a PK? – Kerox Jun 16 '20 at 14:25
  • do I have to turn my PK into a Composite Key? I did this, my key is now made from 'game_id', 'genre', and 'modes' columns and I can insert multiple rows with the same id now. This is what I needed to know in the first place. – Kerox Jun 16 '20 at 17:00
  • Yes, exactly. If you‘d only keep the 1NF then you‘d use a composite key. – Stefan Winkler Jun 16 '20 at 18:13
  • well I have to go up to BCNF so now I think I have to remove the composite key – Kerox Jun 16 '20 at 18:22
  • Then you need to move the 1:n relationships to different tables (in my example GAME_MODE and GAME_GENRE) – Stefan Winkler Jun 17 '20 at 08:06