3

Is there a naming convention for lookup tables? I cannot see any declaration by oracle or anything consistent on google.

However I assume some of you professional DBAs follow a convention? Perhaps there is a convention which occurs the most when you are called to edit a project you didn't author?

example table

metals

+----+------------+
| id | metal_type |
+----+------------+
| 1  |    gold    |
| 2  |    silver  |
| 3  |    bronze  |
| 4  |    brass   |
+----+------------+

Currently I have been using the original table name + the column name as my lookup table name.

metals_metal_type

I decided to change to LK_ + original table + column as it allows easier navigation when browsing all tables.

LK_metals_metal_type

What are your views on this?

Thanks

Hannah Vernon
  • 70,041
  • 22
  • 171
  • 315
cecilli0n
  • 305
  • 1
  • 4
  • 9

1 Answers1

7

Technically no there isn't a standard for table naming conventions. As long as you use something consistent across your environment there shouldn't be a problem. It should also be well documented as to why you are using this prefix.

That being said however here are few rules that I follow. IAlwaysBookEndMyTables the reason for doing this is it make it clear to read without any spaces or underscores. The reason I don't use underscores is that I'm a SQL server guy and they can be used as a wild card. When naming a lookup table I've typically used LU. Once again this doesn't matter as long as you are doing things consistently. LKMetalsMetalType isn't really any different from LUMetalsMetalType.

One other thing be as descriptive with your table names as possible. Whoever picks up after you leave a project should be able to look at your table structure and have a good idea what's going on. There's plenty of room for a long table name but very limited sanity in trying to figure out what the heck the Pl_uva table means. FYI that was just an example.

I shouldn't have to say this and am assuming you already know but I'll say it anyway. Do not use reserved words or include spaces in your table names. I swear to god I saw a guy on Stack Overflow yesterday who had named a column "from" so it was literally.

SELECT
    [FROM]
FROM HisTable
Zane
  • 3,511
  • 3
  • 24
  • 45