SQL - naming of ID columns

database-design, naming-conventions

Solution

It's all a personal preference. I personally use `Id` simply because I think of each table as its own entity...then when I reference with a key it becomes CustomerId or OrderId depending on the name of the table.

Problem

I've always wondered what are the pros and the cons of these ID naming styles in SQL: ``` CREATE TABLE cache ( id INT AUTO_INCREMENT, PRIMARY KEY(id) ); CREATE TABLE cache ( cid INT AUTO_INCREMENT, PRIMARY KEY(id) ); CREATE TABLE cache ( cache_id INT AUTO_INCREMENT, PRIMARY KEY(id) ); ``` Why some developers use "id" in each table, some prefix it with one letter of the table name or with the entire table name along with one underscore?

Original source