Anonymous ID: 09d247 Feb. 9, 2025, 3:37 a.m. No.22544342   🗄️.is 🔗kun   >>4346

>>22544339

but it should be unique, because that's what it is.

and you could easily make sure that this is always the case either by having a table with the SSN being the primary key, OR setting a unique index for the SSN field.

Anonymous ID: 09d247 Feb. 9, 2025, 3:51 a.m. No.22544361   🗄️.is 🔗kun   >>4368 >>4372 >>4385 >>4593

>>22544357

No, it's shitty database design.

Take a hospital system. Every patient gets a unique number called the patient number, plus multiple case numbers.

 

All of these are primary keys, because you never want to assign the same number to multiple people.

 

Same here. It makes no sense to assign the same SSN to multiple people, ever. And there is no way you will ever run out of numbers.

Anonymous ID: 09d247 Feb. 9, 2025, 4:11 a.m. No.22544388   🗄️.is 🔗kun   >>4404

>>22544374

>Primary keys slow databases down, especially write time. They are not meant to be all over your database.

What?

A primary key simply lets a database identify every row uniquely. In professional systems like for example SAP, every table has to have a primary key.

 

What's true though is that additional indexes will increase write time.

Anonymous ID: 09d247 Feb. 9, 2025, 4:22 a.m. No.22544418   🗄️.is 🔗kun

>>22544404

additional indexes can improve all sorts of read operations, especially for big tables.

most of the time database tables are read a lot, and write operations do not happen often.

you want read operations to work as fast as possible.

 

but this is also about database design.

let's go back to the hospital.

 

if you are a bad database designer, you would store it like this:

 

Case-data-table:

Primary key: PATIENT + CASE

this would allow the same case number to be accidentally get assigned to multiple patients. This would be very very bad.

Therefore you do this instead:

Primary key: CASE

Regular field: PATIENT

this way every case number has to be unique, there is no way around that, and every case can only get assigned to one single patient, which is very important.

 

of course some systems like SAP HANA loads the whole database into RAM, in that case such indexes are not needed, at the same time when the system goes down, it may take a day to come back up. With a regular SQL database, that's not the case.