Live data from Hacker News

What does First Normal Form mean?

cargocultcode.com

71–80 of 125 posts

Re: What does First Normal Form mean?

#71

Codd's paper is not that hard. [0] is a PDF copy. One of the pros to reading primary sources is you then know "the whole story": what if anything is missing from popular explanations, and what is changed. A striking bit of trivia (but OT to SQL) is that in Turing's "On Computable Numbers" [1] he treats a Turing Machine that halts as having a problem, whereas in basically every popular treatment a machine that halts i…

> A striking bit of trivia (but OT to SQL) is that in Turing's "On Computable Numbers" [1] he treats a Turing Machine that halts as having a problem, whereas in basically every popular treatment a machine that halts is one that gives you an answer, and a machine that doesn't halt is one with a bug, like it entered an infinite loop. But his paper is the opposite (and doesn't use the word "halt" at all!):

Note that his machines compute real numbers, which always have a an infinitely long binary representation (with possibly infinitely many trailing zeroes), whereas usually one considers Turing machines computing natural numbers, which always have a finite binary representation.

Re: What does First Normal Form mean?

#72
post #16

I have never understood why RDBs have such general concepts of primary keys, where you can for example let date of birth be a primary key, when in every schema I have ever designed or seen, all rows get unique integer IDs anyway.

Codd was pretty adamant in his original papers that keys should be made up from data rather than a unique integer, and his example of converting from a hierarchical database schemas to a relational database schema shows how compound, natural keys are important to represent relationships. But we don’t usually do it that way today, partly because it isn’t that practical with our current databases and ORMs. It has some…

In practice, using a unique IDs is often not ideal, but it also rarely the wrong choice. I've personally never heard of a scenario where a unique ID caused difficult to fix issues (although I'm sure it's possible).

In contrast, a poorly though out natural key can cause a lot of headaches. This mostly occurs when your natural key isn't as unique as you thought, or if you have to change what you use as a natural key. The real world does not like to conform to our database constraints.

Re: What does First Normal Form mean?

#73
post #71

Codd's paper is not that hard. [0] is a PDF copy. One of the pros to reading primary sources is you then know "the whole story": what if anything is missing from popular explanations, and what is changed. A striking bit of trivia (but OT to SQL) is that in Turing's "On Computable Numbers" [1] he treats a Turing Machine that halts as having a problem, whereas in basically every popular treatment a machine that halts i…

> A striking bit of trivia (but OT to SQL) is that in Turing's "On Computable Numbers" [1] he treats a Turing Machine that halts as having a problem, whereas in basically every popular treatment a machine that halts is one that gives you an answer, and a machine that doesn't halt is one with a bug, like it entered an infinite loop. But his paper is the opposite (and doesn't use the word "halt" at all!): Note that his…

Yes, it makes sense. But it sure took me by surprise when I finally read the original paper.

Re: What does First Normal Form mean?

#74

I have never understood why RDBs have such general concepts of primary keys, where you can for example let date of birth be a primary key, when in every schema I have ever designed or seen, all rows get unique integer IDs anyway.

It's rare in practice but occasionally rows have natural unique identifiers that are useable. The textbook case would be student IDs in a university database where each row corresponds to a single student. However some universities view the student id as sensitive information (kind of like a ssn in the US) and so in that scenario it should be aliased to some other key to prevent the student id from being present in m…

In the 1980's your student ID was most likely your SSN

Re: What does First Normal Form mean?

#75
post #50
post #22

Earlier quoted context omitted.

No, is not a contradiction. Is like say "Is wrong to store a large json in a cell in an array, that make it not an array". A relation is A VALUE. That is. The atomicity of the data INSIDE each "cell" is orthogonal to the fact the that relation is a relation. This is the point.

You're not really addressing the point of the comment you are replying to, which is about what constitutes a normalized relation, not what constitutes a relation. And I agree, TFA is just flat out wrong. A relation Manager with a CSV-valued column SubordinateIds or columns named "Subordinate1Id" through "Subordinate9Id" is most definitely not normalized because those are in effect a (bad) simulation of hierarchical-d…

To be pedantic, is not a contradiction. Is a sign of problem with the design? Probably! Most likely!

But the relational model CAN'T say it. The normal forms are properties of the way you can do the design, but can't go that Deep.

In other words: You can adhere 100% on SOLID OOP principles and your code is still conceptually wrong!

If pay attention to the article, his issue is that people latches on the apparent definition of 1st normal form, but misunderstanding it and probably coming to the wrong conclusion about how make the tables...

Re: What does First Normal Form mean?

#76
post #37
post #11

Earlier quoted context omitted.

What about them? Do they really exist, practically speaking? At a quick glance on my databases, I see nothing of the sort.

Are we seriously discussing whether in practice, two people can be born on the same day?

This was an absurd joke. A person looking at their database using birth dates as a primary key can obviously only see people with different birth dates.

Re: What does First Normal Form mean?

#77
post #9
post #4

Earlier quoted context omitted.

He's somewhat consistent with that. "A relation...correspond", "relation refer to the", "an attribute correspond to". But diverges on that pattern for "domain": "a domain...corresponds".

may also be english as a second+ language or just a frequent brainfart around pluralization, see the intro: > This post explains what 1NF actually means and is useful for, and debunk a number of the misunderstandings.

The Wikipedia entry on First Normal Form also uses this kind of construction, which I suspect means it was written by the same person.

I have never seen terms like domain and attribute used as if they were plurals (the way "data" is), but even were that correct, "a domain have" would be contradictory, so I think it is just a linguistic quirk of the writer.

Re: What does First Normal Form mean?

#78
post #8

I think he contradicts himself and confuses the data with the information. I don't think delimited values representing a table in a column can be considered normalized. > Make no mistake, encoding multiple values in a single string is generally a bad design. But it has nothing to do with first normal form. First normal form mean a column should not allow relations as values. A comma-separated string is still just a s…

> I think he contradicts himself and confuses the data with the information.

I would say he is confusing the physical representation with the logical model.

Re: What does First Normal Form mean?

#79

Earlier quoted context omitted.

It's rare in practice but occasionally rows have natural unique identifiers that are useable. The textbook case would be student IDs in a university database where each row corresponds to a single student. However some universities view the student id as sensitive information (kind of like a ssn in the US) and so in that scenario it should be aliased to some other key to prevent the student id from being present in m…

Student IDs are certainly not ‘natural’ keys. I am almost entirely convinced that there is actually no such thing as a natural key.

Dates are natural keys in a calendar table. The composite of the foreign key values is a natural key in a join table expressing a unique relationship between entities in two or more other tables, perhaps with additional attributes, even if those values are surrogate keys in their own tables.

Re: What does First Normal Form mean?

#80

I have never understood why RDBs have such general concepts of primary keys, where you can for example let date of birth be a primary key, when in every schema I have ever designed or seen, all rows get unique integer IDs anyway.

It's rare in practice but occasionally rows have natural unique identifiers that are useable. The textbook case would be student IDs in a university database where each row corresponds to a single student. However some universities view the student id as sensitive information (kind of like a ssn in the US) and so in that scenario it should be aliased to some other key to prevent the student id from being present in m…

> The textbook case would be student IDs in a university database where each row corresponds to a single student

“Student IDs” are an example of surrogate keys, though they may be surrogate keys in a system predating and outside of the DB.

(And if the mapping between them and actual students are managed by an error-prone process outside of the DB, they probably aren’t good primary keys for a table of students.)

Post reply on HN