MySQL Database System Installation Overview SQL summary

Slides:



Advertisements
Similar presentations
 2003 Prentice Hall, Inc. All rights reserved. Chapter 22 – Database: SQL, MySQL, DBI and ADO.NET Outline 22.1 Introduction 22.2 Relational Database Model.
Advertisements

MySQL 5.6 Database System Presented by: Abhishek Kothari Computer Science, UGA 02/19/2013.
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 © 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.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
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.
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.
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.
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.
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.
Introduction to Internet Databases MySQL Database System Database Systems.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Database: SQL and MySQL
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
1 Databases November 15, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg. Published.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
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.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CHAPTER 10 PHP MySQL Database
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
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
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
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.
3 A Guide to MySQL.
ORDER BY Clause The result of a query can be sorted in ascending or descending order using the optional ORDER BY clause. The simplest form of.
Web Systems & Technologies
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
Insert, Update and the rest…
Introduction to MySQL.
JDBC.
ISC440: Web Programming 2 Server-side Scripting PHP 3
SQL Tutorial.
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Chapter 22 - SQL, MySQL, DBI and ADO
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Introduction To Structured Query Language (SQL)
SQL, Data Storage Technologies, and Web-Data Integration
SQL pepper.
Introduction To Structured Query Language (SQL)
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
Introduction to Web programming
Presentation transcript:

MySQL Database System Installation Overview SQL summary

2-Tier Architecture Web Server Web Browser (Client) PHP 5/24/2019 BGA

3-Tier Architecture Web Browser (Client) Web Server Database Server PHP 5/24/2019 BGA

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 Windows GUI client: HeidiSQL WEB GUI client: phpmyadmin 5/24/2019 BGA

Client-Server Interaction Make a request (SQL query) MySQL Server Client Program 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. 5/24/2019 BGA

Connecting to the Server Use a command prompt that sets the path to c:\mysql\bin The following command connects to the server: mysql -u root -p you are prompted for the root password. you can now send comands and SQL statements to the server 5/24/2019 BGA

Entering commands (1) Show all the databases SHOW DATABASES; mysql> SHOW DATABASES; +-------------+ | Database | +-------------+ | bookstore | | employee_db | | mysql | | student_db | | test | | web_db | +-------------+ 5/24/2019 BGA

Entering commands (2) 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 | +----------------+ 4 rows in set (0.00 sec) mysql> 5/24/2019 BGA

Entering commands (3) 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) | | | | | +-----------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) mysql> 5/24/2019 BGA

Entering commands (4) Show the rows of a table (all columns) SELECT * FROM names; mysql> SELECT * FROM names; +----+-----------+------------+ | id | firstName | lastName | +----+-----------+------------+ | 1 | Fred | Flintstone | | 2 | Barney | Rubble | +----+-----------+------------+ 2 rows in set (0.00 sec) mysql> 5/24/2019 BGA

Entering commands (5) 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 | +----+-----------+------------+ 3 rows in set (0.00 sec) mysql> 5/24/2019 BGA

Entering commands (6) 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 | +----+-----------+------------+ 3 rows in set (0.00 sec) mysql> 5/24/2019 BGA

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

The CREATE Command Specifying primary keys CREATE TABLE table_name ( column_name1 column_type1 NOT NULL DEFAULT '0', column_name2 column_type2, ... column_nameN column_typeN, PRIMARY KEY (column_name1) ); 5/24/2019 BGA

The CREATE Command (3) autoincrement primary integer keys CREATE TABLE table_name ( column_name1 column_type1 PRIMARY KEY NOT NULL DEFAULT '0' AUTO_INCREMENT, column_name2 column_type2, ... column_nameN column_typeN, ); 5/24/2019 BGA

The DROP Command To delete databases and tables use the DROP command Examples DROP DATABASE db_name; DROP DATABASE IF EXISTS db_name; DROP TABLE table_name; DROP TABLE IF EXISTS table_name; Note: Don't confuse DROP with DELETE which deletes rows of a table. 5/24/2019 BGA

The INSERT Command Inserting rows into a table 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 \' and \" 5/24/2019 BGA

The SELECT Command (1) Selecting rows from a table Simplest form: select all columns Select specified columns Conditional selection of rows SELECT * FROM table_name; SELECT column_list FROM table_name; SELECT column_list FROM table_name WHERE condition; 5/24/2019 BGA

The SELECT Command (2) Specifying ascending row ordering Specifying descending row ordering SELECT column_list FROM table_name WHERE condition ORDER by ASC; SELECT column_list FROM table_name WHERE condition ORDER by DESC; 5/24/2019 BGA

The SELECT Command (3) There are many other variations of the select command. Example: finding the number of records in a table assuming a primary key called id: Can also perform searching using the WHERE option SELECT COUNT(id) FROM table_name 5/24/2019 BGA

The UPDATE Command Used to modify an existing record Conditional update version 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; 5/24/2019 BGA

marks.sql (1) studentID first_name last_name mark marks table 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) ); 5/24/2019 BGA

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); 5/24/2019 BGA

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 | +-----------+------------+-----------+------+ 5 rows in set (0.00 sec) 5/24/2019 BGA