HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

MySQL similar name for status or type column

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
columnstatustypemysqlnameforsimilar

Problem

As status and type is reserved key in MySQL, I need a column name similar to status to identify the status of a row.

I know there is way to ignore this problem but in different language and different framework it suddenly arise this problem in different way, so I need to ignore this word and need a similar word that sound almost same and can be understandable from the name.

The potential values for my use case are true/false. What do you suggest to name a Boolean column that defines the status of that row?

Here status is defining that row if it is active or inactive. And not every where I'm using status column for this purpose, Somewhere status column is defining if the status is pending, current, confirmed, applied, rejected, etc. Like this shorts of key.

Solution

As a_horse_with_no_name commented:


I typically include the entities name with that, e.g. person_status or element_type. That also makes reading queries easier (at least in my eyes)

...it is better to include more information with those column names in order to make them more easily understandable.

For example you in a user table you could have a user_status and user_type column and those names would clearly define exactly what you are referring to with status and type. It would make it even more useful if those columns where using reference tables such as user_status and user_type.

Those are just examples. The table name could be modified to indicate that it is a reference table such as r_user_status or user_status_ri. Or one can work on making it more generic (but still more descriptive than status), so that it can be used for more tables. This would also allow you to remove repeated data that might need updating, and move the update to a single table for when you might need to change the text of an existing status.

In the end avoiding generic names such as status and type will make it much easier for developers who join the project later on to easily understand the data and its relationships.

Context

StackExchange Database Administrators Q#186498, answer score: 6

Revisions (0)

No revisions yet.