ICS 434 Advanced Database Systems Dr. Abdallah Al-Sukairi Second Semester 2003 - 2004 (032) King Fahd University of Petroleum & Minerals.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

ICS 434 Advanced Database Systems
Database System Concepts and Architecture
Technical Architectures
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
Fundamentals, Design, and Implementation, 9/e Chapter 12 ODBC, OLE DB, ADO, and ASP.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
Client-server database systems and ODBC l Client-server architecture and components l More on reliability and security l ODBC standard.
The University of Akron Dept of Business Technology Computer Information Systems Database Management Approaches 2440: 180 Database Concepts Instructor:
Oracle SQL*plus John Ortiz. Lecture 10SQL: Overview2 Overview  SQL: Structured Query Language, pronounced S. Q. L. or sequel.  A standard language for.
14 Chapter 14 Databases and The Internet Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Overview of Database Languages and Architectures.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Query Processing in Mobile Databases
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
10/26/00Splitting Access Databases...1 Preparing for Access 2000 Windows 2000/Office 2000 Roll-out.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Database Lecture # 1 By Ubaid Ullah.
Data Administration & Database Administration
ICS 434 Advanced Database Systems Dr. Abdallah Al-Sukairi Second Semester (032) King Fahd University of Petroleum & Minerals.
The McGraw-Hill Companies, Inc Information Technology & Management Thompson Cats-Baril Chapter 3 Content Management.
Announcements Read JDBC Project Step 5, due Monday.
Lecture On Database Analysis and Design By- Jesmin Akhter Lecturer, IIT, Jahangirnagar University.
CSC271 Database Systems Lecture # 4.
Database System Concepts and Architecture Lecture # 2 21 June 2012 National University of Computer and Emerging Sciences.
Introduction: Databases and Database Users
Fundamentals of Database Chapter 7 Database Technologies.
M1G Introduction to Database Development 6. Building Applications.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
CS480 Computer Science Seminar Introduction to Microsoft Solutions Framework (MSF)
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden.
“INTRODUCTION TO DATABASE AND SQL”. Outlines 2  Introduction To Database  Database Concepts  Database Properties  What is Database Management System.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
The Client/Server Database Environment Ployphan Sornsuwit KPRU Ref.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
Lesson Overview 3.1 Components of the DBMS 3.1 Components of the DBMS 3.2 Components of The Database Application 3.2 Components of The Database Application.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
ICS 321 Fall 2010 SQL in a Server Environment (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 11/1/20101Lipyeow.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
Management Information Systems, 4 th Edition 1 Chapter 8 Data and Knowledge Management.
ADABAS Versus DB2 An Evaluative Study by Butler Bloor Group.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
14 1 Chapter 14 Web Database Development Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
1 Lesson Overview 2.1 Basic Concept and Vocabulary 2.1 Basic Concept and Vocabulary 2.2 Database Approach: DBMS 2.2 Database Approach: DBMS 2.3 Characteristic.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Basics of JDBC Session 14.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Chapter 2 Database Environment.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
IT420: Database Management and Organization Triggers and Stored Procedures 24 February 2006 Adina Crăiniceanu
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
SQL Triggers, Functions & Stored Procedures Programming Operations.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
E-commerce Architecture Ayşe Başar Bener. Client Server Architecture E-commerce is based on client/ server architecture –Client processes requesting service.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
“Introduction To Database and SQL”
DBMS & TPS Barbara Russell MBA 624.
PGT(CS) ,KV JHAGRAKHAND
The Client/Server Database Environment
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Chapter 7 Using SQL in Applications
Chapter 8 Advanced SQL.
Presentation transcript:

ICS 434 Advanced Database Systems Dr. Abdallah Al-Sukairi Second Semester (032) King Fahd University of Petroleum & Minerals Information & Computer Science Department

Outline 1. The Relational Data Model: Version 2 2. Advanced Data Modeling 3. Client-Server Architecture 4. Client-Server Databases & Tools 5. Databases on the Web 6. The System Catalog 7. Query Processing and Optimization 8. Transaction Processing 9. Concurrency Control 10. Recovery 11. Administration & Security 12. Distributed Databases 13. Database Replication 14. Object-Oriented Databases 15. Data Warehousing and Data Mining 16. Other Emerging Database Technologies

4. Client-Server Databases and Tools

Client-Server Database A multiuser relational database management system Transaction oriented processing Security through accounts, permissions and views Rules and triggers to enforce integrity Examples: Oracle, DB2, SQLServer, Sybase, MySQL

Oracle - Oracle corporation Ideal for large scale grid and cluster computing Currently pushing toward small business, single computer servers Many Enterprise applications are available or included  Finance management  Human Resource Management  Marketing  Product lifecycle management ... 43% market share

DB2 - IBM Flexible to install on a wide variety of systems Focuses on the integration of other DBMS Data can be distributed Has many application packages, similar to Oracle 24% Market Share

SQLServer - Microsoft Targets small business Easy to install Low cost of ownership Excellent Support Notoriously insecure  Susceptible to virus and worm attacks  New patches released monthly 17% Market Share

Adaptive Server Enterprise (ASE) - Sybase Low resource requirements Fast and reliable Lower cost of ownership compared to Oracle or DB2 Popular on Wall Street due to its high transaction rate 2% Market Share

MySQL - MySQL AB (Possible HW) Open source DBMS Supported by a for-profit company Well known compared to other open source solutions. Offers free GPL version and a licensed version that includes vendor support Less popular and less scalable than Oracle, DB2 or ASE

Criteria for Selecting SQL Servers Cost Openness Vendor support and position Third party support Scalability Extra features

How Front-end Tools Work User creates query Database server checks user’s security rights Front-end formats query and sends it to the DBMS Database server processes the query and returns the results to the front-end Front-end receives the response and formats it for the user User view and/or manipulate the data Client System Server System

Front-end Tools Categories Adds on to existing products  Require more system resources Application development tools  OLTP (on-line transaction processing)  Programming Query/reporting tools  Nonprogramming Data integration and analysis tools  EIS/DS (executive information/decision support)

Few Tools Application development tools  Developer Oracle  PowerBuilderSybase  Visual Studio.netMicrosoft Data integration and analysis tools  Forest & Trees Query/reporting tools

Evaluating Front-end Tools Easy coding  Scripting language  4GLs  Object-oriented features  Call 3GL modules Multiprogrammers features Local prototyping opportunity  Off-line development  Rapid application development

... Evaluating Front-end Tools Broad back-end support Adherence to existing standards  ODBC Accessibility of server-specific features Cross-platform development Openness Integration with existing tools Features, not price

Database Languages Integrated with a programming language  Access High-Level Database Languages  SQL  Declarative  Set-at-a-time  Interactive  Embedded in a host language User-friendly Query Languages  QBE 4GL tools

SQL Structured Query Language  Originally was called SEQUEL The standard language for relational DBMS Developed by IBM in 1972 SQL = DDL + DML + DCL

SQL Standards ANSI standardized SQL in 1986 and ISO standardized it in 1987 US government’s FIPS adopted ANSI/ISO standard Revised standard called SQL89 or SQL1 was published in 1989 Due to conflicting interests from Vendors ANSI committee revised its previous work with SQL92 standard in 1992 called SQL2 SQL 92 was approximately 6 times the length of its predecessor In 1999 ANSI/ISO released SQL 1999 called SQL3 SQL 1999 includes object relational database concepts, call level interfaces, and integrity management Recently SQL 2003 was released which includes collection data types, cleaner object/relational specification, and references to new parts such as XML

How Standard is SQL? Most DBMSs meet SQL89, and many meet SQL92  So SQL written for one DBMS will generally work in another DBMS with little or no changes But each implementation of SQL is different  ANSI standard doesn’t define everything  Vendors opt to not comply with entire standard  Vendors wish to include extra features/faster performance

ANSI SQL vs. DBMS-Specific SQL Using ANSI SQL Maintain as much portability of code as possible Maintain as much portability of your skill set as possible Trade off performance and functionality Using DBMS-Specific SQL Code Gain added functionality not defined in SQL standard Gain extra performance of functions optimized for specific DBMS Trade off portability

Importance of SQL Today & Tomorrow Relational databases are still king and SQL is the language of choice  XML and OOP are new non-relational standards  SQL is being enhanced to work with XML  SQL Server 2000  Oracle 9i Release 2 Database administrators and Back-end developers  Database creation and maintenance Front-end application programmers  SQL embedded in programming language for data connectivity  Client-server programming  Web programming Managers  SQL concepts/syntax used for interacting with organizational databases

Control-of-Flow Language Batches  go IF... ELSE  IF Boolean_expression sql_statement ELSE sql_statement BEGIN... END  BEGIN statement_block END WHILE Boolean_expression sql_statement

What are Stored Procedures An SQL program stored inside the database Can pass parameters in and out Can have internal variables, case structures, if-then- else structures, etc.

Advantages of Stored Procedures Callable Programming in Database Back-end  Call from Front-end to handle multi-table inserts or deletes or other complicated procedures  Makes Front-end more simple Added Security  Sprocs can have permissions that the sproc users do not Performance  First time a sproc is run it is optimized and a query plan compiled and saved  The next time it is run, that query plan is used  Saves the optimization and compile times

SQL Server Stored Procedure Creation Syntax create procedure procname [paramertes] as sql_statment execute procname

A Simple First Sproc Create Proc Integer As Begin Tran Delete From Tracks Where Delete From Title Where Commit Tran Sproc specifies local variable. Variables declared above AS are input or output. Variables declared below AS are internal variables. SQL with transaction

Triggers Triggers are pieces of code that run when certain table events occur  Insert  Delete  Update Triggers are attached to a specific table and to a specific event for that table Triggers cannot be called like stored procedures – they run automatically They don’t have separate privileges Triggers are used to maintain integrity

Triggers Work with Temporary Tables Two special tables that exist only while the trigger is running  On Insert  Insert table – exact copy of the row just inserted  On Delete  Delete table – exact copy of the row just deleted  On Update  Insert table – exact copy of the updated row  Delete table – exact copy of the row before the changes Makes triggers hard to write and debug  Insert and Delete exist only during the trigger  You can't look at them before or after the trigger has run  In theory, you could insert them into a test table

Trigger Creation Code Create Trigger triggername On tablename For Update | Insert | Delete As SQLcode

A Sample Trigger Create Trigger trig_Purchase On PurchaseDetail For Delete, Insert, Update As If exists (Select * from deleted where deleted.part is not null) Begin Update InventoryPart Set OnHand = OnHand - deleted.Qty From InventoryPart,deleted Where InventoryPart.Part = deleted.Part End if exists (select * from inserted where inserted.part is not null) Begin Update InventoryPart Set OnHand = OnHand + inserted.Qty From InventoryPart, inserted Where InventoryPart.Part = inserted.Part End Runs on Delete or Update Runs on Insert or Update Temp table is joined to real table to find record to update.

Issues with Triggers Nested Triggers  As Triggers fire and they update related tables  Thus they can trigger other triggers  Can’t get over 32 levels deep, but that shouldn’t be a problem Order of Firing Not Guaranteed  Multiple triggers can be written for the same event  Update one thing  Update something else  Don’t make one dependent on the other, because can’t control order  If need a particular order, use a stored procedure

… Issues with Triggers Triggers Can Cause Debugging Hassles  Can’t test without doing and update, insert, or delete  Can’t see info in inserted and deleted because temporary  Can use Print and Select statements to tell you status of variables in mid-firing  If you drop or change a table that a trigger uses won’t see problem until a user inserts, updates, or deletes Triggers Can Interfere With Referential Integrity  Could write trigger to do a cascade delete of child records when parent record deleted  Trigger would have to be tied to deletion of parent record  But FK constraint would not let parent be deleted in first place

Methods of Accessing a Database Ad-hoc access  Interactive SQL  4GL tools Programmatic access  Embedded SQL  Call Level Interface (CLI)

The challenge of Accessing Heterogeneous Databases Data resides on different  DBMS  Hardware platforms  Operating systems  Network systems We do not have to wait for fully distributed databases, client- server architecture can address the heterogeneous database access problem Front-end tools can access diverse databases Essential to enterprises with heterogeneous databases

Embedded SQL Host language Host variables Singleton SELECT Cursors SQL Communication Area (SQLCA) Precompiler Static SQL Dynamic SQL  EXECUTE IMMEDIATE  PREPARE, EXECUTE

Call Level Interface A program communicates with the DBMS through a set of function calls called the application program interface (API) The CLI approach is used in client-server architecture The code of the API is located on the client system The SQL API becomes just another library for the programmer to learn No need for a precompiler

Heterogeneous Database Access Issues Programming interface  Embedded SQL or CLI Interprocess communication mechanism  Named pipes, TCP/IP Network protocol  TCP/IP, NetBEUI, SPX/IPX System catalog SQL syntax and semantics

Heterogeneous Database Access Approaches Embedded SQL  The application should be precompiled with each back- end server it accesses  Source Code Compatibility  The source code must be recompiled for a new environment  Unacceptable solution to software vendors and corporates CLI  The ability to connect to various backends on a dynamic basis, by loading a new library  Binary Compatibility  Dynamic link libraries or ‘database drivers’

Open Database Connectivity (ODBC) Architecture for database connectivity Open Vendor-neutral ODBC interface defines the following  ODBC API (function calls)  SQL syntax based on X/Open and SQL CAE specs  Standard set of error codes  Standard way to connect to a DBMS  Standard representation for data types

ODBC Goals Provide universal database access Ease development burden Broadens application support for databases Built-in scalability for applications With ODBC the client application is not required to know  Location of the DBMS  Communication method  What vendor’s DBMS is being used

ODBC Architecture Application Driver Manager Driver Data Source Data Source Data Source ODBC Interface

CONNECT (db, user, pswd) SEND (“select * from...”) EXECUTE ( ) DISCONNECT () Client Application DBMS GETROW ( ) (101, ‘Dhahran’,...) GETROW ( ) (101, ‘Khobar’,...) Basic Application Steps

... Basic Application Steps Setting up a data source  SQLConnect, SQLDriverConnect Sending SQL to the data source  SQLPrepare, SQLExecute, SQLExecuteDirect  ODBC syntax  Pass through Retrieving results  SQLFetch  Cursors  SQLSetScrollOption, SQLSetPos  Static, dynamic, Key-set driven