1 / 9

Programming and SQL

Programming and SQL. Edel Sherratt. Motivation 1: Integrity Checking. Sometimes primary keys and foreign keys are not enough For example, they do not enforce mandatory participation on the many side of a one-to-many relationship So additional facilities are needed.

redford
Download Presentation

Programming and SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming and SQL Edel Sherratt

  2. Motivation 1: Integrity Checking • Sometimes primary keys and foreign keys are not enough • For example, they do not enforce mandatory participation on the many side of a one-to-many relationship • So additional facilities are needed

  3. Integrity Checking (from before)

  4. Motivation 2: Impedance mismatch • Mismatches between application programming language and SQL • SQL handles rows of data; a language like C or Java handles only one row at a time • SQL is declarative; C is procedural; Java is object oriented and imperative • There are usually mismatches between SQL and programming language data types

  5. SQL/PSM (Persistent Stored Modules) • Extensions to SQL • part of the SQL standard: SQL/PSM (ANSI/ISO/IEC 9075-4:1999) • But not fully implemented • Partly because proprietary implementations were developed before the standard

  6. SQL Programming Languages • DBMS-specific SQL procedural languages: • Oracle: PL/SQL • Sybase and Microsoft: T-SQL • Informix: SPL • PostgreSQL: PL/pgSQL

  7. Oracle Manual, v10 Using Oracle PL/SQL to improve performance

  8. SQL Programming Language Constructs • Functions and procedures • IF, WHILE • Assignment: both the usual kind and also assignment that results from SQL queries • Cursors: allow the rows of a query to be handled one at a time • Exception handling • Triggers

  9. To find out more • The PostgreSQL reference manual: http://www.postgresql.org/docs/9.1/static/index.htmlSee section V, Server Programming • Oracle PL/SQL: http://www.oracle.com/technetwork/database/features/plsql/index.html • Connolly and Begg, Database Systems, fifth ed., Chapter 8: Advanced SQL

More Related