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

Slides:



Advertisements
Similar presentations
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Advertisements

Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
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. 1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
1 CSE 480: Database Systems Lecture 9: SQL-DDL Reference: Read Chapter of the textbook.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
INTERNET APPLICATION DEVELOPMENT For More visit:
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Lecture 9 – MYSQL and PHP (Part1) SFDV3011 – Advanced Web Development 1.
Information Systems Today (©2006 Prentice Hall) MySQL 1CS3754 Class Note #8, Is an open-source relational database management system 2.Is fast and.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Constraints, Triggers and Index James Wang.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Advanced Database Management System
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.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
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.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
Introduction to Database Programming with Python Gary Stewart
Fundamental of Database Systems
3 A Guide to MySQL.
Web Systems & Technologies
CS320 Web and Internet Programming SQL and MySQL
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Introduction To Structured Query Language (SQL)
Database systems Lecture 3 – SQL + CRUD
Contents Preface I Introduction Lesson Objectives I-2
CS3220 Web and Internet Programming SQL and MySQL
Data Definition Language
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

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

Chapter Eight MySQL Fundamentals slides/chapter08a.fundamentals.ppt 2

 Released internally May 23, 1995  Version 3.23 (January 2001) supported multiple DB engines:  MyISAM: For large amounts of data  InnoDB: For transaction safe processing  InnoDB: For foreign key support  Version 4.0 (March 2003):  Unions: Merging results of two queries into one result  Version 4.1 (October 2004):  Subqueries: Query within a query  Prepared Statements: Precompiled statement MySQL History 3

 Version 5.0 (October 2005):  Cursors: Retrieving multi-row data  Stored Procedures: SQL functions stored in the database  Triggers: Events executed upon tables and columns and defined in the database  Views: Predefined select statement  Transactions: Guarantee the order and success of operations MySQL History (continued) 4

 Sun Microsystems acquires MySQL February 26, 2008  Current Generally Available Release:  Event scheduler: Execute event at a specified time  Row-base replication: Copy data from one table to another at the row level  Partitioning: Divide the data into independent parts MySQL History (continued) 5

 Sun Microsystems acquires MySQL on February 26, 2008  Oracle buys Sun on April 20, 2009  Generally Available Release:  MySQL Editions:  Community Server (free)  Enterprise Edition (commercial)  Cluster Carrier Grade Edition (commercial) MySQL History Summary 6

MySQL Home Page: MySQL MySQL Reference Manual: SQL Tutorial: MySQL References 7

Web Database Applications with PHP & MySQL: Managing and Using MySQL: MySQL Books 8

MySQL Documentation Search (plugin for firefox): US/firefox/addon/mysql-documentation- search/?src=search US/firefox/addon/mysql-documentation- search/?src=search MySQL Workbench: MySQL Applications 9

MySQL uses Structured Query Language (SQL) MySQL uses Structured Query Language (SQL) SQL is language for retrieving, updating, deleting, information from a database SQL is language for retrieving, updating, deleting, information from a database Relational databases use a model that define data according to relationships Relational databases use a model that define data according to relationships Other databases: Oracle, Informix, DB2 (IBM) Access (Microsoft), SQL Server, PostgreSQL Other databases: Oracle, Informix, DB2 (IBM) Access (Microsoft), SQL Server, PostgreSQL What is MySQL? 10

Table: A named set of data that is organized into data types (or columns) and data values (or rows). A table has a specific number of columns, but can have any number of rows. Column: A named collection of data elements of the same data type. A database column is analogous to an array variable in a programming language. Row: A row consists of a field that corresponds to each column in a table. A row is also known as a database record. Database Definition of Terms 11

Database: A database is a named collection of tables that have a similar purpose. Field: A single database element that contains a data value. It is the intersection of a column and a row. Schema: Refers to the database structure of how data is organized. Database Definition of Terms (cont.) 12

Chapter Eight MySQL Commands 13

MySQL can be a accessed via command line (and the API from within PHP). To login to MySQL: mysql -h hostname -u user -p Note: On new MySQL installations the user is “root” and the password is blank (e.g. ""). Exit the command line shell: quit | exit Login/Logout Syntax 14

Example command line login: Login/Logout Example 15

Display the database version and misc information. Example: status; MySQL Status 16

Note: The databases “information_schema”, “mysql”, “phpmyadmin”, contain meta data (e.g. data about data) concerning tables. They are used for administrative purposes. DO NOT DELETE THEM! The databases “test” and “cdcol” are for user testing. Display all databases available. Example: show databases; Show Databases 17

show tables; Display all the tables in a database. Show Tables 18

Sets a connection to a specific database. Syntax: use dbName; Database Connection 19

Display the column names and types in a table. Syntax: describe tableName; Describe Table 20

source fileName; Execute SQL commands contained in a file as a script: MySQL Source File 21

MySQL permits syntax for three different comments. Example: /* * Multi-line comment * and /* nested comments * are legal */ */ # Shell-like comment -- Standard SQL comment MySQL Comments 22

Chapter Eight Schema Design Commands 23

Syntax: CREATE DATABASE dbName; Example: CREATE DATABASE carddb; USE carddb; Creating a Database 24

Syntax: CREATE TABLE tblName ( colName1 dataType1 colName1 dataType1 [colAttr1...] [colAttr1...] [, colName2 dataType2] [, colName2 dataType2] [, colAttr2...] [, colAttr2...] [, tblAttr1,...] ); [, tblAttr1,...] ); Table Creation Syntax 25

CREATE TABLE notecard ( # id INT NOT NULL AUTO_INCREMENT, # id INT NOT NULL AUTO_INCREMENT, id /* column name */ id /* column name */ INT /* column data type */ INT /* column data type */ NOT NULL /* data can’t be null */ NOT NULL /* data can’t be null */ AUTO_INCREMENT, /* next integer */ AUTO_INCREMENT, /* next integer */ name VARCHAR(50), /* 50 chr max */ name VARCHAR(50), /* 50 chr max */ content TEXT, /* unlimited char */ content TEXT, /* unlimited char */ creation TIMESTAMP DEFAULT NOW(), creation TIMESTAMP DEFAULT NOW(), category_id INT, /* foreign key */ category_id INT, /* foreign key */ PRIMARY KEY(id) ); /* index */ PRIMARY KEY(id) ); /* index */ Table Creation Anatomy 26

Description: The describe command displays the column name, column type, and other attributes regarding a table. Syntax: DESCRIBE tableName; Tables Described 27

Syntax: ALTER TABLE oldTable RENAME newTable; RENAME newTable;Example: ALTER TABLE notecard RENAME recipe; Renaming a Table 28

Syntax: ALTER TABLE tableName CHANGE oldColNam CHANGE oldColNam newColNam newColType; newColNam newColType;Example: ALTER TABLE author CHANGE penname CHANGE penname pseudonym varchar(25); pseudonym varchar(25); Renaming a Column 29

Syntax: ALTER TABLE tableName MODIFY colName colType; MODIFY colName colType;Example: ALTER TABLE book MODIFY author MODIFY author varchar(25); varchar(25); Warning: Changing the data type of a column in a table that contains values could cause a loss of data! Modifying a Column Data Type 30

Modifying a Column Data Type (cont.) 31

Syntax: ALTER TABLE tblName ADD colName1 colType1 ADD colName1 colType1 FIRST|AFTER colName2; FIRST|AFTER colName2;Example: ALTER TABLE book ADD pseudonym ADD pseudonym varchar(25) varchar(25) AFTER id; AFTER id; Adding a Column 32

Syntax: ALTER TABLE tblName MODIFY colNam1 colType MODIFY colNam1 colType FIRST|AFTER colNam2; FIRST|AFTER colNam2;Example: ALTER TABLE book MODIFY pseudonym MODIFY pseudonym varchar(25) varchar(25) AFTER author; AFTER author; Changing the Column Order 33

Syntax: ALTER TABLE tableName DROP columnName; DROP columnName;Example: ALTER TABLE book DROP pseudonym; DROP pseudonym; Pitfall: Dropping a column also removes the data stored in the column! Note: There is no “undo” on dropped columns. Removing a Column 34

Syntax: DROP TABLE tableName; Example: DROP TABLE book; Pitfall: Dropping a table also removes the data stored in the table! Note: There is no “undo” on dropped tables. Removing a Table 35

to be continued... es/php/slides/chapter08b.crud.ppt es/php/slides/chapter08b.crud.ppt36