Yes, adding a prefix that denotes the type of the object is a problem, and unnecessary. Because,
- Sometimes objects begin life as something but will end up becoming something else. (e.g. table
tblXxx
was split into tblXxxY
and tblXxxZ
for some reason and replaced with a view that joins the two new tables. Now you have a view called tblXxx
).
- When you type
tbl
in the editor, its AutoComplete feature hangs for 45 seconds and then shows you a list of 4000 entries.
But...
I'm going to play devil's advocate and say something others have outright advised against. There are some rare cases a suffix/prefix could be useful, and here's an example from the organization I work for.
We have an entity based ERP system, where the business logic is written in Oracle PL/SQL. It's nearly two decades old, yet a very stable system (This is not a legacy system. We are continuously developing it).
The system is entity based, and each entity associates a table, multiple views, multiple PL/SQL packages, and a host of other database objects.
Now, we want the objects belonging to the same entity to have the same name but yet to be distinguishable of it's purpose and type. So, if we have two entities that are named CustomerOrder
and CustomerInvoice
, we'll have following objects:
- Tables to store data [
TAB
suffix]:
CUSTOMER_ORDER_TAB
CUSTOMER_INVOICE_TAB
.
- Views that are used by clients [No suffix]:
CUSTOMER_ORDER
CUSTOMER_INVOICE
.
- Interface for basic operations; (PL/SQL packages) [
API
suffix]:
CUSTOMER_ORDER_API
CUSTOMER_INVOICE_API
.
- Report generators; (PL/SQL packages) [
RPI
suffix]:
CUSTOMER_ORDER_RPI
CUSTOMER_INVOICE_RPI
.
- Indexes for primary keys [
PK
suffix]:
CUSTOMER_ORDER_PK
CUSTOMER_INVOICE_PK
.
- Secondary indexes [
IX
suffix]:
CUSTOMER_ORDER_XXX_IX
CUSTOMER_INVOICE_XXX_IX
(where XXX
describes the usage of the index).
- ... and so on.
This is indeed a form of Apps Hungarian (note that same type of objects can have different suffixes depending on the purpose). But, with a suffix instead of a prefix. I can't tell you enough how this system is so easy to read. IntelliSense actually works because instead of typing TBL
and getting 4000 results, I can type Customer
and get all the objects belonging to entities named Customer*
.
So, here I have showed you how metadata can be useful. The purpose is to have a related set of database objects identifiable by a single name, yet differentiate them based on their purpose.
Having said that, if you don't have this kind of system, there is no use of either prefixing or suffixing the type of object.
Note that we haven't used suffixes like _table
, _package
, or _view
(i.e. the type of the object). For example, both (3) and (4) are PL/SQL packages, yet use a different suffix. It's the same for (5) and (6), both of which are indexes. So the suffix is based on purpose rather than the type.
Class
?Wrdthis wrdis wrda wrdsimple wrdsentence.
or this one:This is a simple sentence.
?