Categories
Programming

MySQL : An Introduction

What is MySQL?

MySQL is a Relational Database Management System owned by Oracle Corporation. The open source RDBMS is based on structured query language or SQL. MySQL, where “My” is named after the daughter of its co-founder Mr. Michael Widenius and the SQL on the query abbreviation, is compatible on Linux, Unix & Windows OS. Usually, its use is in the Web application/programming & other online publishing. MySQL is open-source & free to use. However, you can pay Oracle to get commercial license & access premium services. It is considered easier as compared to SQL, Oracle Database & MS SQL Server.


Click image to enlarge 

MySQL is also related to LAMP. Linux-Apache-MySQL-PHP (LAMP) is an open source stack, used in Web-development. The stack includes Linux as Operating System, Apache as the server, PHP as object-oriented scripting language & MySQL as RDBMS. Python or Perl are also an alternative for PHP.


MySQL’s History:

Originally MySQL was founded/created by MySQL AB. A Swedish company which defunct in 2008. Sun Microsystems acquired MySQL AB in 2008. In 2010, Oracle bought Sun Microsystems which again changed the owner. Currently, Oracle Corporation is the owner of MySQL. People can use MySQL for free under GNU GPL (General Public License). But for enterprises, they need to buy a commercial license.


Click image to enlarge 

Working:

To understand the working of MySQL, we will elaborate an example. Suppose there are few things; Server, Computer, PHP, Business, User, Domain name, server page, MySQL Database & Website. Imagine you have a business & you have a website too. Your site provides username & password to your customers. Suppose every customer has got a username & password. Now we will see how MySQL works.

A user goes to your website entering domain address/website link. The page opens up, and they enter their details. The entered details will be sent to a PHP script. It will check, what the user has entered. Then it will be taken to the MySQL page & if it’s into the MySQL database, the user will be allowed to view the website. You fill the MySQL Database because you have entered customer details & provided them username & password.


Features:

  • Relational Database System
  • Client-Server Model
  • Client/Server Architecture
  • SQL Compatibility
  • Stored procedures
  • Triggers
  • Replication
  • User Interface
  • Transactions
  • GIS Functions
  • ODBC
  • Platform Independence
  • Fast & Efficient

SQL – The language of databases:

SQL or Structured query language is a standard language of databases. It is used to access databases. There are three major parts of SQL as follows:

  • Data Definition language
  • Data Manipulation language
  • Data Control language

Click image to enlarge 

MySQL & PHP:

Data that we see on a website is in the form of tables & columns. However we aren’t able to see it, but yes, they are made up of tables & columns (considering alignments too). So whatever data we want to view on the website, we need to do it through tables & columns. Suppose we are having data of around 100 customers & we want to put it on our website. We will put it on the digital table.

A basic website contains four parts; Navigation bar, Sidebar, main content & footer. Using MySQL & PHP, we can get greater advantages as compared to Excel. We can perform multiple tasks or can sort data easily. Meanwhile, Excel doesn’t offer many features. We also use a scripting language like “JavaScript” to make the website more dynamic. These scripting languages go to the user’s computer for instant feedback.

Example: Sometimes we find pages where we have an arrow for Up & down. These arrows are made using JavaScript or similar languages. By the way, JavaScript isn’t created by Java.

PHP is a server-side scripting language usually used for web programming. Rasmus Lerdorf created it in 1994. PHP stands for Personal Home Page. However, now it is known as Hypertexy Preprocessor language. PHP can work alongside HTML & its output is pretty impressive.

MySQL is a database system. MySQL stores the data in the form of tables called as database objects. These tables are a set of rows & columns or collection of entries. MySQL is useful when people or organizations want to store information categorically.

A MySQL database table contains one or more tables. Each table needs to be named & they have rows with data.


Example:

PersonCountryCityState
AAustraliaMelbourneVictoria
BUnited StatesDallasTexas

Above table contains 2 records (one for each person) & 4 columns.


PHP/MySQL Functions:

  1. mysql_query() Function:
    • Used to execute a query on MySQL Database
    • Fetches & buffers the recordset
    • Run an unbuffered query, use mysql_unbuffered_query()
  2. mysql_num_rows() Function:
    • Returns the number of rows in a recordset
    • Returns FALSE on the failure of SQL Query execution

Why PHP & MySQL?


PHP:

  • Server-side scripting language
  • Hypertext Processor
  • Are executed on the server
  • Database supportable (MySQL, Oracle, Informix, Sybase, PostgreSQL, etc.)
  • Open source software
  • Free
  • Can work with HTML
  • Extensions: “.php”, “.php3”, “.phtml”

MySQL:

  • Database server
  • Ideal for small & large applications
  • Supports SQL
  • Compatible
  • Free

PHP accompanied by MySQL are cross-platform You can use it for web applications in Windows & can be even served on UNIX.


XAMPP:

MySQL codes can be executed using XAMPP. Most of the people tend to use it. So below are a few necessary steps:

  • MySQL comes with XAMPP Server package, so no need to download it externally
  • Firstly, start the XAMPP Control Panel & over the web browser type http://localhost/phpmyadmin
  • MySQL starts!
  • Now go to Databases & click on create.
  • Give it a name & your database is created successfully

Few forks of MySQL:

  • Drizzle: lightweight open source RDBMS
  • MariaDB
  • Percona Server with XtraDB

Conclusion:

It was an introduction of what MySQL is & what all things it can do. We have discussed components of it including XAMPP. Firstly, we talked a short intro of MySQL then we moved on to its history. Secondly, we explained how it works with an example. MySQL has got a lot of features to talk about, but we have explored a few in this article. Later on we will cover more about PHP & MySQL, the relation between them and why people opt for PHP & MySQL.


After covering these essential elements, we got XAMPP. XAMPP is an open source server that you can use for different databases.

Check out our Introduction to PHP and MySQL Course if you are interested in learning the subject.

By Dynamic Web Training

Dynamic Web Training is Australia's leading provider of instructor led software training.

We offer training courses in Adobe, Web Design, Graphic Design, Photoshop, InDesign, Dreamweaver and many more.