

If possible, use a single word that exactly describes what is in the table. These are tables like employee, customer, city, and country. If you’re naming entities that represent real-world facts, you should use nouns. My suggestion would be to always go with names in the singular. When naming tables, you have two options – to use the singular for the table name or to use a plural. For separating words in the database object name, use underscore Hint: Use lower letters when naming database objects. In case you have something specific for your database, you can list all such exceptions in one short document. That shall be especially the case if you’re using the most common naming convention rules. If it’s readable, anybody who jumps into the project should be aware of what is where and how the data is related.

One more reason to use it is that you probably won’t be the only one working with the database. If you apply best practices from the start and continue using them when you add new objects, you’ll keep your database structure well organized and easily readable. Therefore, you can expect that the database will stay, more or less, very similar to its’ initial production version. Maybe you’ll even change the language used to write the code.

Sqlite stored procedures allowed code#
On the other hand, the code can change during time. The main reason is that if you change the name of the database object that could affect many places in your code. Changes at the database level are usually avoided and done only when necessary. If that wasn’t enough, there is also one good reason.

Also, it will be much easier to query the INFORMATION_SCHEMA database in search of specific patterns – e.g., checking if all tables have the primary key attribute named “id” do we have a stored procedure that performs an insert for each table, etc. It will increase the overall model readability, and you’ll spend less time finding what you need. One of these rules would be to apply a naming convention. Usually, you’ll have hundreds of tables, and if you don’t want to have a complete mess, you should follow some organizational rules. Databases rarely have a small number of tables. Maybe the most important reason to use it is to simplify life to yourself. Why should you use the naming convention? In this article, I’ll try to use these rules you’ll meet in most cases. While most rules are pretty logical, you could go with some you’ve invited (e.g., you could call a primary key attribute “id”, or “ID”), and that is completely up to you. That part is completely up to you.Īlso, using the naming convention is not the rule, but it’s desired. Of course, you could decide to only set naming convention rules for tables and column names. You’ll apply these rules while naming anything inside the database – tables, columns, primary and foreign keys, stored procedures, functions, views, etc. I’ve already stated it in the intro, but more generally, a naming convention is a set of rules you decide to go with before you start modeling your database. This time we won’t talk about the data itself, but rather about the database objects and the way they were named. We’ll use the same data model we’re using in this series. Today, I’ll try to explain how you should formulate your naming convention and, maybe even more important, why should you do it and what is the overall benefit from using it. A naming convention is a set of unwritten rules you should use if you want to increase the readability of the whole data model.
