CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.

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

 Pearson Education, Inc. All rights reserved Accessing Databases with JDBC.
1 Introduction to Web Application Introduction to Data Base.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
Exercise SELECT authorID, lastName FROM authors AuthorID FirstName
Java Database Connectivity (JDBC). Introduction Database –Collection of data DBMS –Database management system –Storing and organizing data SQL –Relational.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 25 – Database: SQL, ADO and RDS Outline 25.1Introduction 25.2Relational Database Model 25.3Relational.
ASP.NET Programming with C# and SQL Server First Edition
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
 2008 Pearson Education, Inc. All rights reserved Database: SQL, MySQL, ADO.NET 2.0 and Java DB.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
 2003 Prentice Hall, Inc. All rights reserved. 1 Java Database Connectivity with JDBC TM.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Introduction to SQL Steve Perry
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CHAPTER 8 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
Database: SQL and MySQL
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.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Relational Database. Database Management System (DBMS)
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved. 2 Revised by Dr. T. Tran for CSI3140.
 2005 Pearson Education, Inc. All rights reserved Accessing Databases with JDBC.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
 2008 Pearson Education, Inc. All rights reserved Database: SQL, MySQL, ADO.NET 2.0 and Java DB.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 22 - SQL, MySQL, DBI and ADO Outline 22.1 Introduction 22.2 Relational Database Model 22.3 Relational.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
 2009 Pearson Education, Inc. All rights reserved Databases and LINQ to SQL.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
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.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
 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.
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.
Database, SQL and ADO.NET
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Database Programming in Java
 2012 Pearson Education, Inc. All rights reserved.
Accessing Databases with JDBC
LINQ to DATABASE-2.
JDBC.
Databases Intro (from Deitel)
Chapter 8 Working with Databases and MySQL
Databases - בסיסי נתונים
Chapter 22 - SQL, MySQL, DBI and ADO
Introduction To Structured Query Language (SQL)
MySQL Database System Installation Overview SQL summary
MySQL Database System Installation Overview SQL summary
Manipulating Data Lesson 3.
Java Chapter 6 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

CHAPTER 7 Database: SQL, MySQL

Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured Query Language)Basic SELECT Query  WHERE Clause  ORDER BY Clause  Merging Data from Multiple Tables: INNER JOIN  Joining Data from Tables Authors, AuthorISBN, Titles and Publishers  INSERT Statement  UPDATE Statement  DELETE Statement

Introduction Database –Integrated collection of data –Database management system (DBMS) Store and organize data consistent with database’s format Relational database –SQL (Structured Query Language) »Queries »Manipulate data

Relational Database Model Composed of tables Row –Number column –Primary key Reference data in the table A column or set of columns in table contains unique data

Relational Database Model 5 Fig. 22.1Relational database structure of an Employee table.

6 Relational Database Model departmentlocation 413New Jersey 642Los Angeles 611Orlando Fig. 22.2Table formed by selecting department and location data from the Employee table.

Relational Database Model Primary key uniquely identifies each row –Rule of Entity Integrity Composite primary key Lines connecting tables –Relationships One-to-many relationship Foreign key –Join multiple tables –Rule of Referential Integrity

8 Employee Staff_IDNameDepartment 123AhmadGraphic 456ArdenHR 789ZikryEngineering 222SafiaEngineering 111HendraFinance Department Graphic HR Engineering Finance Primary Key Foreign Key When these two tables are linked, Department is a foreign key in table Employee. Data in Department column may be repeatable. Department is a primary key in table Department. Data in Department column must be unique.

9 Relational Database Overview: Books.mdb Database

10 Relational Database Overview: Books.mdb Database

11 Relational Database Overview: Books.mdb Database

12 Relational Database Overview: Books.mdb Database

13 Relational Database Overview: Books.mdb Database

14 Relational Database Overview: Books.mdb Database

15 Relational Database Overview: Books.mdb Database Fig Table relationships in Books.mdb Foreign key- can appears many times in its own table Appears exactly once as primary key of other table

16 SQL (Structured Query Language)

17 Basic SELECT Query SELECT * FROM tableName –SELECT * FROM Authors –SELECT authorID, lastName FROM Authors

18 Basic SELECT Query

19 WHERE Clause Specify selection criteria for query –SELECT columnName1, columnName2, … FROM tableName WHERE criteria SELECT title, editionNumber, copyright FROM Titles WHERE copyright > 1999 –LIKE Pattern matching –Asterisk ( * ) »SELECT authorID, firstName, lastName FROM Authors WHERE lastName LIKE ‘D*’ –Question mark ( ? ) »SELECT authorID, firstName, lastName FROM Authors WHERE lastName LIKE ‘?I*’

20 WHERE Clause

21 WHERE Clause

22 WHERE Clause

23 ORDER BY Clause Arranged in ascending or descending order –SELECT columnName1, columnName2, … FROM tableName ORDER BY column ASC SELECT authorID, firstName, lastName FROM Authors ORDER BY lastName ASC –SELECT columnName1, columnName2, … FROM tableName ORDER BY column DESC SELECT authorID, firstName, lastName FROM Authors ORDER BY lastName DESC

24 ORDER BY Clause

25 ORDER BY Clause

26 ORDER BY Clause SELECT authorID, firstName, lastName FROM Authors ORDER BY lastName, firstName

27 ORDER BY Clause

28 ORDER BY Clause SELECT isbn, title, editionNumber, copyright, price FROM Titles WHERE title LIKE ‘*How to Program’ ORDER BY title ASC

29 Merging Data from Multiple Tables: INNER JOIN Normalize databases –Ensure database does not store data redundantly –SELECT columnName1, columnName2, … FROM table1 INNER JOIN table2 ON table1, columnName = table2.columnName –SELECT firstName, lastName, isbn FROM Authors INNER JOIN AuthorISBN ON Authors.authorID = AuthorISBN.authorID ORDER BY lastName, firstName

30 Merging Data from Multiple Tables: INNER JOIN

31 Fig (1 of 1)

32 Joining Data from Tables Authors, AuthorISBN, Titles and Publishers

33 Joining Data from Tables Authors, AuthorISBN, Titles and Publishers

34 INSERT Statement Inserts new row in table –INSERT INTO tableName ( columnName1, columnName2, …, columnNameN ) VALUES ( value1, value2, …, valueN ) –INSERT INTO Authors ( firstName, lastName ) VALUES ( ‘Sue’, ‘Smith’ )

35 INSERT Statement

36 UPDATE Statement Modifies data in a table –UPDATE tableName SET columnName1 = value1, columnName2 = value2, …, columnNameN = valueN WHERE criteria –UPDATE Authors SET lastName = ‘Jones’ WHERE lastName= ‘Smith’ AND lastName=‘Sue’

37 UPDATE Statement

38 DELETE Statement Removes data from a table –DELETE FROM tableName WHERE criteria –DELETE FROM Authors WHERE lastName=‘Jones’ AND firstName=‘Sue’

39 DELETE Statement

40 MySQL Multi-user and multi-threaded RDBMS server Uses SQL to interact with and manipulate data Supports various programming languages Access tables from different databases Handle large databases The next chapter explains the usage of MySQL with PHP.