The right way to write "ID" in columns in SQL

Capitalization in SQL is largely a matter of coding style. Consistency is the most important aspect. That said, "ProductId" looks a little like "Productld" (that's a lower-case-L before the "d") to me, so I'd prefer "ProductID" (or "productID" or "product_id").

As for prefixing column names with table names, it's too much in my book. Products.id is sufficient; Products.productID is redundant.


There isn't a "right" way of doing it. Just be consistent. My personal preference is to use ProductId in both tables. If you use "ID" for all your tables and then join onto another table you will likely end up aliasing them anyway to distinguish between the two ID fields.


Personally, I'd ProductID, ProductName etc in a Product table and for the FKs too to avoid having ID and Name columns everywhere

Just be consistent