What is MySQL?
MySQL is a relational database management system
MySQL is open-source
MySQL is free
MySQL is ideal for both small and large applications
MySQL is very fast, reliable, scalable, and easy to use
MySQL is cross-platform
MySQL is compliant with the ANSI SQL standard
MySQL was first released in 1995
MySQL is developed, distributed, and supported by Oracle Corporation
MySQL is named after co-founder Monty Widenius's daughter: My
Who Uses MySQL?
Huge websites like Facebook, Twitter, Airbnb, Booking.com, Uber,
GitHub, YouTube, etc.
Content Management Systems like WordPress, Drupal, Joomla!,
Contao, etc.
A very large number of web developers around the world
Show Data On Your Web Site
To build a web site that shows data from a database, you will need:
An RDBMS database program (like MySQL)
A server-side scripting language, like PHP
To use SQL to get the data you want
To use HTML / CSS to style the page
What is RDBMS?
RDBMS stands for Relational Database Management System.
RDBMS is a program used to maintain a relational database.
RDBMS is the basis for all modern database systems such as MySQL,
Microsoft SQL Server, Oracle, and Microsoft Access.
RDBMS uses SQL queries to access the data in the database.
What is a Database Table?
A table is a collection of related data entries, and it consists of columns and
rows.
A column holds specific information about every record in the table.
A record (or row) is each individual entry that exists in a table.
Look at a selection from the Northwind "Customers" table:
CustomerID CustomerName ContactName Address City
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin
2 Ana Trujillo Emparedados y Ana Trujillo Avda. de la Constitución México
helados 2222 D.F.
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México
D.F.
4 Around the Horn Thomas Hardy 120 Hanover Sq. London
5 Berglunds snabbköp Christina Berguvsvägen 8 Luleå
Berglund
The columns in the "Customers" table above are: CustomerID,
CustomerName, ContactName, Address, City, PostalCode and Country. The
table has 5 records (rows).
What is a Relational Database?
A relational database defines database relationships in the form of tables.
The tables are related to each other - based on data common to each.
Look at the following three tables "Customers", "Orders", and "Shippers"
from the Northwind database:
Customers Table
CustomerID CustomerName ContactName Address City
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin
2 Ana Trujillo Emparedados y Ana Trujillo Avda. de la Constitución México
helados 2222 D.F.
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México
D.F.
4 Around the Horn Thomas Hardy 120 Hanover Sq. London
5 Berglunds snabbköp Christina Berguvsvägen 8 Luleå
Berglund
The relationship between the "Customers" table and the "Orders" table is the
CustomerID column:
Orders Table
OrderID CustomerID EmployeeID OrderDate
10278 5 8 1996-08-12
10280 5 2 1996-08-14
10308 2 7 1996-09-18
10355 4 6 1996-11-15
10365 3 3 1996-11-27
10383 4 8 1996-12-16
10384 5 3 1996-12-16
The relationship between the "Orders" table and the "Shippers" table is the
ShipperID column:
Shippers Table
ShipperID ShipperName Phone
1 Speedy Express (503) 555-9831
2 United Package (503) 555-3199
3 Federal Shipping (503) 555-9931
Keep in Mind That...
SQL keywords are NOT case sensitive: select is the same as SELECT
In this tutorial we will write all SQL keywords in upper-case.
Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL
statement.
Semicolon is the standard way to separate each SQL statement in database
systems that allow more than one SQL statement to be executed in the
same call to the server.
In this tutorial, we will use semicolon at the end of each SQL statement.
Some of The Most Important SQL
Commands
SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index