Intro to SQL CS-422 Dick Steflik.

Slides:



Advertisements
Similar presentations
Introduction to Structured Query Language (SQL)
Advertisements

Java and Databases CS-328 Dick Steflik. Database Drivers Think of a database as just another device connected to your computer like other devices it has.
Introduction to Structured Query Language (SQL)
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
Introduction to Structured Query Language (SQL)
CSC 2720 Building Web Applications Database and SQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Introduction to SQL Steve Perry
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
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.
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.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
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.
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
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.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
CompSci 280 S Introduction to Software Development
Fundamentals of DBMS Notes-1.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Structured Query Language
Fundamental of Database Systems
Database Access with SQL
CS SQL.
Microsoft Office Access 2010 Lab 3
SQL: Schema Definition and Constraints Chapter 6 week 6
Insert, Update and the rest…
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL Creating and Managing Tables
Session 4 PHP & MySQL.
Web Programming Week 3 Old Dominion University
ISC440: Web Programming 2 Server-side Scripting PHP 3
Structured Query Language (SQL) William Klingelsmith
SQL Creating and Managing Tables
Accounting System Design
Chapter 8 Working with Databases and MySQL
SQL Creating and Managing Tables
Insert, Update, Delete Manipulating Data.
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Chapter 2 Views.
Chapter 7 Introduction to Structured Query Language (SQL)
Accounting System Design
Databases and Information Management
Chapter 2 Views.
SQL-1 Week 8-9.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Contents Preface I Introduction Lesson Objectives I-2
Web Programming Week 3 Old Dominion University
Relational Database Design
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
DATABASE Purpose of database
Database SQL.
Manipulating Data Lesson 3.
Web Programming Week 3 Old Dominion University
SQL (Structured Query Language)
Presentation transcript:

Intro to SQL CS-422 Dick Steflik

Structured Query Language Developed by C. Date for Relational Data Base Management Systems (RDBMS) Simple Declarative Language has no program control statements

SQL Two categories of commands Data Manipulation Commands deal with: RETRIEVING DATA MAINTAINING DATA ADDING, UPDATING, DELETING Data Definition Commands DEAL WITH: CREATING DATABASE OBJECTS (TABLES,VIEWS) Object organization and attributes

Data Model Database objects are modeled on the concept of a table (i.e. rows and columns) Each row is a single table object Columns are the attributes of that table A database is a collection of related tables

Referential Integrity Rules to insure that table data stays accurate and accessible rows in a table should be unique one column should contain no duplicate data primary key column values cannot contain repeating groups or arrays null is different than space and zero, 2 null values are not considered equal

Data Manipulation Commands Select - query and display data from a database Insert - a new row into a table Update - modify a column in a table Delete a row from a table

Select Select (column list) from (sources) where (conditions) order by (ocolumn list) column list - comma separated list of names of columns to be in output Ex. ssn , lastname , firstname,gpa can contain literals to be included in output Ex. Ssn,”~”,lastname,”~”,firstname sources - name(s) of table(s) to retrieve data from conditions (optional) - conditions for selections lastname like “S%” (lastname = “Steflik) and (firstname like “R%”) ocolumn list (optional)- list of columns that output should be ordered by Ex select * from student select lastname,fristname from student where gpa > 3.0 select lastname,firstname from student order by lastname,firstname

Select - joined tables Two tables may be joined and viewed as a single data source is the both have a common column suppose we have 2 tables: Inventory and category and each has a column called catg_code In category catg_code is unique and is the primary key

Select - joined tables (cont.) Inventory Category P_no Catg_code qty Catg_code descr

Select - joined tables (cont.) To retrieve all of the part numbers and the name of the category to which the part belongs: select inventory.p_no category.descr from inventroy , category select a.p_no,” “,b.descr from a inventory , b category

Insert Add a row to a table use jdbc execute Update method insert into category values(“IGN”,”Ignition System”) use jdbc execute Update method ex. Stmt.executeUpdate(“insert into Category values(‘IGN’,’Ignition System’)”);

Update Modify an existing row in a table Use jdbc executeUpdate method update category set descr = “Ignition Subsystem” where catg_code = “IGN” Use jdbc executeUpdate method String s = “update category set descr = ‘Ignition Subsystem’ where catg_code = ‘IGN’ ”; stmt.executeUpdate(s);

Delete Remove a row from a table delete from category where catg_code = “IGN” remove the IGN category delete from category where catg_code like “I%” remove all rows where catg_code starts with an “I”

Data Definition Commands Create table add a table to a database Drop Table remove a table from a database Alter Table add or delete column(s)

A good reference Phil Greenspun – SQL for Web Nerds http://philip.greenspun.com/sql/