I am trying to understand 1st and 2nd normal forms and I see lots of seemingly conflicting information, or just different sets of requirements which leaves me confused. I have a table that I want to get into 2NF.
So far I understand that every field needs to be atomic to achieve 1NF and every field in a column needs to be of the same type.
Let’s take this zoo visit table as an example:
Animal Date Minutes_watched Type_of_exhibit Biome Area Lion 10/10/2020 10 Regular Sahara 1 Giraffe 10/10/2020 20 Special Sahara 1 Python 4/10/2020 15 Regular Jungle 2 Penguins4/10/2020 15 Regular Arctic 3 Lion 10/10/2020 12 Regular Sahara 1
My two main questions are, does there need to be a unique primary key for 1NF? And Can there be repeating groups of data in 1NF like there is above (with the two Lion rows, or with biome and area relationship)?
This top-rated SO post says 1NF just disallows non-nested tables. which suggests to me the above table is in 1NF.
This geeksforgeeks.org article states there are 4 requirements:
- There are only Single Valued Attributes.
- Attribute Domain does not change.
- There is a unique name for every Attribute/Column.
- The order in which data is stored does not matter.
Which says nothing about repeating groups or PKey but has 4 other requirements. Still seems like the example is in 1NF.
Then there is this article that has 4 requirements:
Define the data items required, because they become the columns in a table.
- Define the data items required, because they become the columns in a table.
- Place the related data items in a table.
- Ensure that there are no repeating groups of data.
- Ensure that there is a primary key.
1 & 2 seem like they can reduce to data having the same type, but it says there should be no repeating groups of data and that there needs to be a primary key which the first two don’t seem to require. So the examples is not in 1NF.
- Eliminate repeating groups in individual tables.
- Create a separate table for each set of related data.
- Identify each set of related data with a primary key.
Again, suggests it’s not in 1NF.
Are primary keys required or not? Are groups of data like Lions in the example in 1NF or not? Is there a definitive list of requirements?