Structured Query Language SQL IST359 M005 Yang Wang 342 Hinds

Slides:



Advertisements
Similar presentations
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
Virtual training week 4 structured query language (SQL)
Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
The Database Environment IST359 M005 Yang Wang 342 Hinds
IST359 M005 Yang Wang 342 Hinds SQL Programming And The External Model.
IST359: Introduction to DBMS IST359 Fall 2012 Instructor : Yang Wang 342 Hinds M005: 9:30a-10:50a Lecture: Tuesdays.
STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 2 Structured Query Language.
Chapter 7: Introduction to SQL
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Structured Query Language SQL
System Administration Accounts privileges, users and roles
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Database Lecture # 1 By Ubaid Ullah.
Chapter 6: Introduction to SQL
I Copyright © 2004, Oracle. All rights reserved. Introduction.
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
I Copyright © Oracle Corporation, All rights reserved. Introduction.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
1 Chapter 7 Introduction to SQL. 2 Objectives Definition of terms Interpret history and role of SQL Define a database using SQL data definition language.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
CHAPTER 6: INTRODUCTION TO SQL © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer,
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 6: Introduction to SQL Modern Database Management 10 th Edition Jeffrey A. Hoffer,
Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
“INTRODUCTION TO DATABASE AND SQL”. Outlines 2  Introduction To Database  Database Concepts  Database Properties  What is Database Management System.
MySQL Database Connection
Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 6: Introduction to SQL Modern Database Management 11 th Edition Jeffrey A.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
CHAPTER 6: INTRODUCTION TO SQL Copyright © 2014 Pearson Education, Inc. 1 Essentials of Database Management Jeffrey A. Hoffer, Heikki Topi, V. Ramesh.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Chapter 7: Introduction to SQL
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
Database Basics BCIS 3680 Enterprise Programming.
DBMS_Week 3-4 DBMS. Three-Schema Architecture – Internal schema (one view) describes physical storage structures access paths, indexes used Typically.
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.
SQL.. AN OVERVIEW lecture3 1. Overview of SQL 2  Query: allow questions to be asked of the data and display only the information required. It can include.
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Relational Database Model & Database Development Process IST359 M005 Yang Wang 342 Hinds
SQL Select Statement IST359 M005 Yang Wang 342 Hinds
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
1 A Very Brief Introduction to Relational Databases.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 6: INTRODUCTION.
MY SQL INTRODUCTION TO LOGIN BASIC COMMANDS OTHER COMMANDS.
SQL Basics Review Reviewing what we’ve learned so far…….
CHAPTER 6: INTRODUCTION TO SQL © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer,
CS 3630 Database Design and Implementation
“Introduction To Database and SQL”
PGT(CS) ,KV JHAGRAKHAND
SQL Creating and Managing Tables
SQL 101.
“Introduction To Database and SQL”
DATABASE MANAGEMENT SYSTEM
SQL Creating and Managing Tables
SQL Creating and Managing Tables
SQL Fundamentals in Three Hours
SQL .. An overview lecture3.
SQL-1 Week 8-9.
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Structured Query Language SQL IST359 M005 Yang Wang 342 Hinds

Acknowledgements and caveat These slides draw liberally, with permission, from the following sources: IST359 materials by Prof. Michael Fudge Jr. Slides from Murach’s SQL Server 2008 book Caveat (beware): At best, PowerPoint slides are only a pale limitation of the entirety of a class meeting. In IST359 in particular, the lectures will cover topics beyond what appears in these slides. Don’t rely on them as a substitute for attending class.

Learning Objectives Describe and use basic SQL commands Explain how and why SQL is used, and why it’s important Compare and contrast DML and DDL Use SQL commands to create metadata structures and perform CRUD operations.

WHAT IS SQL? A computer programming language designed for managing data and structures (metadata) in relational database management systems.

Brief History of SQL 1970– E. Codd develops relational database concept –System R with Sequel (later SQL) created at IBM Research Lab 1979–Oracle markets first relational DB with SQL 1986–ANSI SQL standard released 1989, 1992, 1999, 2003, 2007–Major ANSI standard updates Current–SQL is supported by most major database vendors at 1999, 2003 and 2007

The purpose of the SQL standard SQL Syntax and Semantics Intrinsic Data Structures Portability Levels: Minimal (L1) Complete (L2) Allow for Growth / Enhancement

Benefits of the SQL standard Reduced training costs Productivity Application portability Application longevity Reduced dependence on a single vendor Cross-system communication Yes. The standard helps, but each of these benefits is not as realized as other standards, such as HTML

The SQL Server Environment Server Instance Catalog (db) Schema Objects Catalog (db) Schema Objects In this class we use: SQL Server  ist-s-students.syr.edu Instance . (default) Catalog  ist359yournetid# Schema  dbo (default)

SQL Server 2008 R2: ist-s-students Other Information: – SQL Dialect: T-SQL / Transact-SQL – Case Sensitive Collation?: Yes – System tables used to represent meta data. – Client / Server over TCP/IP Connect to database using: host/IP, port number, logon, password Client software used to manage data/meta data on server – Everything can be expressed in SQL! Naming Rules for Objects in SQL Server: – Up to 128 characters long – Must begin with a letter or # (cannot be a digit) – Can contain digits, letters, _,. – Spaces can be used but should be avoided.

My Naming Conventions WhatMike’s ConventionRationale for use All object namesUse all lower case letters.Disambiguation: eg. Employee vs. employee for example All object namesUse underscore in place of SPACE Avoid the need to place brackets around identifiers. employee_phone_number vs. [employee phone number] TablesPluralizeShould be employees table, since it contains more than one employee TablesQualify with logical schemaDisambiguation of objects within the same database: eg. kmart_employees vs. netflix_employees Column namesQualify with table nameHelps define scope of object. Eg. employee_zipcode.vs vendor_zipcode Constraintspk= primary key fk=foreign key u=unique ck=check i=index Disambiguation of constraints, for example: ck_vendor_zipcode.vs. fk_vendor_zipcode

SQL: Language Breakdown DomainSQL CommandsObjects Metadata (DDL) CREATE ALTER DROP Tables, functions, views, procedures, etc DATA (DML) C - INSERT R - SELECT U - UPDATE D - DELETE Tables (as a target) Security (DCL) GRANT REVOKE Tables, functions, views, procedures, etc. Transactions (DTL) BEGIN TRANS COMMIT ROLLBACK Controls DML statements

Workflow in SQL Mgmt Studio 1.Type in SQL 2.Highlight it 3.Check it (For syntax errors) 4.Wreck it (Execute on Server) 5.Once you execute “the program has run and the damage is done.” There is no undo, only redo, meaning if you delete something to get it back you must start over again.

DDL 1 Create students table w/Defaults ID Name GPA Year (Fr, So, Jr, Sr) Are they iSchool? DOB?

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

DDL2 Students table add constraints Primary Key Unique s Valid GPA’s

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

DML Add students List students Find one student Update students Update one student

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Lookup table Create table student_years Add pk to table Add data to student_years Alter students add FK

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.

Murach’s SQL Server 2008, C10© 2008, Mike Murach & Associates, Inc.