A Short Introduction to Analyzing Biological Data Using Relational Databases Part III: Writing Simple (Single Table) Queries to Access Relational Data.

Slides:



Advertisements
Similar presentations
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Advertisements

1 Constraints, Triggers and Active Databases Chapter 9.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
5 Chapter 5 Structured Query Language (SQL1) Revision.
Concepts of Database Management Sixth Edition
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
Introduction to SQL Steve Perry
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
Analyzing Data For Effective Decision Making Chapter 3.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
CS 1308 Computer Literacy and the Internet
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
© Jalal Kawash Database Queries Peeking into Computer Science.
SQL - DML. Data Manipulation Language(DML) Are used for managing data: –SELECT retrieve data from the a database –INSERT insert data into a table –UPDATE.
Component 4: Introduction to Information and Computer Science Unit 6a Databases and SQL.
Oracle & SQL Introduction. Database Concepts Revision DB? DBMS? DB Application? Application Programs? DBS? Examples of DBS? Examples of DBMS? 2Oracle.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
Database UpdatestMyn1 Database Updates SQL is a complete data manipulation language that can be used for modifying the data in the database as well as.
Database Design And Implementation. Done so far… Started a design of your own data model In Software Engineering, recognised the processes that occur.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 6 This material was developed by Oregon Health & Science.
A Guide to MySQL 6. 2 Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT command.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
ACCESS CHAPTER 2 Introduction to ACCESS Learning Objectives: Understand ACCESS icons. Use ACCESS objects, including tables, queries, forms, and reports.
Alex Ropelewski Pittsburgh Supercomputing Center National Resource for Biomedical Supercomputing Bienvenido Vélez
 CONACT UC:  Magnific training   
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
SQL and Relational Algebra Edel Sherratt Nigel Hardy Horst Holstein.
1 A Short Introduction to Analyzing Biological Data Using Relational Databases Part II: Creating a Relational Database to Model Biological Data Alex Ropelewski.
SQL Introduction SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel – (Structured English.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Database Access with SQL
Chapter 5 Introduction to SQL.
Bioinformatics Data Management
Oracle & SQL Introduction
Insert, Update and the rest…
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
 2012 Pearson Education, Inc. All rights reserved.
SQL Creating and Managing Tables
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
CS1222 Using Relational Databases and SQL
The University of Texas – Pan American
SQL Creating and Managing Tables
Database.
Relational Databases The Relational Model.
Relational Databases The Relational Model.
SQL Creating and Managing Tables
Databases.
Introduction To Databases GCSE Computer Science
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Contents Preface I Introduction Lesson Objectives I-2
Introduction To Databases GCSE Computer Science
Session - 6 Sequence - 1 SQL: The Structured Query Language:
DATABASE Purpose of database
Database SQL.
Presentation transcript:

A Short Introduction to Analyzing Biological Data Using Relational Databases Part III: Writing Simple (Single Table) Queries to Access Relational Data Alex Ropelewski ropelews@psc.edu Pittsburgh Supercomputing Center National Resource for Biomedical Supercomputing Bienvenido Vélez Bienvenido.Velez@upr.edu University of Puerto Rico at Mayaguez Department of Electrical and Computer Engineering

Learning Objectives Using SQL SELECT statement to: Select which attributes to show in a result Select which rows to show in a result Using UPDATE to modify rows Using DELETE to remove rows Using logical operators (AND, OR and NOT) to form more complex selections of rows Using INTO clause to store result rows into new database tables

The language of relational databases SQL The language of relational databases Data definition/schema creation Implements relational algebra operations Data manipulation Insertion Manipulation Updates Removals A standard (ISO) since 1987

An Improved Relational Database Design Sequences Accession Description Species P14555 Group IIA Phospholipase A2 Human P81479 Phospholipase A2 isozyme IV Indian Green Tree Viper P00623 Phospholipase A2 Eastern Diamondback Rattlesnake Matches Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 E-52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Runs RunNum Date Matrix 1 7/21/07 Pam70 2 7/20/07 Blosom80

SQL: SELECT Statement Selects attributes SELECT Accession, Description, Species FROM Sequences In this context since we are selecting all attributes in the table. We could use the wildcard character * instead of listing the individual attribute names: SELECT * FROM Sequences Sequences Accession Description Species P14555 Group IIA Phospholipase A2 Human P81479 Phospholipase A2 isozyme IV Indian Green Tree Viper P00623 Phospholipase A2 Eastern Diamondback Rattlesnake

Used to filter tuples with certain attribute values SQL: WHERE Clause Used to filter tuples with certain attribute values Used in many SQL Statements, including SELECT SELECT * FROM Sequences WHERE Species=’Human’ Sequences Accession Description Species P14555 Group IIA Phospholipase A2 Human

Used to order data by attribute values SQL: ORDER BY Clause Used to order data by attribute values Used in many SQL Statements, including SELECT SELECT * FROM Sequences ORDER BY Species Sequences Accession Description Species P00623 Phospholipase A2 Eastern Diamondback Rattlesnake P14555 Group IIA Phospholipase A2 Human P81479 Phospholipase A2 isozyme IV Indian Green Tree Viper

SQL: UPDATE Statement Revises table data Sequences (before UPDATE) Accession Description Species P14555 Group IIA Phospholipase A2 Human UPDATE Sequences SET Species=’Homo Sapiens’ WHERE Accession=’P14555’ Sequences (after UPDATE) Accession Description Species P14555 Group IIA Phospholipase A2 Homo Sapiens

Removes table data – Be Careful! SQL: DELETE Statement Removes table data – Be Careful! Sequences (before DELETE) Accession Description Species P14555 Group IIA Phospholipase A2 Human P81479 Phospholipase A2 isozyme IV Indian Green Tree Viper P00623 Phospholipase A2 Eastern Diamondback Rattlesnake DELETE FROM Sequences WHERE Accession=’P14555’ Sequences (after DELETE) Accession Description Species P81479 Phospholipase A2 isozyme IV Indian Green Tree Viper P00623 Phospholipase A2 Eastern Diamondback Rattlesnake

Used in many SQL Statements One of two conditions must be met SQL: OR operator Used in many SQL Statements One of two conditions must be met SELECT * FROM Matches WHERE Accession=’P14555’ OR Accession=’P00623’ Matches Select Result Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 -E52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Accession RunNum eValue P14555 1 4.18 E-32 2 3.47 E-33 P00623 1.21 E-08

Used in many SQL Statement Two of two conditions must be met SQL: AND operator Used in many SQL Statement Two of two conditions must be met SELECT * FROM Matches WHERE Accession=’P14555’ AND RunNum=’1’ Matches Select Result Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 -E52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Accession RunNum eValue P14555 1 4.18 E-32

Used in many SQL Statement Negation of condition SQL: NOT operator Used in many SQL Statement Negation of condition SELECT * FROM Matches WHERE NOT Accession=’P14555’ Matches Select Result Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 -E52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Accession RunNum eValue P81479 2 2.68 -E52 1 1.20 E-54 P00623 1.21 E-08

Used to clarify order of operations SQL: Parenthesis Used to clarify order of operations SELECT * FROM Matches WHERE ((Accession=’P14555’) OR (Accession=’P81479’)) AND RunNum=’2’ Matches Select Result Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 -E52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Accession RunNum eValue P14555 2 3.47 E-33 P81479 2.68 E-52

Used to store results in new tables SQL: INTO Used to store results in new tables SELECT * INTO GoodMatches FROM Matches WHERE (eValue >= 1.0E-10) Matches GoodMatches Table Accession RunNum eValue P14555 1 4.18 E-32 P81479 2 2.68 -E52 3.47 E-33 1.20 E-54 P00623 1.21 E-08 Accession RunNum eValue P00623 2 1.21 E-08

Key Concepts SQL’s SELECT statement can be used to select which attibutes should appear in a result SQL’s SELECT statement can be used to select which rows should appear in a result using the WHERE clause SQL’s UPDATE statement can be used to modify rows SQL’s DELETE statement can be used to remove rows Logical operators can be used to form complex logical conditions for selecting which rows to show in a result The INTO clause can be used to store results into a new table in the database