2

After reading about normalization I am unsure of how to interpreter the 1 NF requirements

According to wikipedia, something is in first normal form, if the "domain of each attribute contains only atomic indivisible values"

My question is:
Who decides what is indivisible or not? You may divide a date datatype into year, month, day, second, nanoseconds. You may aswell divide an adress into the exact latitude coordinates. When can you really be sure that you have reached 1NF?

Would this table be considered 1NF?

fullName fullAdresss
Joe Zowesson 87th Victoria Street London EC96 1MB, 14584
Mason Hamburg 47th Jeremy Street London EC26 1MB, 13584
Dedrik Terry 27th Burger Street London EC16 1MB, 17584

My interpretation here is that the value Joe Zowesson is indivisible in regards to the column fullName. And that both zip code, street number and street name is atomic in relation to the column name fullAddress.

I am almost certain that I am in the wrong, but I can not yet understand why.

The question is in regards to an upcoming exam, where I will need to "proove" which normal form something currently is in. Something that I find very hard depending on how you interpreter the word atomic.

Will123
  • 55
  • 1
  • 7
  • 1
    Interesting . . . 1NF is not usually of much interest, except for changing it to 3NF. – Gordon Linoff Mar 20 '21 at 16:26
  • What do you mean? You would have to reach 1NF before eventually reaching 2NF and 3NF. – Will123 Mar 20 '21 at 16:40
  • 1
    To be honest, if you simply create a database with the attitude that values are only stored once, with references to the values, then you'll come up with a pretty good design. Practiced database designers don't go through the steps of normalization formally. But they do use the language to talk about structures, so understanding the concepts is useful. – Gordon Linoff Mar 20 '21 at 17:07
  • Does this answer your question? [Normalization in database management system](https://stackoverflow.com/questions/40623169/normalization-in-database-management-system) – philipxy Mar 20 '21 at 17:44
  • This is a faq. Before considering posting please read the manual & google any error message & many clear, concise & precise phrasings of your question/problem/goal, with & without your particular names/strings/numbers, 'site:stackoverflow.com' & tags; read many answers. If you post a question, use one phrasing as title. Reflect your research. [ask] – philipxy Mar 20 '21 at 17:51
  • 1
    I have linked to a Q&A explaining that 1NF has no single meaning. Some of the links there are Q&A about the vague, unhelpful & confused notion of atomicity. One is about good design in the spirit of atomicity. But I can't use it as a duplicate target yet. PS What are the columns & the values for each column & row in that "table"? Please format reasonably. See the edit help. You are not clear: What do you mean "indivisible from"? Use enough words, sentences & references to parts of examples to clearly & fully say what you mean. – philipxy Mar 20 '21 at 17:53

2 Answers2

3

You have misunderstood the concept of 1NF basically. By atomic value, it is meant that when you have a column for Name, you should not store any other values alongside it. In other words, the column intended for the Name should not store ID, Address or anything else together with Name, so that when you query the column Name you get only Name, and not name with Id or Address. And Name can be in any form you want whether it be First name + Last name or First name + Last name + Middle name + Previous name.

The decision of whether you need separate columns for the related data should be made during design. Let's suppose you have table Student:

StudentId FullName Address Average grade
1 John Done New York, US 3.4
2 Robert Bored New York, US 0
3 Student LName Dallas, US 1
4 Another LName Munich, Germany 2

In this case, it means that you do not write queries and don't need data based on First name, Last name separately, but you need all at once for example:

SELECT FullName
FROM Student
WHERE StudentId = 1;

John Done

And when you need First name, Last name separately, you decompose them into several columns, for example:

StudentId FullName LastName Address Average grade
1 John Done New York, US 3.4
2 Robert Bored New York, US 0
3 Student LName Dallas, US 1
4 Another LName Munich, Germany 2

And your queries might look like this:

SELECT LastName, AverageGrade
FROM Student
WHERE AverageGrade >= 1 AND FirstName != 'John';

The result will be:

| LastName | AverageGrade |
---------------------------
| LName    |     1        |
| LName    |     2        |

Or something like this maybe:

UPDATE Student
SET AverageGrade = 4
WHERE LastName = 'LName' AND FirstName != 'Student'

Basically, the decision depends on how you manipulate the data and in which form you need it.

To sum it up. Whether the relation is in 1NF or not depends on what values you're trying to store on this table, as I mentioned above, one column should store only one type of value, e.g ID, Address, Name, etc. And the decision of how your columns' values will look depends on the design and how you NEED TO STORE the data. If you do not need to query fistname, middlename, lastname, secondname separately, then what you can do is just save all of them in one column FullName and it will still be in 1NF. But if you need them separately, you can store them in separate columns, and again it will still be in 1NF, but it might violate other rules.

Here are some tutorials you might find useful: https://www.studytonight.com/dbms/first-normal-form.php

Miraziz
  • 509
  • 7
  • 15
  • To clarify, both of your tables are in 1NF right? And whether or not something is in 1NF depends (for example), entirely on if you would ever need to query first name/ last name from someones **FullName**. If the answer is **no**, you are in 1NF? If you have **one** single query out of 200 (where 199 uses **FullName** directly), you are not in 1NF? – Will123 Mar 20 '21 at 18:52
1

Let the application, and how it will be used, guide you as to what data should be split further into additional fields (or not).

For example; If, in your application, you are constantly splitting first name from last name so that you can say "Hi Joe" on correspondence, you should split fullName into two fields. Conversely, If you had two fields firstName and lastName, and were always concatenating them so that you could correctly address an envelope, it would make more sense to have those two fields stored in a single column in your table.

In practice, it is not uncommon for a database to show some de-normalization with the above example given how common both scenarios are but the risk is that they get out of sync if someone updates first name (for example) but doesn't update fullName.

Consider things like how you will force your users to follow a certain pattern if you decide to go with a single column fullName. How would you prevent "Smith, Joe" if your application needed "Joe Smith"?

Dates are another good example and again, whether you split the parts into separate columns depends on how they will be used.

A datetime field which indicates when a row was inserted probably doesn't need to be split out, but if you had many queries which were only interested in the year (for example), it might make sense to split it out.

This only scratches the surface which is why this answer is more about how to think about the underlying problem. Yes normalizing your database is important for all kinds of reasons, but how far you go with it depends on how your data will be used at the end of the day.

G B
  • 1,412
  • 10
  • 12