bottle-cork
bottle-cork copied to clipboard
Would numerical user ids instead of name field as primary key make sense?
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
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.
+1, this is db 101 nono, not to mention that users cannot change their usernames without a db migration of all related tables.