ISD3 Lecture 4 - Databases, SQL and MySQL. dept deptno dname location emp empno ename not null job not null hiredate sal comm manager The EMP DEPT database.

Slides:



Advertisements
Similar presentations
BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
Advertisements

Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
9-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language A DML statement is executed when you: – Add new rows to a table.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
Bogdan Shishedjiev SQL1 SQL Reminder of SQL. Bogdan Shishedjiev SQL 2 Subsets of language Data definition language (DDL) –Domain definition –Schema definition.
SQL Components DML DDL DAL. Overview u Getting the records onto the disk - mapping u Managing disk space u SQL Modes u Ceating database.
ISD3 Chris Wallace Next 6 Weeks Extended Relational Model Object Orientation Matching systems 3 tier architecture Technology.
Copyright  Oracle Corporation, All rights reserved. 9 Manipulating Data: INSERT, UPDATE, DELETE.
SQL's Data Definition Language (DDL) – View, Sequence, Index.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
ORACLE SQL. Overview Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction.
o At the end of this lesson, you will be able to:  Describe the life-cycle development phases  Discuss the theoretical and physical aspects of a relational.
Copyright  Oracle Corporation, All rights reserved. I Introduction.
Database Technical Session By: Prof. Adarsh Patel.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
4-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language (DML)
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
SQL (DDL & DML Commands)
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Introduction to Relational Databases &
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.
1 Information Retrieval and Use (IRU) CE An Introduction To SQL Part 1.
SQL FUNDAMENTALS SQL ( Structured Query Language )
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Session 2: SQL (A): Parts 1 and 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
SQL SeQueL -Structured Query Language SQL SQL better support for Algebraic operations SQL Post-Relational row and column types,
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Copyright  Oracle Corporation, All rights reserved. 4 Introduction.
More SQL Data Management Topics zIntegrity Constraints zOuter Join zUnion.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
Manipulating Data. Objectives After completing this lesson, you should be able to do the following: Describe each DML statement Insert rows into a table.
9 Manipulating Data. 9-2 Objectives At the end of this lesson, you should be able to: Describe each DML statement Insert rows into a table Update rows.
Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Subqueries These slides are licensed under.
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
Lecture 10 Creating and Maintaining Geographic Databases Longley et al., Ch. 10, through section 10.4.
9-1 © Prentice Hall, 2007 Topic 9: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relational State Assertions These slides.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Copyright س Oracle Corporation, All rights reserved. 12 Creating Views.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
Databases Introduction - concepts. Concepts of Relational Databases.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -
uses of DB systems DB environment DB structure Codd’s rules current common RDBMs implementations.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
SQL Statements SELECT INSERTUPDATEDELETECREATEALTERDROPRENAMETRUNCATECOMMITROLLBACKSAVEPOINTGRANTREVOKE Data Retrieval Language (DRL) Data Retrieval Language.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Oracle SQL.
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
Interacting with the Oracle Server
What Is a View? EMPNO ENAME JOB EMP Table EMPVU10 View
(SQL) Manipulating Data
Database systems Lecture 3 – SQL + CRUD
Triggers in SQL’99 CS561.
Database Programming Using Oracle 11g
Presentation transcript:

ISD3 Lecture 4 - Databases, SQL and MySQL

dept deptno dname location emp empno ename not null job not null hiredate sal comm manager The EMP DEPT database

A managerial view Which Database to use for my application? –Functional capabilities – what parts of the SQL standard are supported –Advanced functionality – Object-relational, OLAP, GIS.. –Limitations – on the number of tables, size of tables, and size of fields –Cost – initial and ongoing –Ecology – availability of tools, staff, training, –Performance - for different tasks –Security –Backup and recovery

SQL Standard conformance SQL1 – SQL-89 – Access default standard SQL2 – SQL-92 - join syntax - most common level to be supported – MYSQL but limited SQL3 – SQL-99 - object relational features – Oracle 9i, Postgres SQL4 – SQL-03 - more advances- Standard about to be released

Basic SQL Basic DDL CREATE TABLE, ALTER TABLE, DROP TABLE with basic column types – number, character, date Basic DML SELECT … calculated fields, FROM multiple tables, WHERE condition, basic functions, basic aggregation (GROUP, HAVING) INSERT INTO T VALUES(…) UPDATE T SET X=6 WHERE X=5, DELETE FROM T WHERE X=5 REPLACE

Join and Sub-select SELECT * FROM emp,dept WHERE dept.deptno=emp.deptno SELECT * FROM FROM emp INNER JOIN dept ON dept.deptno=emp.deptno SELECT * FROM emp INNER JOIN dept USING deptno SELECT * FROM emp NATURAL JOIN dept SELECT dname FROM dept WHERE deptno in (SELECT deptno FROM EMP WHERE job=’analyst’) SELECT DISTINCT dname FROM emp NATURAL JOIN dept WHERE job=’analyst’

Extended Data types Time and Date Currency Unicode character strings BLOBs for images, sound Points and lines for geometry (GIS)

Data integrity Primary key CONSTRAINT emp_pk PRIMARY KEY (empno) Not Null Ename NOT NULL Foreign Key CONSTRAINT emp-deptfk FOREIGN KEY (deptno) REFERENCES dept –NO ACTION, CASCADE, SET NULL, SET DEFAULT Field Validation CONSTRAINT emp_sal CHECK (sal <6000) CONSTRAINT emp_job CHECK (job IN (‘analyst,’salesman’, ‘manager’, ‘president’, ‘clerk’))

Views CREATE VIEW empvw1 as SELECT empno, ename, job, hiredate, dname, location FROM emp NATURAL JOIN dept WHERE job <> ‘PRESIDENT’ SELECT * FROM empvw1 WHERE job=’Clerk UPDATE empvw1 set job=’manager’ where empno = 7566 UPDATE empvw1 set dname=’Accounts’ where empno = 7566

Transactions ATOMIC and ISOLATED UPDATE EMP SET sal=sal*1.1 WHERE job <>’Clerk’ UPDATE EMP SET sal=800 WHERE empno=7866 SELECT sum(sal) from emp;

Recovery and Backup

Stored Procedures E.g listing an employee’s superiors. Where to do processing: –On the database server Stored procedures written in say PL/SQL Reduces traffic between the client and the server Binds you to a specific DBMS –In the application Repeating code in different scripts

Triggers Actions performed when database changes On update to emp, if new sal > old sal, update counts set no=no+1 where type=’salincrease’

Non-first normal tables CHILD TABLE –empchild(empno, childname) –SELECT childname –FROM emp NATURAL JOIN empchild WHERE empno = 7566 –SLOW Non-atomic field e.g. –Set type in MySQL –E.g service days of the week

MySQL GNU General Public License (GPL) Developed by David Axmark, Allan Larsson and Michael "Monty" Widenius Supported by MySQL AB – a Swedish company - both open and commercial licences MySQL limitations –No subselect (included in 4.1) –No Foreign key handling –No check –Transaction control only in one file type –No stored procedures –No user defined types –Only aggregate type is SET –Table replication for retrieval performance

User defined types Object – Relational database e.g. currency with currency code and value User defined data types – to treat the combined colums as a single unit Functions (stored procedures) to process the data type -