Concepts of Database Management Seventh Edition

Slides:



Advertisements
Similar presentations
Concepts of Database Management Seventh Edition
Advertisements

Session 2Introduction to Database Technology Data Types and Table Creation.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Access Tutorial 1 Creating a Database
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Concepts of Database Management Sixth Edition
Concepts of Database Management, 4th Edition, Pratt & Adamski
Introduction to Structured Query Language (SQL)
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.
Concepts of Database Management Sixth Edition
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
Microsoft Access 2010 Chapter 7 Using SQL.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Access Tutorial 10 Automating Tasks with Macros
Tutorial 1 Creating a Database. Objectives Learn basic database concepts and terms Learn basic database concepts and terms Explore the Microsoft Access.
Chapter 2 Querying a Database
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Concepts of Database Management, Fifth Edition
1 An Introduction to SQL. 2 Objectives  Understand the concepts and terminology associated with relational databases  Create and run SQL commands 
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
BIS121 IT for Business Application Lecture 8 – Database (Part I)
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Chapter 3 Single-Table Queries
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Chapter 1 Databases and Database Objects: An Introduction
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
® Microsoft Access 2010 Tutorial 1 Creating a Database.
Analyzing Data For Effective Decision Making Chapter 3.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Seventh Edition
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
® Microsoft Office 2013 Access Creating a Database.
Tutorial 91 Databases A database is an organized collection of related information stored in a file on a disk A database allows companies to store information.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
1 2 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
1 SQL II CIS*2450 Advanced Programming Concepts. 2 Data Types INTEGER –numbers without a decimal point –range is to SMALLINT –like.
Microsoft Access Prepared by the Academic Faculty Members of IT.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
COMPREHENSIVE Access Tutorial 1 Creating a Database.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
3 A Guide to MySQL.
Access Creating a Database
Access Creating a Database
Yong Choi School of Business CSU, Bakersfield
Shelly Cashman: Microsoft Access 2016
Presentation transcript:

Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL

Objectives Introduce Structured Query Language (SQL) Use simple and compound conditions in SQL Use computed fields in SQL Use built-in SQL functions Use subqueries in SQL

Objectives (continued) Group records in SQL Join tables using SQL Perform union operations in SQL Use SQL to update database data Use an SQL query to create a table in a database

Introduction SQL (Structured Query Language) Allows users to query a relational database Must enter commands to obtain the desired results Standard language for relational database manipulation

Getting Started with SQL If you are completing the work in this chapter using Microsoft Office Access 2007, Microsoft Office Access 2010, or MySQL version 4.1 or higher, the following sections contain specific information about your DBMS

Getting Started with Microsoft Office Access 2007 and 2010 If you are using the Access 2007 or 2010 version of the Premiere Products database provided with the Data Files for this text: Tables in the database have already been created You will not need to execute the CREATE TABLE commands to create the tables or the INSERT commands to add records to the tables

Getting Started with Microsoft Office Access 2007 and 2010 (continued) To execute SQL commands shown in the figures in Access 2007 or Access 2010: Open the Premiere Products database Click the Create tab on the Ribbon Click the Query Design button in the Other group Click the Close button in the Show Table dialog box Click the View button arrow in the Results group on the Query Design Tools tab, then click SQL View The Query1 tab displays the query in SQL view, ready for you to type your SQL commands

Getting Started with MySQL MySQL-Premiere script provided with the Data Files for this text will: Activate the database Create the tables Insert the records To run a script in MySQL: Type the SOURCE command followed by the name of the file Press the Enter key

Getting Started with MySQL (continued) Before typing commands in MySQL, you must activate the database by typing the USE command followed by the name of the database The most recent command entered in MySQL is stored in a special area of memory called the statement history

Table Creation SQL CREATE TABLE command Creates a table by describing its layout Typical restrictions placed on table and column names by DBMS Names cannot exceed 18 characters Names must start with a letter Names can contain only letters, numbers, and underscores (_) Names cannot contain spaces

Table Creation (continued) INTEGER Number without a decimal point SMALLINT Uses less space than INTEGER DECIMAL(p,q) P number of digits; q number of decimal places CHAR(n) Character string n places long DATE Dates in DD-MON-YYYY or MM/DD/YYYY form

Simple Retrieval SELECT-FROM-WHERE: SQL retrieval command SELECT clause: lists fields to display FROM clause: lists table or tables that contain data to display in query results WHERE clause (optional): lists any conditions to be applied to the data to retrieve Simple condition: field name, a comparison operator, and either another field name or a value

Simple Retrieval (continued) FIGURE 3-6: SQL query with WHERE condition

Simple Retrieval (continued) FIGURE 3-7: Query results

Simple Retrieval (continued) FIGURE 3-8: Comparison operators used in SQL commands

Compound Conditions Compound condition Connecting two or more simple conditions using one or both of the following operators: AND and OR Preceding a single condition with the NOT operator Connecting simple conditions using AND operator All of the simple conditions must be true for the compound condition to be true Connecting simple conditions using OR operator Any of the simple conditions must be true for the compound condition to be true

Compound Conditions (continued) FIGURE 3-15: Compound condition that uses the AND operator FIGURE 3-16: Query results

Compound Conditions (continued) FIGURE 3-17: Compound condition that uses the OR operator FIGURE 3-18: Query results

Compound Conditions (continued) Preceding a condition by NOT operator Reverses the truth or falsity of the original condition BETWEEN operator Value must be between the listed numbers

Computed Fields Computed field or calculated field Field whose values you derive from existing fields Can involve: Addition (+) Subtraction (-) Multiplication (*) Division (/)

Computed Fields (continued) FIGURE 3-25: SQL query with a computed field and condition FIGURE 3-26: Query results