Introduction to Internet Databases MySQL Database System Database Systems.

Slides:



Advertisements
Similar presentations
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
Advertisements

MySQL 5.6 Database System Presented by: Abhishek Kothari Computer Science, UGA 02/19/2013.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Multiple Tiers in Action
Lecture 4: Introduction to PHP 3 PHP & MySQL
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Intermediate PHP & MySQL
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.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
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:
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.
Web Application Development. Tools to create a simple web- editable database QSEE MySQL (or PHPMyAdmin) PHP TableEditor.
In the next lectures you will learn  What is SQL  How to access mySQL database  How to create a basic mySQL database  How to use some basic queries.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Simple Database.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
CS 174: Web Programming September 23 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
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.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
LIS651 lecture 6 mySQL Thomas Krichel
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
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.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
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.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
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.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
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.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
CCT395, Week 6 Implementing a Database with SQL and a Case Study Exercise This presentation is licensed under Creative Commons Attribution License, v.
3 A Guide to MySQL.
CS320 Web and Internet Programming SQL and MySQL
Introduction to MySQL.
CS311 Database Management system
Database application MySQL Database and PhpMyAdmin
Chapter 8 Working with Databases and MySQL
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
Database Connections.
MySQL Database System Installation Overview SQL summary
Presentation transcript:

Introduction to Internet Databases MySQL Database System Database Systems

2 2-Tier Architecture Web Browser (Client) Web Server PHP

3 3-Tier Architecture Web Browser (Client) Database Server Web Server PHP

4 MySQL installation MySQL can be installed as a service (Win 2000/XP) Can make icons on the desktop for starting and stopping the server. It is most commonly installed on a UNIX web server and accessed via the internet

5 Command Line Client The standard command line client is: c:\mysql\bin\mysql.exe The command line client can be used to send commands and SQL queries to the MySQL server There are also GUI clients such as MyCC

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 Entering commands Show all the databases SHOW DATABASES; mysql> SHOW DATABASES; | Database | | bookstore | | employee_db | | mysql | | student_db | | test | | web_db |

8 Entering commands Choosing a database and showing its tables USE test; SHOW tables; mysql> USE test; Database changed mysql> SHOW tables; | Tables_in_test | | books | | name2 | | names | | test | rows in set (0.00 sec) mysql>

9 Entering commands Show the structure of a table DESCRIBE names; mysql> DESCRIBE names; | Field | Type | Null | Key | Default | Extra | | id | int(11) | | PRI | NULL | auto_increment | | firstName | varchar(20) | | | | | | lastName | varchar(20) | | | | | rows in set (0.00 sec) mysql>

10 Entering commands Show the rows of a table (all columns) SELECT * FROM names; mysql> SELECT * FROM names; | id | firstName | lastName | | 1 | Fred | Flintstone | | 2 | Barney | Rubble | rows in set (0.00 sec) mysql>

11 Entering commands Inserting a new record INSERT INTO names (firstName, lastName) VALUES ('Rock','Quarry'); SELECT * FROM names; 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 | rows in set (0.00 sec) mysql>

12 Entering commands Updating a record UPDATE names SET lastName = 'Stone' WHERE id=3; SELECT * FROM names; 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 | rows in set (0.00 sec) mysql>

13 Logging output The commands you type and their ouput can be logged to a file by using the following command inside the MySQL command line client tee log.txt Here log.txt is the name of the file

14 Executing SQL files It is usually better to use an editor to write an SQL script and send it to the server. A file of SQL commands such as books.sql can be executed by the server by using a command such as C:\mysql\bin\mysql < books.sql This assumes that books.sql is in your current directory. Otherwise the complete path to books.sql must be supplied

15 SQL commands SHOW, USE SHOW Display databases or tables in current database; Example (command line client): show databases; show tables; USE Specify which database to use Example use bookstore;

16 marks.sql studentIDfirst_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

17 marks.sql -- 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);

18 Executing The Script within MySQL use a command such as source c:/ /marks.sql This adds the marks table to the database

19 The Marks Table Selecting the complete table 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 | rows in set (0.00 sec)

20 Limiting number of rows LIMIT can be used to specify the maximum number of rows that are to be returned by a select query. Example SELECT * FROM marks LIMIT 3; This query will return only the first 3 rows from the marks table To return 15 rows beginning at row 5 use SELECT * FROM marks LIMIT 4, 15;

21 books.sql isbntitleauthorpubyearprice 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

22 books.sql -- Insert some books into books table INSERT INTO books VALUES (' ', 'PHP and MySQL Web Development', 'Luke Welling, Laura Thomson', 'Sams', 2001, ); INSERT INTO books VALUES (' ', 'Professional Apache', 'Peter Wainwright', 'Wrox Press Ltd', 1999, );

23 Executing The Script within MySQL use a command such as source c:/ /books.sql This adds the books table to the database

24 employee_db.sql employeeIDnamepositionaddress CREATE DATABASE IF NOT EXISTS employee_db; USE employee_db; DROP TABLE IF EXISTS employees; DROP TABLE IF EXISTS jobs; employeeIDhours employees table jobs table

25 employee_db.sql 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');

26 employee_db.sql 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);

27 Executing The Script within MySQL use a command such as source c:/ /employee_db.sql This creates the employee_db database and adds the employees and jobs tables to it

28 Select Queries With Joins SELECT * FROM employees, jobs; | employeeID | name | position | address | employeeID | hours | | 1001 | Fred | programmer | 13 Windle St | 1001 | | | 1002 | Joan | programmer | 23 Rock St | 1001 | | | 1003 | Bill | manager | 37 Front St | 1001 | | | 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 |

29 See mySQL in action! Lets just take a look at mySQL working via a web page using PHP as the scripting language. End of this part of the lecture.