Live data from Hacker News

What does First Normal Form mean?

cargocultcode.com

11–20 of 125 posts

Re: What does First Normal Form mean?

#11

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.

What about people with the same birthdays?

What about them? Do they really exist, practically speaking?

At a quick glance on my databases, I see nothing of the sort.

Re: What does First Normal Form mean?

#12

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 multiple tables as a foreign key.

Re: What does First Normal Form mean?

#13
post #11

Earlier quoted context omitted.

What about people with the same birthdays?

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

https://en.wikipedia.org/wiki/Birthday_problem

Re: What does First Normal Form mean?

#14

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…

> 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 multiple tables as a foreign key.

It is ironic, given that the whole reason to have a student ID is for it to be a primary key in some database somewhere.

Re: What does First Normal Form mean?

#15

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.

What about people with the same birthdays?

I think this was the parent's point. Since, as you point out, we we almost never use the data itself (e.g. date of birth) as the primary key, the parent is asking why is this a feature at all? Why not just mandate a uuid, number, etc. as the primary key?

Re: What does First Normal Form mean?

#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 theoretical advantages and disadvantages, but using IDs seems to work well enough that we’re not investing in a new paradigm.

Re: What does First Normal Form mean?

#17
post #13
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.

https://en.wikipedia.org/wiki/Birthday_problem

Is there anything comparable to the birthday paradox, which includes years, by the way?

I would guess that you would need a big group of random people such that there is a high chance of having two people born the very same day.

Re: What does First Normal Form mean?

#18
post #13
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.

https://en.wikipedia.org/wiki/Birthday_problem

I don't think the birthday problem accounts for year, but yet it's clear some people share the same birthdate, twins for example.

Re: What does First Normal Form mean?

#19

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.

How would DoB work as a primary key? A primary key is useless if not unique, right? And I know many people born on the same day that aren't even twins. Incrementing integers are nice and easy for humans to consume. Using GUIDs is far more portable than unique integers, but damn near impossible for humans to deal.

Re: What does First Normal Form mean?

#20
post #17
post #13

Earlier quoted context omitted.

https://en.wikipedia.org/wiki/Birthday_problem

Is there anything comparable to the birthday paradox, which includes years, by the way? I would guess that you would need a big group of random people such that there is a high chance of having two people born the very same day.

The birthday paradox threshold if years are included would be 23 people per year, rather than 23 people in your database. What that translates to in your database depends a lot the age demography of your userbase. If people live to be 100, and if I don't worry about the fact that some years will have more people than others even if they are randomly distributed (something that should go in to the model), that's about 2,300 people before you start expecting to see duplicate birthdays.
Post reply on HN