Is it good practice to use the email address as the primary key in many tables in the website system?

For example, a website like stackoverflow.com, is it useful to use an email address to identify users in many tables?

Itโ€™s bad if the primary key is very long, say

VARCHAR (50)

or even

VARCHAR (100)

?

+3
source share
6 answers

Not really. For any significant data set, you end up wasting a lot of space, and when polling you will get a performance hit. Also, if someone modifies their email (which you may or may not allow), you need to change it everywhere.

, , .

+12

. -, , ? , .

-, . , ? , .

-, - auto-incrementing ID. (, ) .

, memberID member. questionID question memberID member, , . Etc.

, , , (3NF). , .

+7

, , , , ,

  • . , . , . ( ? ? -?)

  • - . . , 13 .

  • , ( ?). , , a) , b) , .

+3

post Jay Pipes int char , .

0

, . .

0

. . , . .

If your columns are indexed correctly, most modern databases (Oracle, Postgres, SQLServer) will not punish you for participating in an email address. If you are worried about joins, create a denormalized materialized view and pay the price for insert / update.

0
source

Source: https://habr.com/ru/post/1724698/


All Articles