4 ms·
No, clarity is much more important than consistency. And I much prefer to see an expression like O.order_id = CO.order_id than O.Id = CO.order_id
by Ma8ee 7y ago
No, clarity is much more important than consistency. And I much prefer to see an expression like
O.order_id = CO.order_id
than
O.Id = CO.order_id
- roland-s 7y agoIf you're using table aliases like "O" you're already throwing clarity out the window. The following is perfectly clear and readable IMO: Orders.id = Customers.order_id and also indicates which column is the primary key and which is the foreign key. What about other column names duplicated across tables, should Orders.created_at = Customers.created_at become Orders.order_created_at = Customers.customer_created_at Scope exists for a reason, don't be afraid to use it!
- Ma8ee 7y agoThe reason we use aliases is it almost only in toy-examples that most tables are called things like Order. I won't fill my SELECT with row after row with CustomerOrderRowHistory... And your second example kind of prove my point. When it it written out like that it become obvious that you are trying to compare diffent quantities. There is clearly something wrong when you are trying to join on order_created_at = customer_created_at which isn't at all as clear with your way of writing.