CS162 Discussion Notes March 31, 2011 Jorge Ortiz.

Slides:



Advertisements
Similar presentations
Data Definition Language (DDL)
Advertisements

SQL Introduction Standard language for querying and manipulating data Structured Query Language Many standards out there: SQL92, SQL2, SQL3. Vendors support.
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
Sanjay Goel, School of Business, University at Albany, SUNY 1 SQL- Data Definition Language ITM 692 Sanjay Goel.
5 Chapter 5 Structured Query Language (SQL2) Revision.
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.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
Correlated Queries SELECT title FROM Movie AS Old WHERE year < ANY (SELECT year FROM Movie WHERE title = Old.title); Movie (title, year, director, length)
Exercises Product ( pname, price, category, maker) Purchase (buyer, seller, store, product) Company (cname, stock price, country) Person( per-name, phone.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Oracle Data Definition Language (DDL)
Copyright © Curt Hill SQL The Data Definition Language.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Introduction to Structured Query Language (SQL) COM S Fall Instructor: Ying Cai Iowa State University 1.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
An Introduction to SQL Kirk Anne Computing & Information Technology SUNY Geneseo Nael Alian
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
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.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 7 Introduction to Structured.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
Visual Programing SQL Overview Section 1.
SQL – Structured Query Language
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
Database Queries aka SQL (pronounced “ sequel ” ).
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
Aggregation SELECT Sum(price) FROM Product WHERE manufacturer=“Toyota” SQL supports several aggregation operations: SUM, MIN, MAX, AVG, COUNT Except COUNT,
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
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.
SQL Reminder Jiankang Yuan Martin Lemke. SQL Reminder - SELECT SELECT column_name1, column_name2, … FROM table_name SELECT * FROM table_name.
Lec-7. 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.
Creating and Managing Tables. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically represents subsets.
Big Data Yuan Xue CS 292 Special topics on.
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Insert, Update and the rest…
Database Models Relational Model
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Creating Tables & Inserting Values Using SQL
Database systems Lecture 3 – SQL + CRUD
Creating Database Objects
JDBC II IS
Presentation transcript:

CS162 Discussion Notes March 31, 2011 Jorge Ortiz

ACKNOWLEDGEMENTS Paul A. Strassmann, George Mason University Rightscale.com Kirk Anne, SUNY Geneseo Randy Katz, UC Berkeley

Outline Cloud computing – What is it? Virtualization – Hypervisor configurations Amazon EC2 Relational databases – Entity relationship diagrams Data models – Imperative versus declarative SQL

What is cloud computing? Cloud computing is Internet-based computing, whereby shared resources, software and information are provided to computers and other devices on-demand, like electricity – Wikipedia

Data Centers 6 Google’s Containerized Datacenter Microsoft Chicago Datacenter

What runs on these machines? All types of applications! How can we make best use of the resources?

Virtualization (2)

Virtualization (3)

Amazon EC2 Architecture

Applications Web applications Databases Compute-intensive jobs Client-Server applications – Project 3! Chat Server will be in the cloud Clients will be outside the cloud Application state stored in database

Parts of a database Record Attribute/Field Tables Records become “ rows ” Attributes/fields become “ columns ” Rules determine the relationship between the tables and tie the data together to form a database

Basic SQL Commands Creating tables with CREATE Adding data with INSERT Viewing data with SELECT Removing data with DELETE Modifying data with UPDATE Destroying tables with DROP

Creating tables with CREATE Generic form CREATE TABLE tablename ( column_name data_type attributes…, … ) Table and column names can ’ t have spaces or be “ reserved words ” like TABLE, CREATE, etc.

Phone Book/Contact Table CREATE TABLE contacts ( NameVARCHAR(40), Address VARCHAR(60), Company VARCHAR(60), Phone VARCHAR(11), URLVARCHAR(80), AgeINT, HeightFLOAT, BirthdayDATE, WhenEnteredTIMESTAMP ); Plan your tables very carefully! Once created, they are difficult to change!

Data Types Binary – Database specific binary objects (BLOB) Boolean – True/False values (BOOLEAN) Character – Fixed width (CHAR) or variable size (VARCHAR) Numeric – Integer (INT), Real (FLOAT), Money (MONEY) Temporal – Time (TIME), Date (DATE), Timestamp (TIMESTAMP)

Adding data with INSERT Generic Form INSERT INTO tablename (column_name,…) VALUES (value,…)

Inserting a record into ‘ contacts ’ INSERT INTO contacts (contactid,name,address,company,phone,url,a ge,height,birthday,whenentered) VALUES (1, ‘ Joe ’, ’ 123 Any St. ’, ’ ABC ’, ’ ’, ‘ ’,30,1.9, ’ 6/14/1972 ’, now());

Inserting a partial record INSERT INTO contacts (contactid,name,phone) VALUES (2, ’ Jane ’, ’ ’ );

Automatic key generation CREATE SEQUENCE contactidseq; Change the ContactID line in the CREATE TABLE to: ContactIDINT DEFAULT nextval( ‘ contactidseq ’ ) PRIMARY KEY Or when inserting into a table INSERT contacts (contactid,name,phone) VALUES (nextval( ‘ contactidseq ’ ), ’ Jack ’, ‘ ’ );

Viewing data with SELECT Generic Form SELECT column,… FROM table,… WHERE condition GROUP BY group_by_expression HAVING condition ORDER BY order_expression The most used command Probably the most complicated also If used improperly, can cause very long waits because complex computations

A few simple SELECTs SELECT * FROM contacts; – Display all records in the ‘ contacts ’ table SELECT contactid,name FROM contacts; – Display only the record number and names SELECT DISTINCT url FROM contacts; – Display only one entry for every value of URL.

Refining selections with WHERE The WHERE “ subclause ” allows you to select records based on a condition. SELECT * FROM contacts WHERE age<10; – Display records from contacts where age<10 SELECT * FROM contacts WHERE age BETWEEN 18 AND 35; – Display records where age is 18-35

Additional selections The “ LIKE ” condition – Allows you to look at strings that are alike SELECT * FROM contacts WHERE name LIKE ‘ J% ’ ; – Display records where the name starts with ‘ J ’ SELECT * FROM contacts WHERE url LIKE ‘ %.com ’ ; – Display records where url ends in “.com ”

Removing data with DELETE Generic Form DELETE FROM table WHERE condition; DELETE FROM contacts WHERE age<13;

Modifying data with UPDATE Generic Form UPDATE table SET column=expression WHERE condition; UPDATE contacts SET company= ‘ AOL ’ WHERE company= ‘ Time Warner ’ ;

Destroying tables with DROP Generic Form DROP TABLE tablename; DROP TABLE contacts;

Joining together tables SELECT name,phone,zip FROM people, phonenumbers, address WHERE people.addressid=address.addressid AND people.id=phonenumbers.id; People IdNameAddressID 1Joe1 2Jane2 3Chris3 Address AddressIDCompanyAddressZip 1ABC XYZ PDQ PhoneNumbers PhoneIDIdPhone

GROUP BY/HAVING The “ GROUP BY ” clause allows you to group results together with “ aggregate functions ” – AVG(), COUNT(), MAX(), MIN(), SUM() – COUNT DISTINCT HAVING allows you to search the GROUP BY results

Important links