× Home About us Contact Us Contributor Guidelines – All Perfect Stories Register Submit Your Stories
Database Schema Design
By JOEL BORTHWICK 1,828 views
BUSINESS

Best Practices for Database Schema Design

In this article we will look at some of the most common database design decisions you need to make when defining a schema. Our focus will be on the planning phase as well as our opinion of the best method. We will also look at a few basic guidelines which may or may not suit your needs. We will not be looking at the engineering aspect of database design but our focus is to provide tips for making something that’s easy to work with data. Plus, we will not be discussing any advanced or intermediate concepts in this article. If you want to use a schema designer this article will still come in handy.

Understanding Usage Patterns 

There are two ways in which databases are used. The first would be for OLTP or Online Transaction Processing and the other for DSS or Decision Support Systems. So, depending on the usage patterns, you may want to Denormalize or Normalize the data.

Generally, an OLTP database will consist of many microtransactions. Take for instance a banking system where a many little modifications will take place throughout the banking day. There will be constant debits and credits as well as managing registered accounts, updating the balance and security logs.

The goal of an OLTP database is to organize data in a way which does not have duplicate fields or data which is repeated. So, you can have the customer name in one column of one table, and multiple orders will consequently link back to that one column with the customer’s name. By breaking down data into different columns and tables, we are normalizing it.

Choosing Naming Conventions

We wouldn’t personally want to influence your naming conventions because everyone uses their own style and so they may want to adhere to the ISO standard like ISO-11179. Whatever convention you choose consistency is important.

Ideally, you’ll want to avoid just having just the ID in the PK of the table as it leads to many aliases when multiple tables are joined and when several tables return numerous IDs. Also, have a list of SQL Server words that are reserved like Date, User, etc. If you use a reserved word, it will spit out a syntax error unless you specify its value which in turn will slow down development and lengthen the statements.

Always use Constraints

You should use constraints like allowed values, fields, unique values at a database level which will help to ensure data validation and integrity. These checks will not just be the place where validation takes place but one of the places. You should have validation within the front end of the app as well. If a validation issue is caught an error should be displayed to the user.

A well-handled validation error should be baked into the process so if it is missed by the application the database can snag it but which will render a more archaic type error message. The key is to make sure that the error is caught in time and which did not lead to the database being defiled. Also, if you have constraints defined within the database many of the latest applications should be able to pull up those errors and add them to the application which is then rendered to the screen with all the necessary elements.

Conclusion

We are hopeful that these tips will set you on the right path to ensure good database design practices. Planning is one of the keys to success in the world of database administration. You can also prove your design by using various code generators like Iron Speed Designer which allows you to work with the data in a similar fashion.

Joel Borthwick
Author
JOEL BORTHWICK

Joel Borthwick is basically from Australia but is keen to explore everything under the sun. He is a part-time blogger, well acclaimed for his blogs on topics like - home improvement, business, lifestyle, health, travel and fashion. He aims to solve day-to-day problems of people through his blogs.