SQL.

Slides:



Advertisements
Similar presentations
What is a Database By: Cristian Dubon.
Advertisements

Tutorial 3 Queries and Table Relationships
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Chapter 2 Querying a Database
SQL Tutorials To understand some of the topics please analyze the following tutorials: The following tutorials will help:
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 16 – SQL SEAN J. TAYLOR.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
1 Relational Databases. 2 Find Databases here… 3 And here…
ASP.NET Programming with C# and SQL Server First Edition
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.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Database: SQL and MySQL
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Selecting Data.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
STRUCTURED QUERY LANGUAGE SQL-II IST 210 Organization of Data IST210 1.
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Lesson 2: Designing a Database and Creating Tables.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
School of Geography FACULTY OF ENVIRONMENT Querying with ArcGIS.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Structured Query Language
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
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.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Indexes By Adrienne Watt.
GO! with Microsoft Office 2016
 2012 Pearson Education, Inc. All rights reserved.
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.
The Database Exercises Fall, 2009.
Larry Reaves October 9, 2013 Day 16: Access Chapter 2 Larry Reaves October 9, 2013.
GO! with Microsoft Access 2016
JDBC.
Database Management  .
Building and Using Queries
Databases and Information Management
The University of Texas – Pan American
Database Queries.
CIS16 Application Programming with Visual Basic
Chapter 22 - SQL, MySQL, DBI and ADO
PHP and MySQL.
Structured Query Language
Databases and Information Management
Introduction To Structured Query Language (SQL)
Grauer and Barber Series Microsoft Access Chapter One
CS3220 Web and Internet Programming SQL and MySQL
Database Connections.
Manipulating Data Lesson 3.
Finding Your GP Data Ian Richardson BA CPA CGA Colin Pich CPA CGA.
Nagendra Vemulapalli Access chapters 1&2 Nagendra Vemulapalli
Presentation transcript:

SQL

Technologies Involved in Project Architecture Web server Web pages, JS files, and data Database server (if necessary) Data Team web space URL: http://teams.up.ist.psu.edu/ist402sp17/section2/Team01/.... Each team member can access the folder and files under it. Be careful when you modify a document.

Database Server SQL Server Why is Python insufficient? Help manage data and respond dynamic queries Why is Python insufficient? Python is good if you know what data users may need Database server is better if user info and needs are more dynamic and unpredicatable. Team database IST402SP1700201 – IST402SP1700210

Revisit to Relational Database and SQL

Relational Model A relational database includes tables that are connected through keys (primary key  foreign key). Table: a set of unique records (rows) with multiple attributes (columns) Each table is an entity Primary key: the attribute(s) used to identify a record in a table. Foreign key: the attribute(s) in a table used as the primary key in another table Primary-foreign key pair defines a relationship between two entities.

Example MC 2 entities and relationships Data sets we have Car-assignments Credit card spending records Shopper card spending records GPS records What entities do we have here? Their relations?

employee shop spending GPS car

Import Data into Database Start SQL Server 2014 Management Studio Log on the Database Server upsql

Locate your database and right-click to find the Import-Data tool

Follow the Import and Export Wizard Choose “Flat File Source” as the type of data source, and “SQL Server Native Client 11.0” as the type of your Destination

Exercise: Import the cc_data.csv into your database Use your personal database. Copy the source file to your desktop and import the copied file.

SQL Structured Query Language

Basic Form of SQL Select attribute1, attributes2, … From table Where condition Get all spending records before 1/10/2014 Select * From table_name Where timestamp < '2014-01-01 0:0:0.0'

SQL Match Criteria The WHERE clause match criteria may include Equals “=“ Not Equals “<>” Greater than “>” Less than “<“ Greater than or Equal to “>=“ Less than or Equal to “<=“ Multiple matching criteria may be specified using AND Representing an intersection of the data sets OR Representing a union of the data sets

Save Query Result Select attri, … into Table_name

Count function Get the number of records Select count(*) From table Where condition For subgroup count Group by aggregation_condition

SQL: Wildcard Searches LIKE Multiple character wildcard character is a percent sign (%) Single character wildcard character is an underscore (_) Select * FROM employee WHERE Display LIKE ‘L%';

SQL: Sorting the Results ORDER BY SELECT LastName, FirstName, Count(*) as ShoppingTimes FROM cc_data GROUP BY LastName, FirstName ORDER BY ShoppingTimes

Find the amount of Spending

Join Example: Combine More Tables SELECT attribut1, … FROM Table1, Tabe2 WHERE Table1.JoinAttr = Table2.JoinAttr

Find out Whether a Person Driving a Car when Shopping

Select FirstName, LastName, ShopID From employee, spending as sp, GPS as gp Where employeeID = spenderID and assigneCardID = CarID and sp.time = gp.time