SQL Structured Query Language. Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).

Slides:



Advertisements
Similar presentations
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Advertisements

1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Design process Identify entities and attributes –What do you want to know? –Note that the question of whether something is an attribute or an entity may.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Systems Lecture 5 Natasha Alechina
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
IE 423 – Design of Decision Support Systems Database development – Relationships and Queries Introduction to SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
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.
SQL Data Definition (CB Chapter 6) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley.
Database Technical Session By: Prof. Adarsh Patel.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
HSCI 709 SQL Data Definition Language. SQL Standard SQL-92 was developed by the INCITS Technical Committee H2 on Databases. SQL-92 was designed to be.
Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
Quick review of SQL And conversion to Oracle SQL.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
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.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
Oracle 11g: SQL Chapter 4 Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
SQL introduction 2013.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E) 1.
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Chapter 3: Relational Databases
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
Copyright © Curt Hill SQL The Data Manipulation Language.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
Fundamental of Database Systems
CS SQL.
SQL: Schema Definition and Constraints Chapter 6 week 6
Insert, Update and the rest…
STRUCTURED QUERY LANGUAGE
Structured Query Language (Data definition Language)
The Relational Model Relational Data Model
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
مقدمة في قواعد البيانات
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Instructor: Samia arshad
DATABASE Purpose of database
SQL (Structured Query Language)
Presentation transcript:

SQL Structured Query Language

Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).  To introduce SQL Data Manipulation Language (DML).

Implementation of a Physical Design Database Design Language  Course (courseCode, title, cost) Entity Course is converted to the following physical design.  courseCode and title are set to text and indexed appropriately, cost is set to Currency tblCourse Field Name Data Type SizeFormat Key Type IndexRequired courseCodeText8 Primary Key Yes(no duplicates) Yes titleText25Yes costCurrencyCurrencyNo

SQL (Data Definition Language - DDL Database Definition Commands  CREATE DATABASE  DROP DATABASE  SHOW DATABASES  CREATE TABLE  ALTER TABLE

SQL Create Table CREATE TABLE CREATE TABLE (,, ….. ….. );

SQL Create Table Each column definition has 3 components.  this the name of the attribute identified in the design.  specified for the attribute in the Physical design. The data types available for use will depend on those appropriate for the software with which the database is to be implemented.  such as specification of Primary Keys, Indexes and Nulls.

SQL Create Table CREATE TABLE tblCourse (courseCode VARCHAR(8) PRIMARY KEY, (courseCode VARCHAR(8) PRIMARY KEY, title VARCHAR(25) NOT NULL, title VARCHAR(25) NOT NULL, cost CURRENCY cost CURRENCY ); );

Implementation of a Physical Design StudentCourse(studentID, courseCode) FK studentID → tblStudent Update Cascade, Delete Restrict FK studentID → tblStudent Update Cascade, Delete Restrict FK courseCode → tblcourse Update Cascade, Delete Restrict FK courseCode → tblcourse Update Cascade, Delete Restrict Entity StudentCourse is converted to the following physical design.  This entity has a Compound Key, all elements of the compound key are identified.  Both attributes are foreign keys. This means that their data type and size must exactly match the data type and the field to which they will be linking to enforce the relationship between the tables.  Compound keys are always indexed yes (duplicates OK) Field NameData TypeSizeFormatKey TypeIndexRequired studentIDText8Compound KeyYes(duplicates OK)Yes courseCodeText8Compound KeyYes(duplicates OK)Yes

SQL Create Table CREATE TABLE tblStudentCourse (studentID VARCHAR(8), (studentID VARCHAR(8), courseCode VARCHAR(8), courseCode VARCHAR(8), PRIMARY KEY (studentID, courseCode) PRIMARY KEY (studentID, courseCode) ); );

Enforcing Foreign Keys ALTER TABLE tblStudentCourse ADD CONSTRAINT courseStudentCourseFK FOREIGN KEY (courseCode) REFERENCES tblcourse (courseCode);

Adding data using SQL INSERT INTO targetTable (Field1, Field2, …) VALUES (Value1, Value2, …)

Adding data using SQL INSERT INTO targetTable (Field1, Field2, …)  VALUES (Value1, Value2, …)

Adding data using SQL Method 1 INSERT INTO tblProduct (prodID, prodDesc, cost) VALUES (‘ssaay1’, ‘Nut’, 34.50)

Adding data using SQL Method 2 INSERT INTO tblProduct VALUES (‘ssaay2’, ‘screw’, 4.50);

INSERT INTO tblSupplier (suppName, suppAdd1, suppAdd2, suppPostCode) VALUES (‘Johnsons’, ‘34 Meols Parade’, ‘Meols’, ‘CH47 6AY’) Adding data using SQL

Summary  Implementation of a Physical Design  Use of SQL Create Table  Use of SQL Alter Table to enforce foreign keys.  Student individual work  Rest of chapter 6

NEXT WEEK Chapter 7 More Advanced SQL Next Week is an in class-Test- Logical Design Test