Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of tbl_Product, tbl_Order naming conventions?

I've seen tbl_ prefixes decorating all tables in the last two code bases I've worked with. I can't think of any reason they'd be useful for application developers or database administrators.

If a DBA needs to see what objects are tables they can always join up to DMV's or the schema tables in master right? I can't think of how they'd be useful to a programmer either, even more so if the project is using an ORM tool.

Still even while writing stored procs they just seem to get in the way.

Can anybody explain how they'd be useful in a non-subjective way? Ex ( having tbl_ helps me perform x task )

like image 368
John Farrell Avatar asked Dec 10 '22 19:12

John Farrell


2 Answers

I’ve heard the same thing over and over again the reason being, it helps them to know the type of the object.

Inside a query, using prefixes could help them separate tables from views for instance.

I really don’t agree with that. After getting used to the database schema, prefixes become redundant and as happens with everything that is redundant, it can become desynchronized or make changes harder to do.

Let’s say you have a table that for whatever reason you have to split into two tables. Let’s say you decide to create a view that emulates the original table selecting data from the two new tables.

Are you going to rename throughout you code base or are you going to stick with a view prefixed as tbl_?

So my point is database object names should not have any prefixes for inferring their types.

like image 128
Alfred Myers Avatar answered May 14 '23 05:05

Alfred Myers


I can't think of many benefits. You could definitely see cleaner SQL like this:

select post.id, post.subject, post.body from tbl_post post where post.author="eric"

Makes your variables easier. Otherwise, this just looks like you've been dealing with people who learned databases on MS Access.

like image 40
Eric Anderson Avatar answered May 14 '23 04:05

Eric Anderson