Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.

Slides:



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

Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
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)
CSC 2720 Building Web Applications Database and SQL.
1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Structured Query Language(SQL) XU Yinqing SEEM PHD YEAR 3.
Database Lecture # 1 By Ubaid Ullah.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
ASP.NET Programming with C# and SQL Server First Edition
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Introduction to SQL Steve Perry
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Sundara Ram Matta Apr 01 st, Sundara Ram Matta Apr 01 st, 2015
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 What is database 2? What is normalization? What is SQL? What is transaction?
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
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.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
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. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Fox MIS Spring 2011 Database Week 5 SQL basics SELECT, INSERT, UPDATE, DELETE.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
CHAPTER 9 SQL อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
SQL Basics Review Reviewing what we’ve learned so far…….
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.
SQL Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Fundamentals of DBMS Notes-1.
Web Systems & Technologies
Module T03d Software Engineering
From: SQL From:
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Introduction to Structured Query Language(SQL)
Introduction To Structured Query Language (SQL)
SQL Queries Chapter No 3.
Introduction To Structured Query Language (SQL)
Structured Query Language
Presentation transcript:

Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total Sessional Terminal Exam Final Evaluation By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 1 Remember:

Chapter NoChapter NamePage No 1. Database Foundation OR An Overview of Database Management System (DBMS) 2.Semantic Modeling OR Entity Relationship Model (ERD) 3.An introduction to Relational Database 4.Normalization 5.Relational Algebra 6.An Introduction to Structured Query Language (SQL) By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 2 Course Contents

COURSE INSTRUCTOR: ILTAF MEHDI By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 3 Chapter No: 06

1. SQL Introduction SQL Intro 2. SQL Syntax SQL Syntax 3. SQL Select SQL Select 4. SQL Distinct SQL Distinct 5. SQL Where SQL Where 6. SQL And & Or SQL And & Or 7. SQL Order By SQL Order By 8. SQL Insert SQL Insert 9. SQL Update SQL Update 10. SQL Delete SQL Delete 1. SQL Introduction SQL Intro 2. SQL Syntax SQL Syntax 3. SQL Select SQL Select 4. SQL Distinct SQL Distinct 5. SQL Where SQL Where 6. SQL And & Or SQL And & Or 7. SQL Order By SQL Order By 8. SQL Insert SQL Insert 9. SQL Update SQL Update 10. SQL Delete SQL Delete By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 4

What is SQL?  SQL is a standard language for accessing and manipulating databases.  SQL stands for Structured Query Language  SQL lets you access and manipulate databases  SQL is an ANSI (American National Standards Institute) standard By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 5

6

7

8

Using SQL in Your Web Site  To build a web site that shows some data from a database, you will need the following: 1. An RDBMS database program (i.e. MS Access, SQL Server, MySQL) 2. A server-side scripting language, like PHP or ASP, ASP.NET 3. SQL 4. HTML / CSS / java Script Using SQL in Your Web Site  To build a web site that shows some data from a database, you will need the following: 1. An RDBMS database program (i.e. MS Access, SQL Server, MySQL) 2. A server-side scripting language, like PHP or ASP, ASP.NET 3. SQL 4. HTML / CSS / java Script By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 9

RDBMS  RDBMS stands for Relational Database Management System.  RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.  The data in RDBMS is stored in database objects called tables.  A table is a collections of related data entries and it consists of columns and rows. RDBMS  RDBMS stands for Relational Database Management System.  RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.  The data in RDBMS is stored in database objects called tables.  A table is a collections of related data entries and it consists of columns and rows. By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 10

By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 11

Semicolon after SQL Statements?  Some database systems require a semicolon at the end of each SQL statement.  Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.  We are using MS Access and SQL Server 2000 and we do not have to put a semicolon after each SQL statement, but some database programs force you to use it. By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 12

SQL DML and DDL  SQL can be divided into two parts: 1. The Data Manipulation Language (DML) and 2. the Data Definition Language (DDL). The query and update commands form the DML part of SQL:  SELECT - extracts data from a database  UPDATE - updates data in a database  DELETE - deletes data from a database  INSERT INTO - inserts new data into a database SQL DML and DDL  SQL can be divided into two parts: 1. The Data Manipulation Language (DML) and 2. the Data Definition Language (DDL). The query and update commands form the DML part of SQL:  SELECT - extracts data from a database  UPDATE - updates data in a database  DELETE - deletes data from a database  INSERT INTO - inserts new data into a database By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 13

 The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:  CREATE DATABASE - creates a new database  ALTER DATABASE - modifies a database  CREATE TABLE - creates a new table  ALTER TABLE - modifies a table  DROP TABLE - deletes a table  CREATE INDEX - creates an index (search key)  DROP INDEX - deletes an index  The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:  CREATE DATABASE - creates a new database  ALTER DATABASE - modifies a database  CREATE TABLE - creates a new table  ALTER TABLE - modifies a table  DROP TABLE - deletes a table  CREATE INDEX - creates an index (search key)  DROP INDEX - deletes an index By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 14

By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 15

By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 16

By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 17

By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 18

 SELECT * FROM Student WHERE FirstName=‘Ajmal’ OR FirstName=‘Hamid’ Combining AND & OR  You can also combine AND and OR (use parenthesis to form complex expressions).  Now we want to select only the Student with the last name equal to “Ullah" AND the first name equal to “Ajmal" OR to “Hamid": We use the following SELECT statement:  SELECT * FROM Student WHERE LastName=‘Ullah' AND (FirstName=‘Ajmal’ OR FirstName=‘Hamid')  SELECT * FROM Student WHERE FirstName=‘Ajmal’ OR FirstName=‘Hamid’ Combining AND & OR  You can also combine AND and OR (use parenthesis to form complex expressions).  Now we want to select only the Student with the last name equal to “Ullah" AND the first name equal to “Ajmal" OR to “Hamid": We use the following SELECT statement:  SELECT * FROM Student WHERE LastName=‘Ullah' AND (FirstName=‘Ajmal’ OR FirstName=‘Hamid') By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 19

 The ORDER BY keyword is used to sort the result-set by a specified column.  The ORDER BY keyword sort the records in ascending order by default.  If you want to sort the records in a descending order, you can use the DESC keyword. SQL ORDER BY Syntax  SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 20

 The INSERT INTO statement is used to insert a new row in a table. SQL INSERT INTO Syntax  It is possible to write the INSERT INTO statement in two forms. The first form doesn't specify the column names where the data will be inserted, only their values:  INSERT INTO table_name VALUES (value1, value2, value3,...) The second form specifies both the column names and the values to be inserted:  INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...) By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 21

Insert Data Only in Specified Columns  It is also possible to only add data in specific columns. The following SQL statement will add a new row, but only add data in the "P_Id", "LastName" and the "FirstName" columns:  INSERT INTO Student (P_Id, LastName, FirstName) VALUES (5, ‘Shahid’, ‘Afridi’) By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 22

 The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax  UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value  Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated! By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 23

 The DELETE statement is used to delete rows in a table. SQL DELETE Syntax  DELETE FROM table_name WHERE some_column=some_value Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted! By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 24

 The PRIMARY KEY constraint uniquely identifies each record in a database table.  Primary Keys must contain unique values.  A primary key column cannot contain NULL values.  Each table should have a primary key, and each table can have only ONE primary key. By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 25

 The following SQL creates a PRIMARY KEY on the "P_Id" column when the "Persons" table is created: SQL Server / Oracle / MS Access:  CREATE TABLE Student ( P_Id int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) ) By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 26

 To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY KEY constraint on multiple columns, use the following SQL syntax for :  MySQL / SQL Server / Oracle / MS Access: CREATE TABLE Students ( st_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), CONSTRAINT pk_PersonID PRIMARY KEY (st_Id, LastName) ) By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 27

 To drop a PRIMARY KEY constraint, use the following SQL: MySQL:  ALTER TABLE Persons DROP PRIMARY KEY SQL Server / Oracle / MS Access:  ALTER TABLE Persons DROP CONSTRAINT pk_PersonID By ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) SQL 28