Primary key vs surrogate key | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Primary key vs surrogate key

If I have an entity 'applicant' with national id as an attribute among other attributes, is it recommended to use national id as primary key since it might contain null values(for applicants under 18 with no national ID or international students)? Then I thought of using a surrogate key but some sites say it violates 3nf and that it is not good as a search key. Any solution pls?

30th Jan 2024, 11:50 AM
Kimberley
5 Answers
+ 3
A primary id should not contain null. You should have an entity with the types of applicants that has a relation to your applicant entity, and then you are not violating 3NF.
30th Jan 2024, 2:27 PM
Jan
Jan - avatar
+ 1
I think this blog is worth to take a look. https://www.sololearn.com/blog/what-is-normalization/ 3NF is good, but not necessary in all use case.
2nd Feb 2024, 4:36 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Kimberley I don't know how this happens. But if you view this discussion from the website, the link is clickable.
2nd Feb 2024, 4:36 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
The link is not working.
2nd Feb 2024, 4:33 PM
Kimberley
0
Ok I tried to copy paste the link and open it in chrome instead. Thanks for the resource.
2nd Feb 2024, 6:38 PM
Kimberley