I have been told several times that using email address a primary key is a bad choice, but what I don't understand is have seen on many occasions where email address is used to identify users; when signing up on a platform and logging in, I see email addresses
being displayed to identify that the user who logs in, is the owner of the email address.
From what I read with regards to this, email is most times changed and as a result, there must be an update on all the tables on the platform. If that is the case, then I see no problem in updating all the tables.
An email might be used as a username but doing so does not mean the email is the primary key.
georgeakpan233
From what I read with regards to this, email is most times changed and as a result, there must be an update on all the tables on the platform. If that is the case, then I see no problem in updating all the tables.
Why create a complex design that might cause issues later? Makes no sense. Use standards and assign a primary key that does not change. Keep in mind, keys are used by the system not the user.
georgeakpan233
More guide please?
I have provided standard patterns and approaches in several of your threads. You refuse the recommendations and state that your design is solid. Clearly, your design is not working.
Where did you get all this assumptions that its not working?
It's been a few weeks where you have struggling with the same issue.
georgeakpan233
You clearly do not have an idea on what I am trying to accomplish
THE IDENTITY YOU TALK ABOUT HERE, I CHECKED IT AND IT DOES NOT MEET WHAT I WANT
No. I completely understand what you are trying to do and have build similar application. I'm simply trying to give you my experience so you do not have to make the same mistakes. Clearly you know what you're doing... good luck.
I have seen situations where a user registers and at that instant a record is created in two tables User table and in a wallet table, and the user will have NO amount in the wallet because the user just registered. Identity has not mentioned anything
in that regard; You mentioned that I should separate identity and wallet
I have seen situations where a user registers and at that instant a record is created in two tables User table and in a wallet table, and the user will have NO amount in the wallet because the user just registered. Identity has not mentioned anything
in that regard; You mentioned that I should separate identity and wallet
Snarky comments aside, your response highlights your inexperience. The "wallet" is a custom application feature. If the design/code does not behave as expected then there is a flaw in your design/code not Identity. Identity is just an API for managing
accounts and logins.
You could simply use Cookie Authentication with out identity if you do not need the account management.
Using the mail address to "identify" the user from a business perspective doesn't mean an app won't use its own pk. This way if the user is changingg his mail address you just don"t have to update all related tables (including audit logs or whatever).
A single user could also register multiple mail addresses etc...
As pointed already a good primary key is not only unique but most often should never change and even never be reused (for example so that you can distinguish between the current
john.smith@company.com and another one that worked here few years ago but left since then).
Member
66 Points
175 Posts
Email Address as primary key
Jul 01, 2020 10:27 AM|georgeakpan233|LINK
Hello Forum,
I have been told several times that using email address a primary key is a bad choice, but what I don't understand is have seen on many occasions where email address is used to identify users; when signing up on a platform and logging in, I see email addresses being displayed to identify that the user who logs in, is the owner of the email address.
From what I read with regards to this, email is most times changed and as a result, there must be an update on all the tables on the platform. If that is the case, then I see no problem in updating all the tables.
More guide please? Thank you
All-Star
53721 Points
24050 Posts
Re: Email Address as primary key
Jul 01, 2020 10:37 AM|mgebhard|LINK
An email might be used as a username but doing so does not mean the email is the primary key.
Why create a complex design that might cause issues later? Makes no sense. Use standards and assign a primary key that does not change. Keep in mind, keys are used by the system not the user.
I have provided standard patterns and approaches in several of your threads. You refuse the recommendations and state that your design is solid. Clearly, your design is not working.
All-Star
20953 Points
4984 Posts
Re: Email Address as primary key
Jul 01, 2020 10:46 AM|asteranup|LINK
This is a good discussion in this topic here-
https://stackoverflow.com/questions/3804108/use-email-address-as-primary-key#:~:text=Yes%2C%20it%20is%20a%20bad,to%20update%20their%20email%20addresses.&text=Another%20reason%20why%20integer%20primary,use%20it%20as%20a%20key.
Anup Das Gupta
Visit My Blog
You can also connect with me in LinkedIn
Member
66 Points
175 Posts
Re: Email Address as primary key
Jul 01, 2020 10:52 AM|georgeakpan233|LINK
mgebhard,
I NEVER MENTIONED THAT IT IS NOT WORKING.
Where did you get all this assumptions that its not working?
You clearly do not have an idea on what I am trying to accomplish
THE IDENTITY YOU TALK ABOUT HERE, I CHECKED IT AND IT DOES NOT MEET WHAT I WANT
Member
66 Points
175 Posts
Re: Email Address as primary key
Jul 01, 2020 10:54 AM|georgeakpan233|LINK
Thanks asreranup,
I will check it out
All-Star
53721 Points
24050 Posts
Re: Email Address as primary key
Jul 01, 2020 11:02 AM|mgebhard|LINK
It's been a few weeks where you have struggling with the same issue.
No. I completely understand what you are trying to do and have build similar application. I'm simply trying to give you my experience so you do not have to make the same mistakes. Clearly you know what you're doing... good luck.
Member
66 Points
175 Posts
Re: Email Address as primary key
Jul 01, 2020 11:06 AM|georgeakpan233|LINK
Okay Mr Einstein,
I have seen situations where a user registers and at that instant a record is created in two tables User table and in a wallet table, and the user will have NO amount in the wallet because the user just registered. Identity has not mentioned anything in that regard; You mentioned that I should separate identity and wallet
All-Star
53721 Points
24050 Posts
Re: Email Address as primary key
Jul 01, 2020 11:27 AM|mgebhard|LINK
Snarky comments aside, your response highlights your inexperience. The "wallet" is a custom application feature. If the design/code does not behave as expected then there is a flaw in your design/code not Identity. Identity is just an API for managing accounts and logins.
You could simply use Cookie Authentication with out identity if you do not need the account management.
Member
66 Points
175 Posts
Re: Email Address as primary key
Jul 01, 2020 11:32 AM|georgeakpan233|LINK
What a person, mgebhard! Sorry but I only got time for better responses. Ciao
All-Star
48730 Points
18190 Posts
Re: Email Address as primary key
Jul 01, 2020 12:00 PM|PatriceSc|LINK
Using the mail address to "identify" the user from a business perspective doesn't mean an app won't use its own pk. This way if the user is changingg his mail address you just don"t have to update all related tables (including audit logs or whatever). A single user could also register multiple mail addresses etc...
As pointed already a good primary key is not only unique but most often should never change and even never be reused (for example so that you can distinguish between the current john.smith@company.com and another one that worked here few years ago but left since then).
Contributor
2619 Points
2753 Posts
Re: Email Address as primary key
Jul 02, 2020 05:54 AM|wavemaster|LINK
All processing is done in zeros and ones.
If one uses int as the primary key, there is one type conversion from int to binary
If one uses string as the primary key, then there are two type conversions: ASCII to int to binary for each character in the string
Say you are asking to do a table lookup for record 100, which is 0110 0100 in binary. That would be really fast.
Now consider a string as the primary key and an email address along the lines of georgeakpan233@mail.yourreallylongdomain.com
I count 44 characters, i.e. 44 different comparisons. Not as fast.