sql - cakephp mysql ,autoincrement id or varchar as primary key -


i building web application cakephp 2.4 , have firstly designed users table integer auto-incrementing id, since urls structured : http://mywebsite/users/view/username realized instead of using integer auto-increment, may better performance use username(varchar 100) primary key.now curious how approach affect site performance when database grows.

as per other answers, use integer pk. pick correct int size depending on how many records you're expecting. not using integer pk cake might cause problems. if you're using framework, stick it's conventions - that's advantage of framework!

do not generate unique route every user dynamically in routes.php. goes against entire point of having generic routing. 1 route should account this, , deal in relevant controller.

for example, if specify of real controllers/actions:

router::connect('/:controller', array('controller' => 'user|anothercontroller|etc')); router::connect('/:action', array('controller' => 'something'), array('action' => 'allowed|actions|etc')); router::connect('/:action', array('controller' => 'else'), array('action' => 'allowed|actions|etc')); 

you can send else, in, site.com/username, somewhere specific.

router::connect('/:username', array('controller' => 'users'), array('action' => 'view'), array('pass'=>array('username'), 'username' => 'regex')); 

and accept 'username' var in view function, , use find correct user db. also, note if


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -