Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Aren't you literally describing an index?


No. Maybe an example helps. You have a users table with username as natural PK. You have an access table with timestamps of users hitting a service, with FK of username. If you query the access table for a range of timestamps and just want the usernames, they're right there in the results of the access table query. If you had instead used a synthetic user_id key, the db would have to do an additional lookup in the users table via a join for each user_id to get the usernames.


Oh of course, that makes sense. I'm not sure how I misunderstood that!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: