You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it would make sense to use a numerical value, for example an auto-incrementing integer as the primary key, especially in scenarios where there are resources "belonging" to a user, in a sense that a user reference is part of another database record?
I would imagine that using the user name as a foreign key there could possibly increase the size of the data, add unnecessary redundancy, and be costly in joins.
For example, I have an application where there are "projects" that are created by a user, and have access lists allowing other users access to the project data as well. The project database is file based sqlite, using sqlalchemy, and thus lives in a different database context than the user database. I doubt that sqlite is smart enough to optimize that in a way that would be equivalent to numerical foreign key relations.
Thanks!
Andy
The text was updated successfully, but these errors were encountered:
oaken-source
changed the title
Would numerical user ids instead of name field as primary make sense?
Would numerical user ids instead of name field as primary key make sense?
Aug 21, 2014
I'm interested in helping that, as I also want to have an user_id to relate to other tables. If anyone is up to giving some advice on how to start that I'd be willing to try my hand contributing.
In the sqlalchemy backend (line 155), the table definition sais
I was wondering if it would make sense to use a numerical value, for example an auto-incrementing integer as the primary key, especially in scenarios where there are resources "belonging" to a user, in a sense that a user reference is part of another database record?
I would imagine that using the user name as a foreign key there could possibly increase the size of the data, add unnecessary redundancy, and be costly in joins.
For example, I have an application where there are "projects" that are created by a user, and have access lists allowing other users access to the project data as well. The project database is file based sqlite, using sqlalchemy, and thus lives in a different database context than the user database. I doubt that sqlite is smart enough to optimize that in a way that would be equivalent to numerical foreign key relations.
Thanks!
Andy
The text was updated successfully, but these errors were encountered: