No Skill? Or NoSQL?

It’s already been a year since I first learned the MySQL. SQL in MySQL stands for Structured Query Language, a relational database management system (R-DBMS) widely used in websites around the world. It single-handedly fetch and insert data to a database in many well-structured tables. Now, now. While SQL is good at fetching data, it has a quite limitation that if the data are just too many, the query itself may take a longer time to perform the query. It is usually tolerable, however in game development, it is unforgivable.

Here comes the competitor of MySQL: the NoSQL Database. Contrary to the MySQL which hold data in a well-structured tables, NoSQL stores data in a very ill-structured, or I can say “Unstructured”. Yes, since performance is the highest priority in NoSQL Database, the “unstructured” structure of NoSQL is quite good. Well, if it is not because of my internship projects which demand me to use the NoSQL Database for Game Development, it is highly unlikely that I would touch this right now.

Well, I assumed that many of you has already touch MySQL, why don’t we take a look at MongoDB, a NoSQL DBMS.MongoDB store the data in an unstructured schema, just like my favorite database written in XML format. What makes MongoDB win rather than XML is:

  • No need for to create a custom query for fetching. Standard XML is supoorted by many platform, however most of the time you have to make your own deserializer (many dev-tools already support data to XML serializer)
  • Less overhead than XML. Because MongoDB use JSON (Javascript Object Notation) format, it has less overhead in the file itself. What is overhead? It is analogous to the time to perform something. Higher overhead, the worse. Just take a look at the example below, it is clear that XML uses much more characters rather than needed just to extract the data.
    XML Format JSON Format
        "user": {
            "address": {

The NoSQL can be downloaded at: It is highly recommended that you download the x64 version, since the x64 version knows how to handle RAM up to 4GB, rather than the x32 which only handle up to 2GB RAM.

Assumed that you use Microsoft Windows, just download the zip, extracted it at someplace, and you’re ready to go.

OK, since this one is just like the old MySQL, we need to run the service itself, or the Mongo DB Daemon. But, before you run, first thing first that you need to do is make a folder where to put the database itself. By default, MongoDB will store the data in C:\data\db, however I prefer to store it in F:\MongoDB\data\db. Whatever you coose, however you still have to make the folder first. Create the folder, and you’re ready to: Start the Daemon

To start the daemon, you can just open a cmd and type this in the folder mongoDB/bin:

  • Use default C:\data\db:
  • Use custom path (e.g.: F:\MongoDB\data\db):
    mongod --dbpath "F:\MongoDB\data\db"

Or you can just type that code snippets in your lovely Notepad++, and save it as mongod-start.bat. If you the latter, all you have to do each time is just double click the .bat file.

Now, to test you newly running MongoDB Daemon, run the mongo.exe. By default, it will use the test database collation. To change the collation, just type: use <any_name_you_wish>, for example: use GameDB

Now that we have the database, you can see that the database collation itself will take 64MB of your harddisk. Wow. Don’t worry, since this is normal. This is the way MongoDB minimize the I/O between each data collecting. FYI, it is quite similar to Google BigTable, and of course, this MongoDB is equipped with the so-called MapReduce Optimation.

This GameDB collation has no data yet. It’s time to make collection. Collection is a term that somewhat similar to the MySQL’s infamous Table. However, there is no single command in the MongoDB to create a new collection. Don’t worry, because the MongoDB will automatically make the collection the very first time you instance an object to that collection.

For example, I want to make a collection named User, and the first data is Edgar, 21 years old, live in Bandung, Indonesia. Type this:

db.User.add({name: "Edgar", age: 21, address: {city: "Bandung", country: "Indonesia"}});

Furthermore, I want to add next data which is Drake, Programmer, 2D Puzzle Specialist. Can I do this? Of course I can. Since this one is an unstructured database, I can add anything I want. Just type:

db.User.add({name: "Drake", job: "Programmer", specialization: "2D Puzzle Specialist"});

And voila, you got it. Just type db.User.find() to show all the data inside User collection.

Alright, now that you have the very basic of the MongoDB usage, the most important thing in this DBMS is usage right? Right, you can use this to make a web. There are some people who made the driver for MongoDB fo PHP 5, but I won’t discuss it right away. I just want to introduce the NoSQL to you, so you can learn something new. MongoDB in PHP is not that hard, but you need to learn several native function built inside the Mongo class. For further tutorial, you can use this link to learn more about MongoDB by yourself: Tutorial & SQL Mapping to MongoDB Script

FYI, in ITB, NoSQL is a 7th semester course in the name of Non-Relational Database, a course taught by Prof. Benhard S, so this one maybe become a good starter before you take the course. Of course, I wouldn’t even bother to take his course, LOL.

2 thoughts on “No Skill? Or NoSQL?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s