MySQL Tutorial

Many dynamic websites require a back end database. The database can contain information that the web pages display to the user, or the purpose of the database might be to store information provided by the user. In some applications, the database both provides available information and stores new information.

MySQL is the most popular database for use in websites. It is particularly popular for use with websites that are written in PHP as PHP and MySQL work well together.

Ultimate Guide | String Functions | Numeric Functions | Date Functions

MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language.

Normalization is a database design technique which organizes tables in a manner that reduces redundancy and dependency of data. It divides larger tables to smaller tables and links them using relationships.

MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Some of the original developers of MySQL forked it due to concerns over its acquisition by Oracle Corporation. Its lead developer is Michael "Monty" Widenius, one of the founders of MySQL AB. MariaDB is named after Monty's younger daughter Maria, similar to how MySQL is named after his other daughter My.

MySQL is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language. MySQL is a component of the LAMP open-source web application software stack. LAMP is an acronym for "Linux, Apache, MySQL, Perl/PHP/Python".

A FOREIGN KEY is a key used to link two tables together. It is a field (or collection of fields) in one table that refers to the Primary Key in another table. The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.

The PRIMARY KEY uniquely identifies each record in a database table. Primary keys must contain UNIQUE values, and cannot contain NULL values. A table can have only one primary key, which may consist of single or multiple fields.

The CREATE TABLE statement is used to create a new table in a database. The column specifies the name of the column of the table. The datatype parameter specifies the type of data the column can hold.

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. It is also used to add and drop various constraints on an existing table.

The DROP TABLE statement is used to drop or completely delete an existing table in a database. Deleting a table will result in loss of complete information stored in the table.

MySQL stores information in different formats. It allows different types of data to be used in different ways. The main types of data are character, numerical, and date and time. When you create a database, you tell MySQL what kind of data to expect in a particular column by using the MySQL names for data types.

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There are two wildcards used in conjunction with the LIKE operator:

  1. % : The percent sign represents zero, one, or multiple characters.
  2. _ : The underscore represents a single character.

The SELECT statement is used to select data from a database. The data returned is stored in a result table.

The DELETE statement is used to delete existing records in a table.

The UPDATE statement is used to modify the existing records in a table.

A field with a NULL value is a field with no value. If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.

The INSERT INTO statement is used to insert new records in a table.

SQL is almost like simple English. It’s made up largely of English words, put together into strings of words that sound similar to English sentences.

The MySQL software consists of the MySQL server, several utility programs that assist in the administration of MySQL databases, and some supporting software that the MySQL server needs. The heart of the system is the MySQL server.

After you have planned your database, you can then build it. A database has two parts

  1. Structure to hold the data
  2. Data

In many cases, you often need to get data from multiple tables in a single query. You can use JOIN clause to get data from multiple tables in your single SQL query. A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

A database needs to be able to receive information for storage and to deliver information on request.

The first step in creating a database is to design it. You create the database and its tables according to the design you developed.