Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.

Slides:



Advertisements
Similar presentations
The Database Environment
Advertisements

Chapter 4 5 6_ SQL SQL Is: Structured Query Language
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
IMS1907 Database Systems Summer Semester 2004/2005 Lecture 9 Structured Query Language – SQL Data Definition Language - DDL.
1 © Prentice Hall, 2002 Chapter 7: SQL Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
1 IS 4420 Database Fundamentals Chapter 7: Introduction to SQL Leon Chen.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Database Management System LICT 3011 Eyad H. Elshami.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
Chapter 6: Introduction to SQL
Database Design lecture 3_1 1 Database Design Lecture 3_1 Data definition in SQL.
Database Technical Session By: Prof. Adarsh Patel.
Database System SQL November 1st, 2009 Software Park, Bangkok Thailand Pree Thiengburanathum College of Arts and Media Chiang Mai University.
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.
Chapter 8 Part 1 SQL-99 Schema Definition, Constraints, Queries, and Views.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 6: Introduction to SQL Modern Database Management 10 th Edition Jeffrey A. Hoffer,
Guofeng Cao CyberInfrastructure and Geospatial Information Laboratory Department of Geography National Center for Supercomputing Applications (NCSA) University.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
© 2007 by Prentice Hall 1 Chapter 7: Introduction to SQL Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
1 SQL Tarek El-Shishtawy Professor Ass. Of Computer Engineering.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
Dr. Chen, Data Base Management Chapter 6: Introduction to SQL Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga University.
Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 6: Introduction to SQL Modern Database Management 11 th Edition Jeffrey A.
CHAPTER 6: INTRODUCTION TO SQL Copyright © 2014 Pearson Education, Inc. 1 Essentials of Database Management Jeffrey A. Hoffer, Heikki Topi, V. Ramesh.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Lec 3- B Database Integrity 1. Overview Define a database using SQL data definition language Work with Views Write single table queries Establish referential.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
© 2005 by Prentice Hall 1 Chapter 7: Introduction to SQL Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
Chapter 7: Introduction to SQL
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
CHAPTER 6: INTRODUCTION TO SQL © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer,
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
© 2011 Pearson Education 1 Chapter 6: Basic SQL Modern Database Management 10 th Edition, International Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Chapter 6: Introduction to SQL
Sql DDL queries CS 260 Database Systems.
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 Overview Structured Query Language
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
1 © Prentice Hall, 2002 Chapter 7: SQL Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
CS263 Information Modeling Course tutor: Tony Browne Some diagrams in these notes are small when printed 6.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 6: INTRODUCTION.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Lecture 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A. Hoffer,
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 6: INTRODUCTION.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
CHAPTER 6: INTRODUCTION TO SQL © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer,
SQL Query Getting to the data ……..
DATABASE MANAGEMENT SYSTEM
STRUCTURED QUERY LANGUAGE
CHAPTER 6: INTRODUCTION TO SQL
SQL OVERVIEW DEFINING A SCHEMA
SQL-1 Week 8-9.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
SQL (Structured Query Language)
Presentation transcript:

Lecture # 24 Introduction to SQL Muhammad Emran Database Systems

2 Objectives Definition of terms Definition of terms Discuss advantages of standardized SQL Discuss advantages of standardized SQL Define a database using SQL data definition language Define a database using SQL data definition language Write single table queries using SQL Write single table queries using SQL Establish referential integrity using SQL Establish referential integrity using SQL Work with Views Work with Views

3 The Physical Design Stage of SDLC (Figures 2-4, 2-5 revisited) Purpose –programming, testing, training, installation, documenting Deliverable – operational programs, documentation, training materials, program/data structures Database activity – physical database design and database implementation Project Identification and Selection Project Initiation and Planning Analysis Physical Design Implementation Maintenance Logical Design Implementation Physical Design

4 SQL Overview Structured Query Language Structured Query Language The standard for relational database management systems (RDBMS) The standard for relational database management systems (RDBMS) SQL-92 (Also call SQL-2) and SQL-99 Standards – Purpose: SQL-92 (Also call SQL-2) and SQL-99 Standards – Purpose: Specify syntax/semantics for data definition and manipulation Specify syntax/semantics for data definition and manipulation Define data structures Define data structures Enable portability Enable portability Specify minimal (level 1) and complete (level 2) standards Specify minimal (level 1) and complete (level 2) standards Allow for later growth/enhancement to standard Allow for later growth/enhancement to standard

5 Benefits of a Standardized Relational Language Reduced training costs Reduced training costs Productivity Productivity Application portability Application portability Application longevity Application longevity Reduced dependence on a single vendor Reduced dependence on a single vendor Cross-system communication Cross-system communication

6 SQL Environment Catalog Catalog A set of schemas that constitute the description of a database A set of schemas that constitute the description of a database Schema Schema The structure that contains descriptions of objects created by a user (base tables, views, constraints) The structure that contains descriptions of objects created by a user (base tables, views, constraints) Data Definition Language (DDL) Data Definition Language (DDL) Commands that define a database, including creating, altering, and dropping tables and establishing constraints Commands that define a database, including creating, altering, and dropping tables and establishing constraints Data Manipulation Language (DML) Data Manipulation Language (DML) Commands that maintain and query a database Commands that maintain and query a database Data Control Language (DCL) Data Control Language (DCL) Commands that control a database, including administering privileges and committing data Commands that control a database, including administering privileges and committing data

7 Figure 7-1: A simplified schematic of a typical SQL environment, as described by the SQL-92 standard

8 Some SQL Data types (from Oracle 9i) String types String types CHAR(n) – fixed-length character data, n characters long Maximum length = 2000 bytes CHAR(n) – fixed-length character data, n characters long Maximum length = 2000 bytes VARCHAR2(n) – variable length character data, maximum 4000 bytes VARCHAR2(n) – variable length character data, maximum 4000 bytes LONG – variable-length character data, up to 4GB. Maximum 1 per table LONG – variable-length character data, up to 4GB. Maximum 1 per table Numeric types Numeric types NUMBER(p,q) – general purpose numeric data type NUMBER(p,q) – general purpose numeric data type INTEGER(p) – signed integer, p digits wide INTEGER(p) – signed integer, p digits wide FLOAT(p) – floating point in scientific notation with p binary digits precision FLOAT(p) – floating point in scientific notation with p binary digits precision Date/time type Date/time type DATE – fixed-length date/time in dd-mm-yy form DATE – fixed-length date/time in dd-mm-yy form

9 Figure 7-4: DDL, DML, DCL, and the database development process

10 SQL Database Definition Data Definition Language (DDL) Data Definition Language (DDL) Major CREATE statements: Major CREATE statements: CREATE SCHEMA – defines a portion of the database owned by a particular user CREATE SCHEMA – defines a portion of the database owned by a particular user CREATE TABLE – defines a table and its columns CREATE TABLE – defines a table and its columns CREATE VIEW – defines a logical table from one or more views CREATE VIEW – defines a logical table from one or more views Other CREATE statements: CHARACTER SET, COLLATION, TRANSLATION, ASSERTION, DOMAIN Other CREATE statements: CHARACTER SET, COLLATION, TRANSLATION, ASSERTION, DOMAIN

11 Table Creation Figure 7-5: General syntax for CREATE TABLE Steps in table creation: 1.Identify data types for attributes 2.Identify columns that can and cannot be null 3.Identify columns that must be unique (candidate keys) 4.Identify primary key- foreign key mates 5.Determine default values 6.Identify constraints on columns (domain specifications) 7.Create the table and associated indexes

12 The following slides create tables for this enterprise data model

13 Figure 7-6: SQL database definition commands for Pine Valley Furniture Overall table definitions

14 Defining attributes and their data types

15 Non-nullable specification Identifying primary key Primary keys can never have NULL values

16 Non-nullable specifications Primary key Some primary keys are composite – composed of multiple attributes

17 Default value Domain constraint Controlling the values in attributes

18 Primary key of parent table Identifying foreign keys and establishing relationships Foreign key of dependent table