SlideShare a Scribd company logo
Let’s work with Database (MySql)
Author:- Subhasis
CMC
MySql & RDBMS
• MySQL is a Relational Database Management
  System (RDBMS).
• server can manage many databases at the same
  time.
• In fact many people might have different databases
  managed by a single MySQL server.
• Each database consists of a structure to hold the
  data and the data itself.
• A database can exist without data.
Cont’d …..
• Data in a database is stored in one or more
  tables.
Cont’d ….
• First you create the empty database.
• Then you add empty tables to the database.
• Table is organized with in rows and columns.
• Each row represents an entity in the database
• Each column contains an item of information about
  the entity.
• The place where a particular row and column
  intersect, the individual cell of the table, is called a
  field.
Cont’d …..
• Tables in databases can be related.
• Often a row in one table is related to several
  rows in another table.
• You include a column in one table to hold data
  that matches data in the column of another
  table.
Related tables
Communicating with DataBase
• All our interaction with the database is
  accomplished by passing messages to the MySQL
  server.
• It must be able to understand the instructions that
  you send it.
• So we communicate using Structured Query
  Language (SQL), which is a standard computer
  language     understood    by    most      database
  management systems
Cont’d …..

• To make a request that MySQL can understand,
  you build an SQL query and send it to the
  MySQL server.
Building SQL queries
• The first word of each query is its name name, which is an
  action word (a verb) that tells MySQL what we want to do.
• Queries we discuss here:
  ▫   CREATE
  ▫   DROP
  ▫   ALTER
  ▫   SHOW
  ▫   INSERT
  ▫   LOAD
  ▫   SELECT
  ▫   UPDATE
  ▫   DELETE
Cont’d ….

• The query name is followed by words and
  phrases — some required and some optional —
  that tell MySQL how to perform the action.
• For insntace we have to tell the table name to
  which we want to insert the data.
Don’t forget

• SQL language words in all caps.
• SQL words must be separated by one or more
  spaces.
• Put the string within double quote.
Sending SQL query
• We can send sql query to do what we desire to do
  using:
 ▫ The mysql client - A text-based mysql client is
   automatically installed when we install MYSQL.
 ▫ Administration software - Separate software
   packages that are available can provide a more user-
   friendly interface for interacting with MySQL than the
   mysql client does.
 ▫ PHP built in function –we communicate with a
   MySQL database from PHP scripts by using PHP built-
   in functions designed specifically for this purpose.
Using the mysql client
• To send SQL queries to MySQL from the mysql client,
  follow these steps:
 A. Locate the mysql client(it is in bin of your mysql
    directory) we can start it fom Command prompt of
    Windows
 B. To start command is (mysql -u root -p)
 C. If you are in network then you need command (mysql -h
    mysqlhost.mycompany.com -u root -p)
 D. At the mysql prompt, type your SQL query followed by a
    semicolon (;) and then press Enter.
 E. To leave the mysql client, type quit at the prompt and
    then press Enter.
Using Administration software
• To work with mySql using admin software We need
  these steps as follow:
 A. Open your browser and access the phpMyAdmin
    main page.(localhost:Portnumber/phpmyadmin)
 B. Click the down arrow in the databases field in the
    left pane of the phpMyAdmin page. Click the name
    of the database you want to open.
 C. Click the SQL link near the top center of the page.
 D. Type your SQL query in the text area
 E. Click Go below the query text area.
Protect Ur DB before hacked
• MySQL accounts: No one can access the data in
  your database without an account. Sp protect ur
  database with a strong password.
• Permissions: MySQL uses account permissions
  to specify who can do what. Differentiate the
  tasks using different user name and password
  for different tasks.
Designing Database
Field
• The individual cell in which a particular row and
  column intersect is called a field.
Better to be organized
• The table name should clearly identify the
  objects that it contains with a descriptive word
  or term.
• Column name must speaks about hat will be
  filled in it.
• Name of column and table is case sensitive.
• Identify the primary key
Cont’d ….
Creating table
• To cretae table we need CREATE TABLE
  command as follows.


 CREATE TABLE table_name ( column_name NOT NULL PRIMARY
 KEY,
 column_name VARCHAR(37) NOT NULL,
 column_name VARCHAR(2) NULL );
SELECT command
• To fetch / read data we need SELECT command.
• We will search the record and show them using
  SELECT command.
              SELECT * from employee;
• To search something specific we need WHERE
  clause. SELECT * from employee WHERE
                designation=‘manager’;
Where to put single quote
ORDER BY
• ORDER BY clause is to ensure that the result set produced by
  the query is returned in the specified sequence. Simply,
  ORDER BY sorts the results.
• Following the ORDER BY keywords is at least one column
  with an optional ASC (ascending) or DESC (descending)
  keyword; if neither is specified, ascending is the default.


                ORDER BY column [ASC | DESC]
                  [, column [ASC | DESC]] ⋮
INSERT command
• The INSERT statement inserts one or more
  rows.


INSERT INTO table name (colm1, colm2, colm3..)
VALUES (valu1,value2,value3,vlaue4);
UPDATE command
 • The UPDATE DML statement is similar to the ALTER DDL
   statement in that it produces a change.
 • The difference is that, whereas ALTER changes the
   structure of a table, UPDATE changes the data contained
   within a table, while the table’s structure remains the same.


UPDATE table_name SET column_name = ‘value’;

UPDATE table_name SET column_name = ‘value’
WHERE column_name=‘value’;
DELETE command
 • The DELETE DML statement is similar to the DROP DDL
   statement, in that it removes objects from the database. The
   difference is that DROP removes a table from the
   database, while DELETE removes entire rows of data
   from a table, but the table continues to exist.

DELETE FROM table_name WHERE
column_name = ‘value’;

More Related Content

PPTX
Introduction databases and MYSQL
PDF
BITS: Introduction to MySQL - Introduction and Installation
PPTX
Introduction to my_sql
PPTX
MySql:Introduction
PPT
MySQL and its basic commands
PDF
Introduction to php database connectivity
PDF
4.3 MySQL + PHP
Introduction databases and MYSQL
BITS: Introduction to MySQL - Introduction and Installation
Introduction to my_sql
MySql:Introduction
MySQL and its basic commands
Introduction to php database connectivity
4.3 MySQL + PHP

What's hot (19)

PPTX
Database Connectivity in PHP
PPTX
Introduction to database
ODP
Ms sql-server
PPT
Mysql ppt
PDF
Sql a practical introduction
PPT
Working with Databases and MySQL
DOCX
Android database tutorial
PPTX
SQL for interview
PDF
lab56_db
ODP
Database Connection With Mysql
PPT
MYSQL - PHP Database Connectivity
PPT
Database presentation
PPTX
SQL interview questions by Jeetendra Mandal - part 2
PDF
BITS: Introduction to relational databases and MySQL - Schema design
PPT
PPT
php basic sql
PPTX
Mysql
PPT
MySQL lecture
Database Connectivity in PHP
Introduction to database
Ms sql-server
Mysql ppt
Sql a practical introduction
Working with Databases and MySQL
Android database tutorial
SQL for interview
lab56_db
Database Connection With Mysql
MYSQL - PHP Database Connectivity
Database presentation
SQL interview questions by Jeetendra Mandal - part 2
BITS: Introduction to relational databases and MySQL - Schema design
php basic sql
Mysql
MySQL lecture
Ad

Similar to Php, mysq lpart5(mysql) (20)

PPTX
Getting Started with MySQL I
PDF
Introduction to MySQL and introduction to basic queries
PPTX
Using Mysql.pptx
PDF
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
PPTX
Mysql-overview.pptx
PPTX
sql.pptx
PDF
Chapter – 6 SQL Lab Tutorial.pdf
PPT
MySQL Database System Hiep Dinh
PPT
mysqlHiep.ppt
PDF
Mysql basics1
PDF
sql10.pdfNGBHJHYGKIIIIYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
PPT
mySQL and Relational Databases
PDF
sql.pdf
PPT
My sql with querys
PPTX
Data Base Management 1 Database Management.pptx
PPTX
unit-ii.pptx
PPTX
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
PPTX
MySQL Essential Training
PDF
LECTURE NOTES.pdf
PDF
LECTURE NOTES.pdf
Getting Started with MySQL I
Introduction to MySQL and introduction to basic queries
Using Mysql.pptx
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
Mysql-overview.pptx
sql.pptx
Chapter – 6 SQL Lab Tutorial.pdf
MySQL Database System Hiep Dinh
mysqlHiep.ppt
Mysql basics1
sql10.pdfNGBHJHYGKIIIIYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
mySQL and Relational Databases
sql.pdf
My sql with querys
Data Base Management 1 Database Management.pptx
unit-ii.pptx
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
MySQL Essential Training
LECTURE NOTES.pdf
LECTURE NOTES.pdf
Ad

More from Subhasis Nayak (20)

PDF
working with database using mysql
PDF
Php, mysq lpart3
PDF
Php, mysq lpart4(processing html form)
PPT
PPT
Jsp 02(jsp directives)2003
PPT
Php, mysq lpart1
PPT
Php, mysqlpart2
PPTX
C:\fakepath\jsp01
PPTX
Servlet & jsp
PPT
J2ee connector architecture
PPT
how to create object
PDF
Pointer in c++ part3
PDF
Pointer in c++ part2
PDF
Pointer in c++ part1
PDF
C++ arrays part2
ODP
C++ arrays part1
PDF
Introduction to network
PDF
Flow control in c++
PPT
Oops And C++ Fundamentals
PPT
Text mode Linux Installation Part 01
working with database using mysql
Php, mysq lpart3
Php, mysq lpart4(processing html form)
Jsp 02(jsp directives)2003
Php, mysq lpart1
Php, mysqlpart2
C:\fakepath\jsp01
Servlet & jsp
J2ee connector architecture
how to create object
Pointer in c++ part3
Pointer in c++ part2
Pointer in c++ part1
C++ arrays part2
C++ arrays part1
Introduction to network
Flow control in c++
Oops And C++ Fundamentals
Text mode Linux Installation Part 01

Recently uploaded (20)

PPTX
Week 4 Term 3 Study Techniques revisited.pptx
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
English Language Teaching from Post-.pdf
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
From loneliness to social connection charting
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Week 4 Term 3 Study Techniques revisited.pptx
UPPER GASTRO INTESTINAL DISORDER.docx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
O7-L3 Supply Chain Operations - ICLT Program
Revamp in MTO Odoo 18 Inventory - Odoo Slides
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Cardiovascular Pharmacology for pharmacy students.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
English Language Teaching from Post-.pdf
The Final Stretch: How to Release a Game and Not Die in the Process.
From loneliness to social connection charting
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Open Quiz Monsoon Mind Game Prelims.pptx

Php, mysq lpart5(mysql)

  • 1. Let’s work with Database (MySql) Author:- Subhasis CMC
  • 2. MySql & RDBMS • MySQL is a Relational Database Management System (RDBMS). • server can manage many databases at the same time. • In fact many people might have different databases managed by a single MySQL server. • Each database consists of a structure to hold the data and the data itself. • A database can exist without data.
  • 3. Cont’d ….. • Data in a database is stored in one or more tables.
  • 4. Cont’d …. • First you create the empty database. • Then you add empty tables to the database. • Table is organized with in rows and columns. • Each row represents an entity in the database • Each column contains an item of information about the entity. • The place where a particular row and column intersect, the individual cell of the table, is called a field.
  • 5. Cont’d ….. • Tables in databases can be related. • Often a row in one table is related to several rows in another table. • You include a column in one table to hold data that matches data in the column of another table.
  • 7. Communicating with DataBase • All our interaction with the database is accomplished by passing messages to the MySQL server. • It must be able to understand the instructions that you send it. • So we communicate using Structured Query Language (SQL), which is a standard computer language understood by most database management systems
  • 8. Cont’d ….. • To make a request that MySQL can understand, you build an SQL query and send it to the MySQL server.
  • 9. Building SQL queries • The first word of each query is its name name, which is an action word (a verb) that tells MySQL what we want to do. • Queries we discuss here: ▫ CREATE ▫ DROP ▫ ALTER ▫ SHOW ▫ INSERT ▫ LOAD ▫ SELECT ▫ UPDATE ▫ DELETE
  • 10. Cont’d …. • The query name is followed by words and phrases — some required and some optional — that tell MySQL how to perform the action. • For insntace we have to tell the table name to which we want to insert the data.
  • 11. Don’t forget • SQL language words in all caps. • SQL words must be separated by one or more spaces. • Put the string within double quote.
  • 12. Sending SQL query • We can send sql query to do what we desire to do using: ▫ The mysql client - A text-based mysql client is automatically installed when we install MYSQL. ▫ Administration software - Separate software packages that are available can provide a more user- friendly interface for interacting with MySQL than the mysql client does. ▫ PHP built in function –we communicate with a MySQL database from PHP scripts by using PHP built- in functions designed specifically for this purpose.
  • 13. Using the mysql client • To send SQL queries to MySQL from the mysql client, follow these steps: A. Locate the mysql client(it is in bin of your mysql directory) we can start it fom Command prompt of Windows B. To start command is (mysql -u root -p) C. If you are in network then you need command (mysql -h mysqlhost.mycompany.com -u root -p) D. At the mysql prompt, type your SQL query followed by a semicolon (;) and then press Enter. E. To leave the mysql client, type quit at the prompt and then press Enter.
  • 14. Using Administration software • To work with mySql using admin software We need these steps as follow: A. Open your browser and access the phpMyAdmin main page.(localhost:Portnumber/phpmyadmin) B. Click the down arrow in the databases field in the left pane of the phpMyAdmin page. Click the name of the database you want to open. C. Click the SQL link near the top center of the page. D. Type your SQL query in the text area E. Click Go below the query text area.
  • 15. Protect Ur DB before hacked • MySQL accounts: No one can access the data in your database without an account. Sp protect ur database with a strong password. • Permissions: MySQL uses account permissions to specify who can do what. Differentiate the tasks using different user name and password for different tasks.
  • 17. Field • The individual cell in which a particular row and column intersect is called a field.
  • 18. Better to be organized • The table name should clearly identify the objects that it contains with a descriptive word or term. • Column name must speaks about hat will be filled in it. • Name of column and table is case sensitive. • Identify the primary key
  • 20. Creating table • To cretae table we need CREATE TABLE command as follows. CREATE TABLE table_name ( column_name NOT NULL PRIMARY KEY, column_name VARCHAR(37) NOT NULL, column_name VARCHAR(2) NULL );
  • 21. SELECT command • To fetch / read data we need SELECT command. • We will search the record and show them using SELECT command. SELECT * from employee; • To search something specific we need WHERE clause. SELECT * from employee WHERE designation=‘manager’;
  • 22. Where to put single quote
  • 23. ORDER BY • ORDER BY clause is to ensure that the result set produced by the query is returned in the specified sequence. Simply, ORDER BY sorts the results. • Following the ORDER BY keywords is at least one column with an optional ASC (ascending) or DESC (descending) keyword; if neither is specified, ascending is the default. ORDER BY column [ASC | DESC] [, column [ASC | DESC]] ⋮
  • 24. INSERT command • The INSERT statement inserts one or more rows. INSERT INTO table name (colm1, colm2, colm3..) VALUES (valu1,value2,value3,vlaue4);
  • 25. UPDATE command • The UPDATE DML statement is similar to the ALTER DDL statement in that it produces a change. • The difference is that, whereas ALTER changes the structure of a table, UPDATE changes the data contained within a table, while the table’s structure remains the same. UPDATE table_name SET column_name = ‘value’; UPDATE table_name SET column_name = ‘value’ WHERE column_name=‘value’;
  • 26. DELETE command • The DELETE DML statement is similar to the DROP DDL statement, in that it removes objects from the database. The difference is that DROP removes a table from the database, while DELETE removes entire rows of data from a table, but the table continues to exist. DELETE FROM table_name WHERE column_name = ‘value’;