5 ms·
Personally, for me it makes sense that the id field has a different distintive name for each table because it's a specific kind of id, i.e., customerID is not i
by Mahn 11y ago
Personally, for me it makes sense that the id field has a different distintive name for each table because it's a specific kind of id, i.e., customerID is not interchangeable with reservationID. For me, this is not so much about prepending the field with the table name, but about calling things by their name. "id" is just too vague, even if you use it in the context of a specific table.
- fleitz 11y agoI believe this is what foreign keys are for, and also, they are usually both ints/uuids/etc so generally they are interchangeable. I fail to see how customer.id = product.id is any less obvious of a bug than customer.customerID = product.productID
- jessaustin 11y agoWith aliases that first expression might be: c.id = p.id That seems like an easy error to make...
- liotier 11y ago> With aliases that first expression might be: c.id = p.id Which is why I don't use aliases, so that future me doesn't have to wonder what the hell he wrote a few months ago.
- rlucas 11y agoOnce an application has been alive for more than a few months, I find it often is subject to self-joins and other query approaches which pretty much beg for aliases in the name of legibility.
- dsp1234 11y agosubject to self-joins and other query approaches Which means that the original argument about reserveration_id vs id doesn't matter since it's likely that both table and column aliases would be needed anyways.