Create relations in MySQL database using phpmyadmin

After reading this article, you will be able to create relations in MySQL database using phpmyadmin. If for some reasons you don't want to use phpmyadmin, please look at SQL queries below.

So, what reason to store relations in the database? After all, your application also solves this task. Actually, it's all about the restrictions and actions upon changes, which can be set using relations.

For example, you can deny deleting category while any article connected with it. Or remove all articles if category removed. Or set NULL in relation field. In any case, using relations increases fault tolerance and reliability of the application.

You need to use an InnoDB engine to create a relation. Only this engine supports foreign keys. If you have MyISAM tables, you can read how convert it to InnoDB.

Converting table engine in MySQL

Sometimes you need to convert the table engine MySQL in an existing database.

For example, I needed to create relationships between tables. To create them, the tables must be InnoDB (to support foreign keys).

Old Wordpress (and other) projects use MyISAM because until version MySQL 5.5.4 it was the default engine. But it doesn't support many useful features, such as foreign keys, transactions, etc. All these features are supported by the more modern engine InnoDB, which is now used by default.

Form without tables

To create a form using tables, even a beginner webmaster can do it, but for formatting a tableless form, some skills are required. Let's consider a simple example, such as a login form.

Using templates in Symfony framework. (Lesson 7. Twig)

Using templates in Symfony framework can be done in several ways. First, you can use PHP templates. But the preferred option is to use the Twig template engine (by default). Twig is a compiling open-source template engine written in PHP. It produces PHP/HTML code as output. Besides being very functional, Twig is also very fast.

Usage of QwtPlotSpectrogram

Previously, we learned to use the QwtPlotSpectrocurve component (here). Qwt provides an alternative component that is more convenient for visualizing analytical functions. In this note, we will learn how to use QwtPlotSpectrogram.

Setting PHP timezone in php.ini

During the work with Symfony framework, I received the following warning:

Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/symfony/app/cache/prod/classes.php on line 5009

In fact, there is nothing to worry about or unusual - this was caused by updating PHP to version 5.4, and since the new version was installed next to the old one with new configs, it was necessary to configure the PHP timezone in php.ini again. First, we need to find out which timezone we are in. More precisely, how it should be specified in the PHP config.