Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Similar documents
Introduction to relational databases and MySQL

Chapter 3 Introduction to relational databases and MySQL

How to use SQL to create a database

How to use SQL to work with a MySQL database

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Mastering phpmyadmiri 3.4 for

Queries with Multiple Criteria (OR)

Creating databases using SQL Server Management Studio Express

What is SQL? Toolkit for this guide. Learning SQL Using phpmyadmin

Accessing databases in Java using JDBC

Relational databases and SQL

T-SQL Training: T-SQL for SQL Server for Developers

Module 3 MySQL Database. Database Management System

DATABASES SQL INFOTEK SOLUTIONS TEAM

Database Setup - Local

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

Chapter 1 An introduction to relational databases and SQL

How to use PHP with a MySQL database

Unit 27 Web Server Scripting Extended Diploma in ICT

Database Systems. phpmyadmin Tutorial

Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types

How to design a database

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

CRAF RFI Database: a MySQL implementation

Activant Solutions Inc. SQL 2005: Basic Data Manipulation

! An organized collection of data. ! Can easily be accessed, managed, and updated. ! Data are organized as a set of tables.

Seminar 3. Stored procedures. Global variables. Dynamic Execution. The OUTPUT clause. Cursors

Automated SQL Ownage Techniques. OWASP October 30 th, The OWASP Foundation

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

SQL Server 2008 Tutorial 3: Database Creation

DATABASE MANAGEMENT SYSTEMS

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Mysql Create Table Example Primary Key Foreign

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Structured Query Language (SQL)

Module - P7 Lecture - 15 Practical: Interacting with a DBMS

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

Downloaded from

Exam code: Exam name: Database Fundamentals. Version 16.0

More on MS Access queries

SQL Data Definition and Data Manipulation Languages (DDL and DML)

Table Joins and Indexes in SQL

ISM 4212/4480 Milestone V Submission Sample

Access Objects. Tables Queries Forms Reports Relationships

Oracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)

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

Introduction to Data Management CSE 344

Oracle Academy Amazing Books Part 1: Building Tables and Adding Constraints

MySQL 5.0 Certification Study Guide

Test Bank Database Processing Fundamentals Designand Implementation 14th Edition Kroenke

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Keys are fields in a table which participate in below activities in RDBMS systems:

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4

MySQL. A practical introduction to database design

COMS 469: Interactive Media II

CSCU9Q5 Introduction to MySQL. Data Definition & Manipulation (Over ~two Lectures)

CSC 3300 Homework 3 Security & Languages

PureSight Log Server Installation Manual

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

Solutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik. John Weatherwax

MySQL and MariaDB. March, Introduction 3

Professional PHP for working with MySQL

Chapter 9: MySQL for Server-Side Data Storage

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA

A Project Report On E-Watch Shopping System

ColumnStore Indexes UNIQUE and NOT DULL

User's Guide c-treeace SQL Explorer

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

Lecture 07. Spring 2018 Borough of Manhattan Community College

Course Outline and Objectives: Database Programming with SQL

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

Data Privilege Adding or Removing Members

Database connection 1

Real Application Security Administration

Announcements. Multi-column Keys. Multi-column Keys (3) Multi-column Keys. Multi-column Keys (2) Introduction to Data Management CSE 414

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

MySQL by Examples for Beginners

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Chapter 1 SQL and Data

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

4) PHP and MySQL. Emmanuel Benoist. Spring Term Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1

Index. B backing up 76 7

COOKBOOK Row-Level Security

SQL Server Administration Class 4 of 4. Activant Prophet 21. Basic Data Manipulation

SQL Commands & Mongo DB New Syllabus

Announcements. Multi-column Keys. Multi-column Keys. Multi-column Keys (3) Multi-column Keys (2) Introduction to Data Management CSE 414

Introduction to Databases. MySQL Syntax Guide: Day 1

Lecture 04: SQL. Wednesday, October 4, 2006

Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics

Instructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables

Mysql Information Schema Update Time Null >>>CLICK HERE<<< doctrine:schema:update --dump-sql ALTER TABLE categorie

Lecture 04: SQL. Monday, April 2, 2007

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Creating the Data Layer

Databases. Web applications in PHP to query a database. Practice n. 4

Assignment Grading Rubric

Database Systems Fundamentals

origin destination duration New York London 415 Shanghai Paris 760 Istanbul Tokyo 700 New York Paris 435 Moscow Paris 245 Lima New York 455

Transcription:

1 Chapter 3 Introduction to relational databases and MySQL

Slide 2 Objectives Applied 1. Use phpmyadmin to review the data and structure of the tables in a database, to import and run SQL scripts that create databases, and to create users with limited privileges. 2. Code simple SELECT, INSERT, UPDATE, and DELETE statements, and use phpmyadmin to run them.

Slide 3 Objectives (continued) Knowledge 1. Describe the structure of a database table. 2. Describe how the tables in a relational database are related using these terms: primary key and foreign key. 3. Identify the three types of relationships that can exist between two tables. 4. Describe the way the columns in a table are defined using these terms: data type, null value, default value, and auto-increment column. 5. Describe the use of SELECT statements, including the use of inner joins. 6. Describe the use of INSERT, UPDATE, and DELETE statements. 7. Describe the way the creation of users and the assignment of privileges affect how a MySQL database can be used.

Slide 4 A products table with 5 columns and 10 rows (primary key= productid)

Slide 5 Terms relational database table row column record field cell primary key non-primary key unique key

Slide 6 The categories table (primary key = categoryid)

Slide 7 The products table (foreign key = categoryid)

Slide 8 Terms foreign key one-to-many relationship one-to-one relationship many-to-many relationship

Slide 9 Column definitions for the products table

Slide 10 Common MySQL data types CHAR VARCHAR INT DECIMAL DATE, TIME, DATETIME

11 The SELECT statement syntax for all columns SELECT * FROM table-1 [WHERE selection-criteria] [ORDER BY column-1 [ASC DESC] [, column-2 [ASC DESC]...] ]

12 Example SELECT statement SELECT * FROM products WHERE categoryid = 2

Slide 13 The syntax for selected columns SELECT column-1 [, column-2]... FROM table-1 [WHERE selection-criteria] [ORDER BY column-1 [ASC DESC] [, column-2 [ASC DESC]...] ] A statement that gets selected columns and rows SELECT productname, listprice FROM products WHERE listprice < 500 ORDER BY listprice ASC The result table

Slide 14 The syntax that joins two tables SELECT column-1 [, column-2]... FROM table-1 {INNER LEFT OUTER RIGHT OUTER} JOIN table-2 ON table-1.column-1 {= < > <= >= <>} table-2.column-2 [WHERE selection-criteria] [ORDER BY column-1 [ASC DESC] [, column-2 [ASC DESC]...] ]

Slide 15 A statement that gets data from two related tables SELECT categoryname, productname, listprice FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE listprice > 800 ORDER BY listprice ASC The result table

16 Terms Join result contains data from 2 tables inner join rows are only included when the keys in both tables match outer join rows from one table are included even if the keys don t match left outer join includes all rows in first table and only matching rows in second table

Slide 17 The syntax for the INSERT statement INSERT INTO table-name [(column-list)] VALUES (value-list) A statement that adds one row to a table INSERT INTO products (categoryid, productcode, productname, listprice) VALUES (1, 'tele', 'Fender Telecaster', 599.00) A statement that uses the MySQL NOW function to get the current date INSERT INTO orders (customerid, orderdate) VALUES (1, NOW())

Slide 18 The syntax for the UPDATE statement UPDATE table-name SET expression-1 [, expression-2]... WHERE selection-criteria A statement that updates a column in one row UPDATE products SET productname = 'Ludwig 5-Piece Kit with Zildjian Cymbals' WHERE productcode = 'ludwig' A statement that updates multiple rows UPDATE products SET listprice = 299 WHERE categoryid = 1

Slide 19 The syntax for the DELETE statement DELETE FROM table-name WHERE selection-criteria A statement that deletes one row from a table DELETE FROM products WHERE productid = 1 A statement that deletes multiple rows DELETE FROM products WHERE listprice > 200

Slide 20 MySQL is Inexpensive Fast Easy to use Portable

Slide 21 MySQL provides Support for SQL Support for multiple clients Connectivity Security Referential integrity Transaction processing

Slide 22 A command-line client

Slide 23 A web-based client

Slide 24 The Welcome page

Slide 25 How to start phpmyadmin on a local computer 1. From the XAMPP Control Panel, start the Apache and MySQL servers if they aren t already running. 2. Click the Admin button for the MySQL module to start the phpmyadmin tool in your default web browser. How to log in Enter your username and password. How to log out and return to the Welcome page Click the Log out toolbar button (the Exit sign) that s in the sidebar of most pages. Or, go the Home page by clicking on the Home button, and then click the Log out link.

Slide 26 How to change your password Go to the Home page by clicking on the Home button. Then, click the Change Password link. On the Change Password page, enter and re-enter your new password, and click the Go button.

Slide 27 Running a SQL script that creates a database

Slide 28 How to import and run a SQL script 1. Click the Import tab, go to the File to Import section, click the Browse button, and select the file that contains the script. 2. Click the Go button. This runs the script that s in the file. The script for creating the databases for this book \xampp\htdocs\book_apps\_create_db\create_db.sql

Slide 29 The Databases tab

Slide 30 The Structure tab for a database

Slide 31 The Browse tab for the categories table

Slide 32 The SQL tab with a statement ready to run

Slide 33 The SQL tab after a SQL statement has been run

Slide 34 Creating a user with limited privileges on one table GRANT SELECT ON my_guitar_shop1.products TO mgs_tester@localhost IDENTIFIED BY 'pa55word' Creating a user with limited privileges on all tables GRANT SELECT, INSERT, DELETE, UPDATE ON my_guitar_shop1.* TO mgs_user@localhost IDENTIFIED BY 'pa55word'

Slide 35 Common privileges Privilege SELECT UPDATE INSERT DELETE CREATE TABLE DROP TABLE Description Lets the user select data. Lets the user update data. Lets the user insert data. Lets the user delete data. Lets the user create a table. Lets the user drop a table.

Slide 36 The SQL tab for mgs_tester after an UPDATE statement failed