Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would numerical user ids instead of name field as primary key make sense? #72

Open
oaken-source opened this issue Aug 21, 2014 · 2 comments
Assignees

Comments

@oaken-source
Copy link

In the sqlalchemy backend (line 155), the table definition sais

Column('username', String(128), primary_key=True),

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

@oaken-source 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
@FedericoCeratto FedericoCeratto self-assigned this Dec 21, 2014
@gleicon
Copy link

gleicon commented Jun 8, 2015

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.

@astubbs
Copy link

astubbs commented Aug 5, 2015

+1, this is db 101 nono, not to mention that users cannot change their usernames without a db migration of all related tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants