Questions tagged [naming-convention]
82 questions
108
votes
18 answers
Is adding the ‘tbl’ prefix to table names really a problem?
I’m watching some Brent Ozar videos (like this one, for instance) and he suggests not prefixing tables with ‘tbl’ or ‘TBL’.
On the internet I found some blogs saying it adds nothing to documentation, and also that “it takes longer to read…
Racer SQL
- 7,546
- 16
- 77
- 140
90
votes
13 answers
How should I best name my timestamp fields?
When I am looking to create some timestamp fields (or other date/time style fields), what is the best way to name them? Should I just put record_timestamp?
garik
- 6,782
- 10
- 44
- 56
74
votes
10 answers
Why do people recommend not using the name "Id" for an identity column?
I was taught not to use the name Id for the identity column of my tables, but lately I've just been using it anyways because it's simple, short, and very descriptive about what the data actually is.
I've seen people suggest prefixing Id with the…
Rachel
- 8,547
- 20
- 51
- 74
70
votes
9 answers
Plural vs Singular Table Name
How should I name my Tables when creating a new database?
Singular: Client or Plural: Clients?
John Isaiah Carmona
- 803
- 1
- 6
- 7
28
votes
7 answers
Is table aliasing a bad practice?
I remember learning to do this in a DBMS course for Master of Information Services students. To save yourself some typing, you can type:
SELECT t1.id, t2.stuff
FROM
someTable t1
INNER JOIN otherTable t2
ON…
Zelda
- 2,103
- 6
- 28
- 38
23
votes
9 answers
Is there a reason to use extremely abbreviated table names?
We're using a database setup from a vendor's application that has horrifically hard to read database table names, and no documentation on what is stored where. I can see why one might want to obfuscate their table structure in a proprietary app, but…
Zelda
- 2,103
- 6
- 28
- 38
21
votes
3 answers
Column name naming conventions and best practices
I would like some expert opinion on best practices when it comes to column naming.
The background is that according to Wikipedia, the following syntax,
SELECT ... FROM Employees JOIN Timesheets USING (EmployeeID);
is more efficient than
SELECT ...…
Kerrek SB
- 313
- 2
- 6
21
votes
5 answers
What standard should I follow when naming tables and views?
What standard should I follow when naming tables and views? For instance, is it a good idea to put something like tbl_ at the beginning of table names? Should I designate code/lookup tables in some way like ct_, lut_, or codes_? Are there any other…
Beth Lang
- 952
- 1
- 10
- 19
20
votes
2 answers
Naming conflict between function parameter and result of JOIN with USING clause
Given this setup in current Postgres 9.4 (from this related question):
CREATE TABLE foo (ts, foo) AS
VALUES (1, 'A') -- int, text
, (7, 'B');
CREATE TABLE bar (ts, bar) AS
VALUES (3, 'C')
, (5, 'D')
, (9, 'E');
db<>fiddle here…
Erwin Brandstetter
- 185,527
- 28
- 463
- 633
19
votes
2 answers
Should I call my UUID primary key column ID or not?
I'm working on a database design that extensively uses UUIDs for PRIMARY KEYs. However, this confronts me with a very consequential choice. How do I name these columns? I would call them uuid, except that, UUID being an identifier, I then have to…
BigSmoke
- 784
- 1
- 7
- 13
16
votes
2 answers
Official PostgreSQL Capitalization conventions
Is there an official PostreSQL convention regarding capitalization in DB, Table and field names?
The examples on the official site suggest a lowercase and _ word separation, and I wonder whether this policy is official.
CREATE TABLE films (
code…
Adam Matan
- 12,079
- 30
- 82
- 96
16
votes
2 answers
Should I not use camelCase in my column names?
I am creating a GraphQL API using Node.js, which foces me to return all the field names in camelCase.
In my PostgreSQL database, I currently have all my columns named following a camelCase convention, but I am thinking: is that the best idea?
Should…
Luiz Felipe
- 269
- 1
- 2
- 4
11
votes
1 answer
Issue with Table Naming Conventions and Policy Management in SQL Server 2016
In SQL Server 2012, I had a policy set to not allow spaces in a table name. However, when I use the same policy in SQL Server 2016, I get an error.
Here is the code for the condition:
DECLARE @condition_id INT
EXEC…
John
- 471
- 2
- 8
9
votes
3 answers
What is the significance of the trailing dollar sign `$` on identifiers in SQL Server?
Dumping some internal views, such as sys.system_objects as done in this question I see that some identifiers end with a dollar-sign $
CREATE VIEW sys.system_objects AS
-- cutout
FROM sys.sysschobjs$ o -- XXX: HERE
LEFT JOIN…
Evan Carroll
- 65,432
- 50
- 254
- 507
8
votes
1 answer
Does the length of a table name affect performance?
PostgreSQL table names are limited to 63 chars.
Is there a performance gain to be had if I limit my table names to something like 5 chars or can I use the full 63 chars without consequence?
I understand it will be longer to type long names when…
jmn
- 83
- 1
- 3