01 - Introduction To MySQL
01 - Introduction To MySQL
01 MySQL Introduction
Dr. Mostafa Elgendy
2
Agenda
❖ Introduction
❖ MySQL Introduction
❖ SQL Introduction
❖ Summary
Introduction
❖ Database System: The DBMS software together with the data itself. Sometimes,
the applications are also included.
❖ Software + Database
❖ MySQL is probably the most popular database management system(DBMS) for web
servers.
❖ Free to use
❖ MySQL is very friendly to PHP, the most appreciated language for web development.
❖ Row: A single record within a table, which may contain several fields
MySQL Introduction
❖ There are three main ways you can interact with MySQL:
❖ C:\xampp\mysql\bin
❖ mysql -u root
❖ SHOW databases;
❖ There are six different prompts that MySQL may present you with.
❖ Creating a database:
MySQL
❖ Using database:
USE publications;
MySQL
Database changed
output
❖ Creating users:
MySQL
output
❖ Table:
output
❖ Renaming a table:
MySQL
output
❖ Attribute:
❖ Attribute has :
❖ Both accept text strings and impose a limit on the size of the field
❖ The difference is that every string in a CHAR field has the specified size.
❖ A VARCHAR field does not pad the text; it lets the size of the field vary to fit the text.
❖ AUTO_INCREMENT attribute:
❖ Primary_Key attribute:
❖ an attribute of an entity type for which each entity must have a unique value; e.g.,
SSN of EMPLOYEE
❖ The attributes of a foreign key in one entity are the attributes of a primary key in
another entity;
MySQL
output
❖ Renaming a column:
MySQL
❖ Removing a column:
MySQL
❖ Deleting a table:
SQL Introduction
SQL
❖ The first form doesn't specify the column names, only their values:
❖ INSERT INTO table_name VALUES (value1, value2, value3,...)
❖ The second form specifies both the column names and the values to
be inserted:
❖ INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
SQL
❖ Note: The WHERE clause specifies which record or records that should be
updated. If you omit the WHERE clause, all records will be updated!
Before
After
After
❖ Syntax
Before
After
❖ Syntax:
SQL
SQL
❖ Syntax
SQL
SQL
SQL
MySQL
SQL
❖ The AND operator displays a record if both the first condition and the
second condition is true.
SQL
SQL
SQL
❖ Syntax
❖ SELECT column_name(s) FROM table_name
ORDER BY column_name(s) ASC|DESC
SQL
SQL
❖ Introduction
❖ MySQL Introduction
❖ SQL Introduction
❖ Summary