AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

Similar documents
Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly

APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL

A340 Laboratory Session #17

Multimedia im Netz Online Multimedia Winter semester 2015/16

php Mr. Amit Patel Hypertext Preprocessor Dept. of I.T.

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]

A201 Object Oriented Programming with Visual Basic.Net

Web Systems Nov. 2, 2017

PHP Development - Introduction

Oracle Database 10g Express

Locate your Advanced Tools and Applications

Using PHP with MYSQL

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ]

SQL Commands & Mongo DB New Syllabus

Database Connectivity using PHP Some Points to Remember:

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

Introduction to Databases and SQL

Working with Databases and Java

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

Announcements. PS 3 is out (see the usual place on the course web) Be sure to read my notes carefully Also read. Take a break around 10:15am

Chapter 1 An introduction to relational databases and SQL

Database Management Systems

SQL Data Definition Language: Create and Change the Database Ray Lockwood

2017 Politecnico di Torino 1

The URL of the whole system is:

Chapter 7 PHP Files & MySQL Databases

2017 Politecnico di Torino 1

Almost all new data created today is digital Problem: How to organize the data and store it? Capacity Speed Life of the data Number of users

Relational databases and SQL

Overview of MySQL Structure and Syntax [2]

ITP 140 Mobile Technologies. Databases Client/Server

Relational Database Systems Part 01. Karine Reis Ferreira

CPSC 421 Database Management Systems. Lecture 10: Embedded SQL

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

API Gateway Version September Key Property Store User Guide

COMP519: Web Programming Autumn 2015

Database Processing. Fundamentals, Design, and Implementation. Global Edition

MySQL Introduction. By Prof. B.A.Khivsara

MySQL: Access Via PHP

MySQL for Beginners Ed 3

LAB 11 WORKING WITH DATABASES

BSc (Hons) Web Technologies. Examinations for 2017 / Semester 1

Using Relational Databases for Digital Research

The connection has timed out

CGS 3066: Spring 2017 SQL Reference

DATABASES SQL INFOTEK SOLUTIONS TEAM

UNIVERSITY OF BOLTON CREATIVE TECHNOLOGIES HND/BSC (HONS) COMPUTING & WEBSITE DEVELOPMENT SEMESTER TWO EXAMINATION 2016/2017

The MANUAL. 1 P a g e

File Processing Approaches

CSC 337. Relational Databases and SQL. Rick Mercer

MySQL for Developers Ed 3

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Databases (MariaDB/MySQL) CS401, Fall 2015

Professional PHP for working with MySQL

Module 3 MySQL Database. Database Management System

PHP for PL/SQL Developers. Lewis Cunningham JP Morgan Chase

COSC 304 Introduction to Database Systems. Database Introduction. Dr. Ramon Lawrence University of British Columbia Okanagan

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

PHP and MySQL Programming

CS 377 Database Systems. Li Xiong Department of Mathematics and Computer Science Emory University

Tool Create Database Diagram Sql Server 2008 R2

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Linux Network Administration. MySQL COMP1071 Summer 2017

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

Oracle 1Z0-514 Exam Questions and Answers (PDF) Oracle 1Z0-514 Exam Questions 1Z0-514 BrainDumps

MySQL Installation Guide (Windows)

Lecture 1: Relational Databases

Introduction. Performance

The Blackhole and Federated Storage Engines: The Coolest Kids on the Block

Database Systems. phpmyadmin Tutorial

MTAT Introduction to Databases

Using MySQL on the Winthrop Linux Systems

MySQL for Developers Ed 3

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

Mysql Query Browser Export Table Structure

Submitted No Schema Type For Mysql Type Datetime

MySQL Installation Guide (Windows)

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Database-Aware Fault Localization for Dynamic Web Applications

Database Application Programs PL/SQL, Java and the Web

Course Outline. MySQL Database Administration & Design. Course Description: Pre-requisites: Course Content:

EE221 Databases Practicals Manual

Introduction to Databases

Introduction. Who wants to study databases?

A practical introduction to database design

DATABASE MANAGEMENT SYSTEMS

How To Create Complex Stored Procedures In Sql Server 2008 With Examples

CSC 3300 Homework 3 Security & Languages

Database Systems. Answers

CSC 453 Database Technologies. Tanu Malik DePaul University

Stored procedures - what is it?

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

Databases. Jörg Endrullis. VU University Amsterdam

MULTIMEDIA AND WEB TECHNOLOGY

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA

Transcription:

AN INTRODUCTION TO WEB PROGRAMMING Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

HISTORY Developed by Michael Widenius. Initially release in 1995. Latest release in 2013. One of the most popular open source relational database systems. According to http://en.wikipedia.org/wiki/mysql as of 2008 MySQL, is the most widely used open source relational database management system. It runs as a server, and provides multi-user access to many databases. For a while the MySQL was owned and sponsored by a Swedish company MySQL AB, but it is currently owned by Oracle corporation. Written in C and C++, cross platform, GNU General Public License. http://www.mysql.com/ http://dev.mysql.com/doc/index-about.html MySQL 2

MYSQL AT IU SOUTH BEND My team has been using MySQL since 2004. Our first project (IU-EVAL) used MySQL as its backend database. Since that time, several other projects (e.g., IU- ALUMNI, IU-RETAIN, IU-ADVISE, and IU-READY) have been using the same database system. The MySQL database has proven to be extremely fast, reliable, and feature rich. MySQL 3

SOME TERMS? DBMS Table/File/Entity Row/Record/Tuple Column/Field/Attribute Cell (an individual value) Storage engine SQL (Structured Query Language) Command line interface MySQL admin interface MySQL 4

WHAT IS A DATABASE? Logically coherent collection of data with inherent meaning. A database is an integrated, shared repository of operational data of interest to an enterprise. MySQL 5

WHY A DATABASE? Controlled redundancy Restricted and authorized access (User, databases, tables, etc.) Persistent storage Ability to represent complex relationship among data. Enforce integrity constraints Backup and recovery Standardized query language (SQL) Etc.. MySQL 6

WHAT IS A DATA BASE MANAGEMENT SYSTEM? (DBMS) A collection of programs that enable the user to create and maintain a database. A DBMS provide the following capability: Defining the database (schema, define the attributes, their types, size, constraints, range, etc.) Populate the database (Add data to the database) Manipulate the database (query, update, generate reports, create views, join information) MySQL 7

AN INTRODUCTION TO WEB PROGRAMMING Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

HOW DOES PHP TALK WITH MYSQL? When a client requests a file with a.php extension, the web server sends the request to the PHP interpreter for preprocessing. If the PHP code has any database interaction, PHP first connects to the database and performs the database operations, takes the result of those operations and composed the proper HTML to be sent back to the web server, which is then sent to the client. Image from: http://www.santarosa.edu/~jperetz/spring2012/dreamweaver/ MySQL 9

DATA MODELING MySQL 10

MYSQL Starting up XAMPP/Apache/MySQL. MySQL 11

CREATING THE CLUB DATABASE MySQL 12

SAMPLE SQL COMMANDS.. 1) CREATE DATABASE `club` ; 2) CREATE TABLE `club`.`member` ( `FirstName` VARCHAR( 32 ) NOT NULL, `LastName` VARCHAR( 32 ) NOT NULL, `Email` VARCHAR( 128 ) NOT NULL ) ENGINE = MYISAM ; 3) INSERT INTO `club`.`member` ( `FirstName`, `LastName`, `Email` ) VALUES ( 'Tom', 'Johnson', 'tjohnson@gmail.com' ), ( 'Mary', 'Adams', 'madams@yahoo.com' ); 4) ALTER TABLE `member` ADD PRIMARY KEY ( `Email` ) MySQL 13

AN INTRODUCTION TO WEB PROGRAMMING Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

PHP INTERFACE TO MYSQL PHP provides 3 different APIs to MySQL database: 1. MySQL Original and a little outdated, based on C language (http://www.php.net/manual/en/book.mysql.php) 2. MySQLi OOP version (http://www.php.net/manual/en/book.mysqli.php) 3. PDO OOP, Multi-platform (works with MySQL, but it also works with other databases) (http://us3.php.net/manual/en/book.pdo.php) MySQL 15

TYPICAL DB APPLICATION: Step 1: Make a connection to MySQL Server Step 2: Check for Connection Errors Step 3: Create a new Database Step 4: USE the newly created database (Make it the active DB) Step 5: CREATE one or more Tables Step 6: INSERT, DELETE, UPDATE records optional Step 7: SELECT (retrieve) records from the tables Step 8: Close the connection to the MySQL server MySQL 16

MYSQL-I API $con = mysqli_connect(dbhost, user, password, dbname ); Before we can access data in a database, we must open a connection to the MySQL server. mysqli_connect_errno($con) Check to see if the connection is established. mysqli_query($con, $sql) Submit the SQL query to be processed by the database. mysqli_close($con ) The connection will be closed automatically when the script ends. To close the connection before, use the mysqli_close() function. MySQL 17

A SIMPLE MYSQL APPLICAITON 1) Open Connection $con=mysqli_connect("localhost", User","Password","my_db ) 2) Insert Data $sql="insert INTO Persons (Firstname, Lastname, Age) VALUES ('Sam', 'Chellokabob',35)"; mysqli_query($con, $sql); 3) Retrieve Data $sql="select * FROM Persons"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo $row['firstname']. " ". $row['lastname']; echo "<br />"; } 4) Close Connection mysqli_close($con); MySQL 18

MYSQL-I API $result = mysqli_query($con,$sql); Perform a SQL query on the database and return true if successful. If the query produces a result-set, one can use the following functions: mysqli_num_rows($result) to get the number of rows. mysqli_field_count($con) to get the field count. $row = mysqli_fetch_row($result); to get the rows. mysqli_free_result($result); to free the result-set. MySQL 19

AN INTRODUCTION TO WEB PROGRAMMING Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

TYPICAL DB APPLICATION: Step 1: Make a connection to MySQL Server Step 2: Check for Connection Errors Step 3: Create a new Database Step 4: USE the newly created database (Make it the active DB) Step 5: CREATE one or more Tables Step 6: INSERT, DELETE, UPDATE records optional Step 7: SELECT (retrieve) records from the tables Step 8: Close the connection to the MySQL server MySQL 21

SAMPLE DATABASE (PHP API) Open a Connect: $con=mysqli_connect("localhost","a340user","pass123word"); Check for errors: mysqli_connect_errno($con) mysqli_connect_error() Create a Database: CREATE DATABASE IF NOT EXISTS my_db; mysqli_query($con,$sql) Make an Active Database: USE my_db; Create a Table: CREATE TABLE IF NOT EXISTS persons(firstname CHAR(30),Lastname CHAR(30),Age INT);"; mysqli_query($con,$sql) Insert Record(s): INSERT INTO Persons (Firstname, Lastname, Age) VALUES ('Sam', 'Chellokabob',35);"; mysqli_query($con, $sql); Retrieve / Display Record(s): SELECT * FROM Persons $row = mysqli_fetch_array($result) Close the Connection: mysqli_close($con); MySQL 22