Databases are one thing in the modern development environments without which the world will come to a halt. Right from the small web applications which manage your to-do lists to those like Amazon, databases give them the life, the dynamism which drives the world 2.0 and beyond. QCubed
is one framework which takes care of handling databases a whole lot. Yeah, of course you have to create the tables and set them up yourself. QCubed is a development framework after all, not a frontend
to your DBMS! But there are a lot of thing which you do not have to worry about as long as you are with QCubed. We will talk about all of them in detail, later on. For now, we will introduce you to the wonders. Let's begin.
If you have been to Computer classes in your college days, chances are you are familiar with this term. The SQL (Structured Query Language) is the language in which you ask your database to insert, select, update and delete data from the tables you want according to the filters you set. But that is not easy to work with when you have tables with large numbers of attributes. QCubed makes sure that all the tables are treated as classes and the entries (the rows) are objects. It uses code generation to make sure that you do not have to mess with the queries. Instead, create an object of the class to which a table corresponds and you have all the insertion, deletion, selection and update functions made ready for you. Impressive huh? Some people might complain that there are better ways than code generation for the sake of saving disk space on the server. Some might love to have a framework which does all that dynamically. However, as the history of computing goes, there is always a performance-memory trade off. QCubed chooses to sacrifice a little bit of more space to allow better CPU utilization.
MySQL is great and so is PostgreSQL or Oracle or even MS SQL Server. Let us say you created an application utilizing MySQL but now you want to use PostgreSQL's features and the integrity it provides to data. Stuck? No. You would not be with QCubed. The SQL syntax of MySQL is quite different from that of PostgreSQL but since you do not have to write SQL queries for the databases, there is no reason to be afraid. Just convert your database from MySQL to PostgreSQL (well, there are a lot of conversion tools available, and the command line can work well enough too with some gray matter) and change the settings in configuration.inc.php file to point to the new database and you are good to go. Now that is is insanely easy. Oh, and yes, if you want to practice the old school lessons of SQL, you can do that as well, QCubed does allow you to write your own custom queries. Well, we think it is an important thing to tell that because querying databases with QCubed is just so addictive and easy that one might forget SQL. Completely!
So you have set up everything but there are times when one database is not sufficient enough. You might want to have a separate database to handle the payments whose tables you do not want to mess up with the database your web application uses normally to create the pages. Do not worry. QCubed will allow you to declare any number of additional databases you want to add. All you have to do is to make sure that you have selected the right database before you query (well, most of the time you don't have to even worry about that). Depending on what you want to do in your web application, this can be immensely useful.
There are a whole lot of other things you can do with QCubed for handling your databases the right way. But that is something huge and we better learn it in detail, later. The things such as querying the databases, using relationships, indexes and foreign keys, many to many relationships, applying custom logics into database handler classes (and more) are very interesting topics and we are going to examine them in detail in the coming pages.