September 29, 2014

Mafia Game Monday (MGM) – Importance of Integrity

Hey all,

So, you are an owner of a game, and in order for this game to run with users, you have a database that stores all of the information about the users. Well, in order for users to interact with your game, it will require input from the user in many different ways.

Ok, you all know that already, but what does this have to do with the topic of this post?

What is Integrity?

Integrity can mean various different things, but the base definition is that the data will fit and make sense when interacting with a page as well as interacting with a database. It can also mean ensuring the “truth”, or lack of unauthorized modification, of data during transit.

What are the Types of Integrity?

There are multiple types of integrity. They are:

  • Data Integrity – This is ensuring that the data has not been modified during the transit of the data.
  • Referential Integrity – This is verifying that in a database with a table that uses a foreign key, the value of a foreign key matches a primary key value in the table that uses that column as a primary key (of course when linked appropriately).

How to Ensure Data Integrity?

Well, it is very difficult to completely ensure data integrity, especially without full control over the environment that is used for the service (such as using a hosting company to store your site); however, there are a couple things that you can do in order to ensure data integrity. They are the following:

  1. Check ALL Data BEFORE Entering Into Database – This is extremely important. Without validating the data that is being put into your database, an intruder could easily do a SQL injection attack in order to gain access to your data. If you do not know what SQL injection is, check out the link here.
  2. Only Give Input to Users That is Absolutely Required – Attacks such as SQL injection cannot occur if the user cannot input data, so if users do not necessarily have to input data in order to change the outcome, then simply do not give the users the ability to input any data. This will make data integrity a whole lot easier with no direct user input!

In terms of referential integrity, this is a great tool to use when you are creating tables that are directly dependent upon other tables. Foreign keys are a great way to do this, and foreign keys by default usually automatically configure referential integrity. If you have a table that is dependent upon another table, enforce a foreign key! This will ensure that the foreign key value in one table is a value that is by no doubt a primary key value in the other table.

What are your thoughts on integrity? What are your methods to help ensure integrity?

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470