SlideShare une entreprise Scribd logo
1  sur  64
MySQL Database System Hiep Dinh CS 157B-Section 2
2-Tier Architecture Web Browser (Client) Web Server PHP
3-Tier Architecture Web Browser (Client) Database Server Web Server PHP
Installation Summary ,[object Object],[object Object],[object Object],[object Object]
Command Line Client ,[object Object],[object Object],[object Object],[object Object]
Client-Server Interaction MySQL Server Client Program Make a request (SQL query) Get results Client program can be a MySQL command line client, GUI client, or a program written in any language such as C, Perl, PHP, Java that has an interface to the MySQL server.
Connecting to the Server ,[object Object],[object Object],[object Object],[object Object],[object Object]
WARNING WARNING ,[object Object],[object Object],[object Object]
Entering commands (1) ,[object Object],[object Object],mysql> SHOW DATABASES; +-------------+ | Database  | +-------------+ | bookstore  | | employee_db | | mysql  | | student_db  | | test  | | web_db  | +-------------+
Entering commands (2) ,[object Object],[object Object],mysql> USE test; Database changed mysql> SHOW tables; +----------------+ | Tables_in_test | +----------------+ | books  | | name2  | | names  | | test  | +----------------+ 4 rows in set (0.00 sec) mysql>
Entering commands (3) ,[object Object],[object Object],mysql> DESCRIBE names; +-----------+-------------+------+-----+---------+----------------+ | Field  | Type  | Null | Key | Default | Extra  | +-----------+-------------+------+-----+---------+----------------+ | id  | int(11)  |  | PRI | NULL  | auto_increment | | firstName | varchar(20) |  |  |  |  | | lastName  | varchar(20) |  |  |  |  | +-----------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) mysql>
Entering commands (4) ,[object Object],[object Object],mysql> SELECT * FROM names; +----+-----------+------------+ | id | firstName | lastName  | +----+-----------+------------+ |  1 | Fred  | Flintstone | |  2 | Barney  | Rubble  | +----+-----------+------------+ 2 rows in set (0.00 sec) mysql>
Entering commands (5) ,[object Object],[object Object],[object Object],mysql> INSERT INTO names (firstName, lastName) VALUES ('Ralph', 'Quarry'); Query OK, 1 row affected (0.02 sec) mysql> SELECT * FROM names; +----+-----------+------------+ | id | firstName | lastName  | +----+-----------+------------+ |  1 | Fred  | Flintstone | |  2 | Barney  | Rubble  | |  3 | Ralph  | Quarry  | +----+-----------+------------+ 3 rows in set (0.00 sec) mysql>
Entering commands (6) ,[object Object],[object Object],[object Object],mysql> UPDATE names SET lastName = 'Stone' WHERE id=3; Query OK, 1 row affected (0.28 sec) Rows matched: 1  Changed: 1  Warnings: 0 mysql> SELECT * FROM names; +----+-----------+------------+ | id | firstName | lastName  | +----+-----------+------------+ |  1 | Fred  | Flintstone | |  2 | Barney  | Rubble  | |  3 | Ralph  | Stone  | +----+-----------+------------+ 3 rows in set (0.00 sec) mysql>
Logging output ,[object Object],[object Object],[object Object]
Executing SQL files (1) ,[object Object],[object Object],[object Object],[object Object]
Executing SQL files (2) ,[object Object],[object Object],[object Object]
Documentation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Database concepts (1) ,[object Object],[object Object],[object Object],isbn title author pub year price books table rows (records) column headings
Some SQL data types (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Some SQL data types (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL data types (3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL commands SHOW, USE ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  CREATE  Command (1) ,[object Object],CREATE TABLE table_name (   column_name1 column_type1,   column_name2 column_type2,   ...   column_nameN column_typeN ); Note: To create a database use the statement CREATE db_name;
The CREATE Command (2) ,[object Object],CREATE TABLE table_name (   column_name1 column_type1 NOT NULL   DEFAULT '0',   column_name2 column_type2,   ...   column_nameN column_typeN,   PRIMARY KEY (column_name1) );
The CREATE Command (3) ,[object Object],CREATE TABLE table_name (   column_name1 column_type1 PRIMARY   KEY NOT NULL DEFAULT '0'   AUTO_INCREMENT,   column_name2 column_type2,   ...   column_nameN column_typeN, );
The CREATE Command (4) ,[object Object],[object Object]
Conditional Creation ,[object Object],[object Object],[object Object],[object Object]
The DROP Command ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Note: Don't confuse  DROP  with  DELETE  which deletes rows of a table.
The INSERT Command ,[object Object],INSERT INTO table_name   ( col_1, col_2, ..., col_N) VALUES   ( val_1, val_2, ..., val_N); String values are enclosed in single quotes by default but double quotes are also allowed. Literal quotes need to be escaped using apos; and amp;quot;
The SELECT Command (1) ,[object Object],[object Object],[object Object],[object Object],SELECT column_list FROM table_name; SELECT * FROM table_name; SELECT column_list FROM table_name WHERE condition;
The SELECT Command (2) ,[object Object],[object Object],SELECT column_list FROM table_name WHERE condition ORDER by ASC; SELECT column_list FROM table_name WHERE condition ORDER by DESC;
The SELECT Command (3) ,[object Object],[object Object],[object Object],SELECT COUNT(id) FROM table_name
The UPDATE Command ,[object Object],[object Object],UPDATE table_name SET col_1 = 'new_value1', ..., col_n = 'new_value2'; UPDATE table_name SET col_1 = 'new_value1', ..., col_n = 'new_value2' WHERE condition;
marks.sql (1) studentID first_name USE  test; CREATE TABLE  marks (   studentID SMALLINT AUTO_INCREMENT  NOT NULL ,   first_name  VARCHAR (20)  NOT NULL ,   last_name  VARCHAR (20)  NOT NULL ,   mark  SMALLINT  DEFAULT 0  NOT NULL ,   PRIMARY KEY (studentID) ); marks table last_name mark
marks.sql (2)  -- Insert some rows into marks table INSERT INTO  marks (first_name, last_name,   mark)  VALUES  ('Fred', 'Jones', 78); INSERT INTO  marks (first_name, last_name,   mark)  VALUES  ('Bill', 'James', 67); INSERT INTO  marks (first_name, last_name,   mark)  VALUES  ('Carol', 'Smith', 82); INSERT INTO  marks (first_name, last_name,   mark)  VALUES  ('Bob', 'Duncan', 60); INSERT INTO  marks (first_name, last_name,   mark)  VALUES  ('Joan', 'Davis', 86);
Executing The Script ,[object Object],[object Object],[object Object]
The Marks Table  ,[object Object],SELECT  *  FROM  marks; +-----------+------------+-----------+------+ | studentID | first_name | last_name | mark | +-----------+------------+-----------+------+ |  1 | Fred  | Jones  |  78 | |  2 | Bill  | James  |  67 | |  3 | Carol  | Smith  |  82 | |  4 | Bob  | Duncan  |  60 | |  5 | Joan  | Davis  |  86 | +-----------+------------+-----------+------+ 5 rows in set (0.00 sec)
The WHERE Clause (1) ,[object Object],SELECT  *  FROM  marks  WHERE  studentID > 1   AND  studentID < 5; +-----------+------------+-----------+------+ | studentID | first_name | last_name | mark | +-----------+------------+-----------+------+ |  2 | Bill  | James  |  67 | |  3 | Carol  | Smith  |  82 | |  4 | Bob  | Duncan  |  60 | +-----------+------------+-----------+------+ 3 rows in set (0.01 sec)
The WHERE Clause (2) ,[object Object],SELECT  *  FROM  marks  WHERE  mark >= 80; +-----------+------------+-----------+------+ | studentID | first_name | last_name | mark | +-----------+------------+-----------+------+ |  3 | Carol  | Smith  |  82 | |  5 | Joan  | Davis  |  86 | +-----------+------------+-----------+------+ 2 rows in set (0.00 sec)
The ORDER BY Clause ,[object Object],SELECT  *  FROM  marks  ORDER BY  mark  DESC ; +-----------+------------+-----------+------+ | studentID | first_name | last_name | mark | +-----------+------------+-----------+------+ |  5 | Joan  | Davis  |  86 | |  3 | Carol  | Smith  |  82 | |  1 | Fred  | Jones  |  78 | |  2 | Bill  | James  |  67 | |  4 | Bob  | Duncan  |  60 | +-----------+------------+-----------+------+ 5 rows in set (0.00 sec)
Searching Using LIKE (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Searching Using LIKE (2) ,[object Object],[object Object],SELECT  *  FROM  marks  WHERE  last_name   LIKE   'J%' ; SELECT  *  FROM  marks  WHERE  first_name   LIKE   '_ _ _' ;
Quoting strings ,[object Object],[object Object],SELECT  *  FROM  marks  WHERE  last_name   =  'Oapos;Reilly' ;
Limiting number of rows ,[object Object],[object Object],[object Object],[object Object],[object Object]
MySQL Functions (1) ,[object Object],[object Object],SELECT   COUNT (*)  FROM  marks; +----------+ | COUNT(*) | +----------+ |  5 | +----------+ 1 row in set (0.00 sec)
MySQL Functions (2) ,[object Object],SELECT   SUM (mark)  FROM  marks; +-----------+ | SUM(mark) | +-----------+ |  373 | +-----------+ 1 row in set (0.00 sec)
MySQL Functions (3) ,[object Object],SELECT   AVG (mark)  FROM  marks; +-----------+ | AVG(mark) | +-----------+ |  74.6000 | +-----------+ 1 row in set (0.00 sec)
MySQL Functions (4) ,[object Object],SELECT   MIN (mark)  FROM  marks; +-----------+ | MIN(mark) | +-----------+ |  60 | +-----------+ 1 row in set (0.00 sec)
MySQL Functions (5) ,[object Object],SELECT   MAX (mark)  FROM  marks; +-----------+ | MAX(mark) | +-----------+ |  86 | +-----------+ 1 row in set (0.00 sec)
books.sql (1) USE  web_db; CREATE TABLE  books (   isbn  CHAR (15)  PRIMARY KEY NOT NULL ,   title  VARCHAR (100)  NOT NULL ,   author  VARCHAR (100)  NOT NULL ,   pub  VARCHAR (20)  NOT NULL ,   year YEAR NOT NULL,   price  DECIMAL (9,2)  DEFAULT NULL ); books table this is a simple design isbn title author pub year price
books.sql (2)  -- Insert some books into books table INSERT INTO  books  VALUES  ( '0-672-31784-2' ,   'PHP and MySQL Web Development' ,   'Luke Welling, Laura Thomson' ,   'Sams' , 2001, 74.95 ); INSERT INTO  books  VALUES  ( '1-861003-02-1' ,   'Professional Apache' ,   'Peter Wainwright' ,   'Wrox Press Ltd' , 1999, 74.95 );
Executing The Script ,[object Object],[object Object],[object Object]
employee_db.sql (1) CREATE DATABASE IF NOT EXISTS  employee_db; USE  employee_db; DROP TABLE IF EXISTS  employees; DROP TABLE IF EXITS  jobs; employees table jobs table employeeID name position address employeeID hours
employee_db.sql (1) CREATE TABLE  employees (   employeeID  SMALLINT NOT NULL ,   name  VARCHAR (20)  NOT NULL ,   position  VARCHAR (20)  NOT NULL ,   address  VARCHAR (40)  NOT NULL ,   PRIMARY KEY  (employeeID) ); INSERT INTO  employees  VALUES  (1001, 'Fred',   'programmer', '13 Windle St'); INSERT INTO  employees  VALUES  (1002, 'Joan',   'programmer', '23 Rock St'); INSERT INTO  employees  VALUES  (1003, 'Bill',   'manager', '37 Front St');
employee_db.sql (2) CREATE TABLE  jobs (   employeeID  SMALLINT NOT NULL ,   hours  DECIMAL (5,2)  NOT NULL , ); INSERT INTO  jobs  VALUES  (1001, 13.5); INSERT INTO  jobs  VALUES  (1002, 2); INSERT INTO  jobs  VALUES  (1002, 6.25); INSERT INTO  jobs  VALUES  (1003, 4); INSERT INTO  jobs  VALUES  (1001, 1); INSERT INTO  jobs  VALUES  (1003, 7); INSERT INTO  jobs  VALUES  (1003, 9.5);
Executing The Script ,[object Object],[object Object],[object Object]
Select Queries With Joins (1) ,[object Object],SELECT  *  FROM  employees, jobs; +------------+------+------------+--------------+------------+-------+ | employeeID | name | position  | address  | employeeID | hours | +------------+------+------------+--------------+------------+-------+ |  1001 | Fred | programmer | 13 Windle St |  1001 | 13.50 | |  1002 | Joan | programmer | 23 Rock St  |  1001 | 13.50 | |  1003 | Bill | manager  | 37 Front St  |  1001 | 13.50 | |  1001 | Fred | programmer | 13 Windle St |  1002 |  2.00 | |  1002 | Joan | programmer | 23 Rock St  |  1002 |  2.00 | |  1003 | Bill | manager  | 37 Front St  |  1002 |  2.00 | |  1001 | Fred | programmer | 13 Windle St |  1002 |  6.25 | |  1002 | Joan | programmer | 23 Rock St  |  1002 |  6.25 | |  1003 | Bill | manager  | 37 Front St  |  1002 |  6.25 |
Select Queries With Joins (2) ,[object Object],|  1001 | Fred | programmer | 13 Windle St |  1003 |  4.00 | |  1002 | Joan | programmer | 23 Rock St  |  1003 |  4.00 | |  1003 | Bill | manager  | 37 Front St  |  1003 |  4.00 | |  1001 | Fred | programmer | 13 Windle St |  1001 |  1.00 | |  1002 | Joan | programmer | 23 Rock St  |  1001 |  1.00 | |  1003 | Bill | manager  | 37 Front St  |  1001 |  1.00 | |  1001 | Fred | programmer | 13 Windle St |  1003 |  7.00 | |  1002 | Joan | programmer | 23 Rock St  |  1003 |  7.00 | |  1003 | Bill | manager  | 37 Front St  |  1003 |  7.00 | |  1001 | Fred | programmer | 13 Windle St |  1003 |  9.50 | |  1002 | Joan | programmer | 23 Rock St  |  1003 |  9.50 | |  1003 | Bill | manager  | 37 Front St  |  1003 |  9.50 | +------------+------+------------+--------------+------------+-------+ 21 rows in set (0.01 sec) The cartesian product query is rarely what we want.
Select Queries With Joins (3) ,[object Object],+------+-------+ | name | hours | +------+-------+ | Fred | 13.50 | | Joan |  2.00 | | Joan |  6.25 | | Bill |  4.00 | | Fred |  1.00 | | Bill |  7.00 | | Bill |  9.50 | +------+-------+ 7 rows in set (0.00 sec) Here we are replacing the employeeID numbers in the jobs table by the employee's name SELECT  name, hours  FROM  employees, jobs  WHERE employees.employeeID = jobs.employeeID;
Select Queries With Joins (4) ,[object Object],+------+-------+ | name | hours | +------+-------+ | Fred | 13.50 | | Fred |  1.00 | +------+-------+ 2 rows in set (0.00 sec) SELECT  name, hours  FROM  employees, jobs  WHERE employees.employeeID = jobs.employeeID AND name = 'Fred';
Select Queries With Joins (5) ,[object Object],+------+------------+ | name | SUM(hours) | +------+------------+ | Bill |  20.50 | | Fred |  14.50 | | Joan |  8.25 | +------+------------+ 3 rows in set (0.00 sec) SELECT  name, SUM(hours)  FROM  employees, jobs WHERE  employees.employeeID = jobs.employeeID GROUP BY  name;
Select Queries With Joins (6) ,[object Object],+------+------------+ | name | SUM(hours) | +------+------------+ | Fred |  14.50 | +------+------------+ 1 row in set (0.00 sec) SELECT  name, SUM(hours)  FROM  employees, jobs WHERE  employees.employeeID = jobs.employeeID AND name = 'Fred'  GROUP BY  name;
SQL links ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances (19)

MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
mySQL and Relational Databases
mySQL and Relational DatabasesmySQL and Relational Databases
mySQL and Relational Databases
 
MySQL Built-In Functions
MySQL Built-In FunctionsMySQL Built-In Functions
MySQL Built-In Functions
 
Sql
SqlSql
Sql
 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
 
Boost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitionsBoost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitions
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-note
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 
data constraints,group by
data constraints,group by data constraints,group by
data constraints,group by
 
Sql analytic queries tips
Sql analytic queries tipsSql analytic queries tips
Sql analytic queries tips
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Les09
Les09Les09
Les09
 

En vedette

Agcapita January 2010 Economy Briefing
Agcapita January 2010 Economy BriefingAgcapita January 2010 Economy Briefing
Agcapita January 2010 Economy BriefingVeripath Partners
 
Weekly Market Update,September 11, 2009
Weekly Market Update,September 11, 2009Weekly Market Update,September 11, 2009
Weekly Market Update,September 11, 2009Jeff Green
 
Agcapita Feb 2010 Agriculture Briefing
Agcapita Feb 2010 Agriculture BriefingAgcapita Feb 2010 Agriculture Briefing
Agcapita Feb 2010 Agriculture BriefingVeripath Partners
 

En vedette (6)

VMware Performance
VMware Performance VMware Performance
VMware Performance
 
Agcapita January 2010 Economy Briefing
Agcapita January 2010 Economy BriefingAgcapita January 2010 Economy Briefing
Agcapita January 2010 Economy Briefing
 
Weekly Market Update,September 11, 2009
Weekly Market Update,September 11, 2009Weekly Market Update,September 11, 2009
Weekly Market Update,September 11, 2009
 
Agcapita Feb 2010 Agriculture Briefing
Agcapita Feb 2010 Agriculture BriefingAgcapita Feb 2010 Agriculture Briefing
Agcapita Feb 2010 Agriculture Briefing
 
Get Your Business Online
Get Your Business OnlineGet Your Business Online
Get Your Business Online
 
The Internet
The InternetThe Internet
The Internet
 

Similaire à mysqlHiep.ppt

My sql with querys
My sql with querysMy sql with querys
My sql with querysNIRMAL FELIX
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxEliasPetros
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql SyntaxReka
 
MYSQL
MYSQLMYSQL
MYSQLARJUN
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2Raj vardhan
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL Rc Os
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfpradnyamulay
 
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018teachersduniya.com
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleFarhan Aslam
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQLNaeem Junejo
 

Similaire à mysqlHiep.ppt (20)

MySQL
MySQLMySQL
MySQL
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
MYSQL
MYSQLMYSQL
MYSQL
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
 
Module 3
Module 3Module 3
Module 3
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Mysql
MysqlMysql
Mysql
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
 
SQL
SQLSQL
SQL
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQL
 

Plus de webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guidewebhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serverswebhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidationwebhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructurewebhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.pptwebhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandiserswebhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Productswebhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mbwebhostingguy
 

Plus de webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

mysqlHiep.ppt

  • 1. MySQL Database System Hiep Dinh CS 157B-Section 2
  • 2. 2-Tier Architecture Web Browser (Client) Web Server PHP
  • 3. 3-Tier Architecture Web Browser (Client) Database Server Web Server PHP
  • 4.
  • 5.
  • 6. Client-Server Interaction MySQL Server Client Program Make a request (SQL query) Get results Client program can be a MySQL command line client, GUI client, or a program written in any language such as C, Perl, PHP, Java that has an interface to the MySQL server.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. marks.sql (1) studentID first_name USE test; CREATE TABLE marks ( studentID SMALLINT AUTO_INCREMENT NOT NULL , first_name VARCHAR (20) NOT NULL , last_name VARCHAR (20) NOT NULL , mark SMALLINT DEFAULT 0 NOT NULL , PRIMARY KEY (studentID) ); marks table last_name mark
  • 36. marks.sql (2) -- Insert some rows into marks table INSERT INTO marks (first_name, last_name, mark) VALUES ('Fred', 'Jones', 78); INSERT INTO marks (first_name, last_name, mark) VALUES ('Bill', 'James', 67); INSERT INTO marks (first_name, last_name, mark) VALUES ('Carol', 'Smith', 82); INSERT INTO marks (first_name, last_name, mark) VALUES ('Bob', 'Duncan', 60); INSERT INTO marks (first_name, last_name, mark) VALUES ('Joan', 'Davis', 86);
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51. books.sql (1) USE web_db; CREATE TABLE books ( isbn CHAR (15) PRIMARY KEY NOT NULL , title VARCHAR (100) NOT NULL , author VARCHAR (100) NOT NULL , pub VARCHAR (20) NOT NULL , year YEAR NOT NULL, price DECIMAL (9,2) DEFAULT NULL ); books table this is a simple design isbn title author pub year price
  • 52. books.sql (2) -- Insert some books into books table INSERT INTO books VALUES ( '0-672-31784-2' , 'PHP and MySQL Web Development' , 'Luke Welling, Laura Thomson' , 'Sams' , 2001, 74.95 ); INSERT INTO books VALUES ( '1-861003-02-1' , 'Professional Apache' , 'Peter Wainwright' , 'Wrox Press Ltd' , 1999, 74.95 );
  • 53.
  • 54. employee_db.sql (1) CREATE DATABASE IF NOT EXISTS employee_db; USE employee_db; DROP TABLE IF EXISTS employees; DROP TABLE IF EXITS jobs; employees table jobs table employeeID name position address employeeID hours
  • 55. employee_db.sql (1) CREATE TABLE employees ( employeeID SMALLINT NOT NULL , name VARCHAR (20) NOT NULL , position VARCHAR (20) NOT NULL , address VARCHAR (40) NOT NULL , PRIMARY KEY (employeeID) ); INSERT INTO employees VALUES (1001, 'Fred', 'programmer', '13 Windle St'); INSERT INTO employees VALUES (1002, 'Joan', 'programmer', '23 Rock St'); INSERT INTO employees VALUES (1003, 'Bill', 'manager', '37 Front St');
  • 56. employee_db.sql (2) CREATE TABLE jobs ( employeeID SMALLINT NOT NULL , hours DECIMAL (5,2) NOT NULL , ); INSERT INTO jobs VALUES (1001, 13.5); INSERT INTO jobs VALUES (1002, 2); INSERT INTO jobs VALUES (1002, 6.25); INSERT INTO jobs VALUES (1003, 4); INSERT INTO jobs VALUES (1001, 1); INSERT INTO jobs VALUES (1003, 7); INSERT INTO jobs VALUES (1003, 9.5);
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.