Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights.

Slides:



Advertisements
Similar presentations
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Advertisements

CSE 1561 A Brief MySQL Primer Stephen Scott. CSE 1562 Introduction Once you’ve designed and implemented your database, you obviously want to add data.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2014 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
SQL Data Definition II Stanislava Armstrong 1SQL Data Definition II.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2014 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
CSC 2720 Building Web Applications Database and SQL.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Copyright © Curt Hill Index Creation SQL.
Introduction to SQL Steve Perry
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
CSC 405: Web Application And Engineering II7.1 Database Programming with SQL Aggregation and grouping with GROUP BY Aggregation and grouping with GROUP.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Introduction to Internet Databases MySQL Database System Database Systems.
CSC 2720 Building Web Applications Database and SQL.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
11-1 Copyright  Oracle Corporation, All rights reserved. What Are Constraints? Constraints enforce rules at the table level. Constraints prevent.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
Visual Programing SQL Overview Section 1.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2016, Fred McClurg, All Rights.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
LAB: Web-scale Data Management on a Cloud Lab 11. Query Execution Plan 2011/05/27.
CS320 Web and Internet Programming SQL and MySQL
SQL Creating and Managing Tables
Kirkwood Center for Continuing Education
SQL Creating and Managing Tables
Lecturer: Mukhtar Mohamed Ali “Hakaale”
SQL Creating and Managing Tables
Chapter 4 Indexes.
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Rob Gleasure robgleasure.com
SQL NOT NULL Constraint
Presentation transcript:

Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights Reserved.

Chapter Nine Database Tuning slides/chapter09e.performance.ppt (Improving Performance) 2

Database Performance via Indexes What is an index? Defined: Mechanism that enables a database to locate a record in row rapidly (e.g. table of contents or textbook index) Best Practice Don’ts: 1.Don’t index every column a.Indexing uses extra storage space b.Additional time is required to create indexed columns during data insert c.Too many indexes increase search time to locate record 2.Don’t index primary keys, they are already indexed 3

Database Performance via Index Selection What to index: 1.Columns in a WHERE clause SELECT * FROM authors WHERE author = 'Max Lucado'; WHERE author = 'Max Lucado'; // author should be indexed 2.Columns in an ORDER BY clause SELECT * FROM contacts ORDER BY person; ORDER BY person; // person should be indexed 3.Columns in MIN and MAX clauses SELECT MAX(elevation) FROM mountain; // elevation should be indexed 4

Database Performance via Index Creation Creating an Index Indexing upon table creation: CREATE TABLE employee ( id INT NOT NULL id INT NOT NULL AUTO_INCREMENT, // id AUTO_INCREMENT, // id name VARCHAR(11), name VARCHAR(11), INDEX name_ix(name) ); INDEX name_ix(name) ); Indexing an existing table: CREATE INDEX name_ix ON employee(name); employee(name); 5

Database Performance via Unique Index Creating an Unique Index Unique Index upon table creation: CREATE TABLE employee ( id INT NOT NULL id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT, ss_number VARCHAR(11), ss_number VARCHAR(11), UNIQUE ss_uq(ss_number) ); UNIQUE ss_uq(ss_number) ); Unique Index for an existing table: CREATE UNIQUE INDEX ss_uq ON employee(ss_number); employee(ss_number); 6

Database Performance via Multiple Index Multiple Column Index Description: Unlike primary keys, an index can be applied to multiple columns. Multi-column unique key, for example, could assure that the combination of two columns is unique. Example: CREATE UNIQUE INDEX state_uq ON location(city, state); location citystate ManhattanKS ManhattanNY 7

Query Performance (Before Indexing) Explain: Analyzes the efficiency of the SQL statement. Example: EXPLAIN SELECT * FROM author WHERE name = 'John MacArthur'; idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra 1SIMPLEauthorALLNULL 7 Using where Explain Explained: type: ALL means every record is scanned to determine match. possible_keys: NULL means no index defined. key: NULL means no key is used by query. rows: Number of rows searched for query (there are 7 records in DB). 8

Query Performance (After Indexing) Example: ALTER TABLE author ADD CONSTRAINT name_uq UNIQUE(name); DESCRIBE author; EXPLAIN SELECT * FROM author WHERE name = 'John MacArthur'; FieldTypeNullKeyDefaultExtra idint(11)NOPRINULLauto_increment namevarchar(40)NOUNINULL idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra 1SIMPLEauthorconstname_uq 42const1 9

to be continued... slides/chapter09f.administration.ppt slides/chapter09f.administration.ppt10