Lab 13 Databases and SQL.

Slides:



Advertisements
Similar presentations
Database Queries and Structured Query Language (SQL) J.G. Zheng May 16 th 2008.
Advertisements

IMPLEMENTATION OF INFORMATION RETRIEVAL SYSTEMS VIA RDBMS.
Chapter 11 Group Functions
Chapter 8 Special-Purpose Languages. SQL SQL stands for "Structured Query Language". Allows the user to pose complex questions of a database. It also.
Introduction to Structured Query Language (SQL)
Introduction to Oracle9i: SQL1 SQL Group Functions.
Chapter 3: Relational Model
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
Microsoft Access 2010 Chapter 7 Using SQL.
Computer Science 101 Web Access to Databases SQL – Extended Form.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Chapter 6 Group Functions. Chapter Objectives  Differentiate between single-row and multiple-row functions  Use the SUM and AVG functions for numeric.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) Structured Query Language Introduction to SQL Structured Query Language.
Structured Query Language Chris Nelson CS 157B Spring 2008.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Information Technologies and Microsoft SQL Server Day 2 by Alper Özpınar
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
Advanced SELECT Queries CS 146. Review: Retrieving Data From a Single Table Syntax: Limitation: Retrieves "raw" data Note the default formats… SELECT.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
© Jalal Kawash Database Queries Peeking into Computer Science.
Mining real world data RDBMS and SQL. Index RDBMS introduction SQL (Structured Query language)
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology.
Single-Table Queries 2: Advanced Topics CS 320. Review: Retrieving Data From a Single Table Syntax: Limitation: Retrieves "raw" data SELECT field1, field2,
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
IS6146 Databases for Management Information Systems Lecture 4: SQL IV – SQL Functions and Procedures Rob Gleasure robgleasure.com.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Day 5 - More Complexity With Queries Explanation of JOIN & Examples Explanation of JOIN & Examples Explanation & Examples of Aggregation Explanation &
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Chapter 3 The Relational Model. Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. “Legacy.
SQL Reminder Jiankang Yuan Martin Lemke. SQL Reminder - SELECT SELECT column_name1, column_name2, … FROM table_name SELECT * FROM table_name.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Web Systems & Technologies
SQL Query Getting to the data ……..
Rob Gleasure robgleasure.com
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Structured Query Language – The Basics
SQL FUNDAMENTALS CDSE Days 2018.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Using SQL to Prepare Data for Analysis
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
MENAMPILKAN DATA DARI SATU TABEL (Chap 2)
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
The Relational Model Relational Data Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Rob Gleasure robgleasure.com
SQL LANGUAGE and Relational Data Model TUTORIAL
Built in Functions Massaging the data.
Chapter 4 Summary Query.
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Introduction To Structured Query Language (SQL)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Access: SQL Participation Project
SQL Aggregation.
CS122 Using Relational Databases and SQL
Introduction To Structured Query Language (SQL)
Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Lab 13 Databases and SQL

Useful information Last lab of the semester . Next week there will be a lab exam . No assignments for this lab.

Databases Data : facts and statistics collected together for reference or analysis Database : A database is a collection of one or more relations, where each relation is a table with rows and columns RDBMS : It contains a set of relations

Database Table attributes (or columns) customer_name customer_street customer_city Jones Smith Curry Lindsay Main North Park Harrison Rye Pittsfield tuples (or rows)

RDBMS Relation: made up of 2 parts: Instance : a table , with rows and columns. #Rows = cardinality, #fields = degree / arity. Schema : specifies name of relation, plus name and type of each column. E.G. Students(sid: string, name: string, login: string, age: integer, gpa: float )

SQL –Structured Query Langauage Developed by IBM (system R) in the 1970s Vendors Oracle MYSQL MS-SQL server IBM DB2

SQL –Structured Query Langauage Activity I : SELECT Tutorial from BBC TABLE http://sqlzoo.net/1.htm Hint: SELECT >>FROM >>WHERE SELECT is the data extraction operator.You can choose the attributes here (columns),’ * ‘ returns all the columns from the table FROM :Table name is defined here. WHERE : It is used to limit the rows according to the condition/s.

SQL –Structured Query Langauage Activity I : SELECT Tutorial from BBC TABLE 2.Relational operators same as c++ =(no double sign here like c++) ,>,<,<=,>=,!= Note :there is no operator like !< .Just use > instead 3.per capita GDP is the GDP divided by the population GDP/population Calculations are usually done in select clause .A new column is created with the calculation .It is a better practice to use an alias for a calculated column . Aliases : Aliases are defined in the from clause, called in select and where clauses . Eg.Select t.id from table as t ( Alternatively used as “from table t” without “as”.Here we create a new column called percaptaGDP using the formula) .

SQL –Structured Query Langauage Activity I : SELECT Tutorial from BBC TABLE 4. SQL aggregate functions returns a single value, calculated from values in a column. Useful aggregate functions: Used on column with quantitative data AVG() - Returns the average value COUNT() - Returns the number of rows ROUND()-Returns after rounding the number MAX() - Returns the largest value MIN() - Returns the smallest value SUM() - Returns the sum

SQL –Structured Query Langauage Activity I : SELECT Tutorial from BBC TABLE 6. The SQL LIKE Operator The LIKE operator is used to search for a specified pattern in a column. SQL LIKE Syntax: SELECT column name(s) FROM table name WHERE column name LIKE pattern; % operator is used inside the like operator. Ex. ‘%United’–Returns strings which ends with with United ‘United%’ -Returns string which starts with United ‘%United%’-Returns string which contains Unitedanywhere in the field.

SQL –Structured Query Langauage Activity I : SELECT Tutorial from BBC TABLE 5.The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...);

SQL –Structured Query Langauage ActIivity 2:More practice with SELECT: Additional practice of the basic features using a table of Nobel Prize winners. http://sqlzoo.net/1b.htm

SQL joins An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them. The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER JOIN returns all rows from multiple tables where the join condition is met. http://sqlzoo.net/3.htm

Questions?