SlideShare a Scribd company logo
UU - IT - UDBL                                                                   1




                   DATABASE DESIGN I - 1DL300
                                     Summer 2009


                    An introductury course on database systems
                              http://user.it.uu.se/~udbl/dbt-sommar09/
                 alt. http://www.it.uu.se/edu/course/homepage/dbastekn/st09/


                                        Kjell Orsborn
                                    Uppsala Database Laboratory
                     Department of Information Technology, Uppsala University,
                                         Uppsala, Sweden

Kjell Orsborn                                8/12/09
UU - IT - UDBL                                          2




                    Database API:s

                     (Elmasri/Navathe ch. 9)
                  (Padron-McCarthy/Risch ch 20)


                           Kjell Orsborn

                 Department of Information Technology
                 Uppsala University, Uppsala, Sweden




Kjell Orsborn                   8/12/09
UU - IT - UDBL                                                                 3




                  Database user interfaces

• Textual interfaces
       – Such as BSQL for Mimer
• Graphical interfaces
       – Most well-known is QBE (Query-By-Example) originally developed by
         IBM. MS Access uses a QBE variant.
• SQL application programming interfaces
       – Requires management of sessions, sql statements and some control of
         query optimization.
       – Call-level interfaces
       – Embedded SQL



Kjell Orsborn                         8/12/09
UU - IT - UDBL                                                                                4



                             Call-Level Interfaces
•    Vendor-specific call-level interfaces
       – An SQL API usually for one or several host languages like C, C++, Java, Fortan, COBOL etc.
       – Support to manage sessions, SQL statements and data conversions
•    SQL Call Level Interface (CLI),
       – The Call Level Interface (CLI) is a standard SQL API created by The Open Group. The API is
         defined for C and COBOL only. ISBN: 1-85912-081-4, X/Open Document Number: C451,
         1995.
•    SQL/CLI
       – Call-Level Interface (SQL/CLI) is an implementation-independent CLI to access SQL
         databases. SQL/CLI is an ISO standard ISO/IEC 9075-3:1995 Information technology --
         Database languages -- SQL -- Part 3: Call-Level Interface (SQL/CLI). The current SQL/CLI
         effort is adding support for SQL:1999.
•    ODBC
       – (Microsoft) Open Database Connectivity is a standard SQL API. ODBC is based on the Call
         Level Interface (CLI) specifications from SQL, X/Open (now part of The Open Group), and
         the ISO/IEC. ODBC was created by the SQL Access Group and released Sept, 1992.
•    JDBC - Java Database Connectivity
       – JDBC is an SQL API for Java (to be strictly correct, JDBC is not an acronym).

Kjell Orsborn                                 8/12/09
UU - IT - UDBL                                     5




                 The ODBC architecture
• ODBC API is independent of any one programming
  language, database system or operating system.




Kjell Orsborn             8/12/09
UU - IT - UDBL                                                 6




                 The JDBC architecture
• JDBC API is independent of (relational) DBMS and operating
  system




Kjell Orsborn               8/12/09
UU - IT - UDBL                                            7




      Alt. JDBC architecture (JDBC-ODBC bridge)
• Makes ODBC accessible from JDBC such that no special JDBC
  drivers are required.




Kjell Orsborn              8/12/09
UU - IT - UDBL                                                                          8




       Programming with SQL CLI interfaces
                                  JDBC example

•    The JDBC API (Application Program Interface) is a set of Java interfaces
     that allow database applications to:
       – open connections to a database,
       – execute SQL statements, and
       – process the results.
•    These include:
       – java.sql.DriverManager, which loads the specific drivers and supports creating
         new database connections
       – java.sql.Connection, which represents a connection to a specific database
       – java.sql.Statement, which allows the application to execute a SQL statement
       – java.sql.PreparedStatement, which represents a pre-compiled SQL statement
       – java.sql.ResultSet, controls access to rows resulting from executing a statement


Kjell Orsborn                              8/12/09
UU - IT - UDBL                                                                          9


                                          JDBC example
        import java.sql.*;

        public class JDBCExample {

           public static void main(String args[]) {

                 String url = "jdbc:mySubprotocol:myDataSource";
                 Connection con;
                 String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME > 10000";
                 Statement stmt;

                 try {
                     Class.forName("myDriver.ClassName");
                 }catch(java.lang.ClassNotFoundException e) {
                    System.err.print("ClassNotFoundException: ");
                    System.err.println(e.getMessage());
                 }

                 try {
                     con = DriverManager.getConnection(url, "myLogin", "myPassword");
                     stmt = con.createStatement();
                     ResultSet rs = stmt.executeQuery(query);
                     while (rs.next()) {
                        String s = rs.getString(”NAME");
                        System.out.println(s);
                     }
                     rs.close();
                     stmt.close();
                     con.close();
                 }catch(SQLException ex) {
                    System.err.print("SQLException: ");
                    System.err.println(ex.getMessage()); }}}

Kjell Orsborn                                 8/12/09
UU - IT - UDBL                                                                     10


                              JDBC example (prepared statement)
  import java.sql.*;

  public class JDBCExample {
     public static void main(String args[]) {

            String url = "jdbc:mySubprotocol:myDataSource";
            Connection con;
            String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME > ?;
            Int incomeLimit;
            PreparedStatement stmt;

            try {
                Class.forName("myDriver.ClassName");
            }catch(java.lang.ClassNotFoundException e) {
               System.err.print("ClassNotFoundException: ");
               System.err.println(e.getMessage());
            }
            try {
                con = DriverManager.getConnection(url, "myLogin", "myPassword");
            stmt = con.prepareStatement(query);
            while(....) {
               .... // Code to read lower income limit into incomeLimit
            stmt.setInt(1,incomeLimit);
            ResultSet rs = stmt.executeQuery();
                while (rs.next()) {
                   System.out.println(rs.getString(”NAME"));
                }}
                rs.close();
                stmt.close();
                con.close();
            }catch(SQLException ex) {
               System.err.print("SQLException: ");
               System.err.println(ex.getMessage()); }}}
Kjell Orsborn                                 8/12/09
UU - IT - UDBL                                                                11




                          Embedded SQL

•    Host language include embedded and specially marked SQL statements.
•    Embedded statements are extracted by preprocessor, translated and replaced
     by database calls, precompiled (prepared) and stored on server.
•    The preprocessed application is then compiled normally
•    Supports dynamic recompilation
•    Reduces optimization cost and can be somewhat simpler than CLI
     programming.




Kjell Orsborn                         8/12/09

More Related Content

PPT
Less07 storage
PPT
plsql Les05
PPT
Plsql les04
PPT
plsql les02
PPT
07 Using Oracle-Supported Package in Application Development
PPT
09 Managing Dependencies
PPT
plsql les03
PPT
Less08 users
Less07 storage
plsql Les05
Plsql les04
plsql les02
07 Using Oracle-Supported Package in Application Development
09 Managing Dependencies
plsql les03
Less08 users

What's hot (20)

PPT
06 Using More Package Concepts
PPT
plsql les10
PPT
05 Creating Stored Procedures
PDF
Jdbc Best Practices - Oracle/IOUG, Toronto, April 21, 2004
PPT
Less03 db dbca
PDF
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
PPT
11 Understanding and Influencing the PL/SQL Compilar
PPTX
PHP Oracle
PPT
02 Writing Executable Statments
PPT
Less01 architecture
PDF
Ebs dba con4696_pdf_4696_0001
PPT
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PPT
08 Dynamic SQL and Metadata
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPT
Less07 schema
PPT
Less14 br concepts
PDF
Improving the Performance of PL/SQL function calls from SQL
PDF
DOC
3963066 pl-sql-notes-only
06 Using More Package Concepts
plsql les10
05 Creating Stored Procedures
Jdbc Best Practices - Oracle/IOUG, Toronto, April 21, 2004
Less03 db dbca
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
11 Understanding and Influencing the PL/SQL Compilar
PHP Oracle
02 Writing Executable Statments
Less01 architecture
Ebs dba con4696_pdf_4696_0001
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
08 Dynamic SQL and Metadata
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Less07 schema
Less14 br concepts
Improving the Performance of PL/SQL function calls from SQL
3963066 pl-sql-notes-only
Ad

Similar to Database design i_-_1_dl300 (20)

PDF
Lecture17
PPT
Jdbc ppt
DOC
Java database programming with jdbc
PPTX
Java Database Connectivity by shreyash simu dbce.pptx
PDF
PDF
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
PDF
PDF
Presentation for java data base connectivity
PDF
Jdbc 1
PPT
Jdbc
PDF
Advance Java Practical file
PDF
10 J D B C
PPTX
PROGRAMMING IN JAVA -unit 5 -part I
PPT
Dbms & prog lang
PPT
Jdbc
PPT
PPTX
PDF
JDBC in Servlets
PPS
Java session16
Lecture17
Jdbc ppt
Java database programming with jdbc
Java Database Connectivity by shreyash simu dbce.pptx
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
Presentation for java data base connectivity
Jdbc 1
Jdbc
Advance Java Practical file
10 J D B C
PROGRAMMING IN JAVA -unit 5 -part I
Dbms & prog lang
Jdbc
JDBC in Servlets
Java session16
Ad

Recently uploaded (20)

PPTX
Special finishes, classification and types, explanation
PDF
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
PDF
Interior Structure and Construction A1 NGYANQI
PDF
Phone away, tabs closed: No multitasking
PPTX
Entrepreneur intro, origin, process, method
PDF
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
PPTX
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
PPTX
Wisp Textiles: Where Comfort Meets Everyday Style
PPT
UNIT I- Yarn, types, explanation, process
PDF
BRANDBOOK-Presidential Award Scheme-Kenya-2023
PDF
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
PPTX
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
PPTX
Tenders & Contracts Works _ Services Afzal.pptx
PDF
Urban Design Final Project-Context
PDF
Quality Control Management for RMG, Level- 4, Certificate
PDF
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
PDF
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
PPTX
DOC-20250430-WA0014._20250714_235747_0000.pptx
PDF
Trusted Executive Protection Services in Ontario — Discreet & Professional.pdf
PPTX
joggers park landscape assignment bandra
Special finishes, classification and types, explanation
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
Interior Structure and Construction A1 NGYANQI
Phone away, tabs closed: No multitasking
Entrepreneur intro, origin, process, method
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
Wisp Textiles: Where Comfort Meets Everyday Style
UNIT I- Yarn, types, explanation, process
BRANDBOOK-Presidential Award Scheme-Kenya-2023
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
Tenders & Contracts Works _ Services Afzal.pptx
Urban Design Final Project-Context
Quality Control Management for RMG, Level- 4, Certificate
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
DOC-20250430-WA0014._20250714_235747_0000.pptx
Trusted Executive Protection Services in Ontario — Discreet & Professional.pdf
joggers park landscape assignment bandra

Database design i_-_1_dl300

  • 1. UU - IT - UDBL 1 DATABASE DESIGN I - 1DL300 Summer 2009 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-sommar09/ alt. http://www.it.uu.se/edu/course/homepage/dbastekn/st09/ Kjell Orsborn Uppsala Database Laboratory Department of Information Technology, Uppsala University, Uppsala, Sweden Kjell Orsborn 8/12/09
  • 2. UU - IT - UDBL 2 Database API:s (Elmasri/Navathe ch. 9) (Padron-McCarthy/Risch ch 20) Kjell Orsborn Department of Information Technology Uppsala University, Uppsala, Sweden Kjell Orsborn 8/12/09
  • 3. UU - IT - UDBL 3 Database user interfaces • Textual interfaces – Such as BSQL for Mimer • Graphical interfaces – Most well-known is QBE (Query-By-Example) originally developed by IBM. MS Access uses a QBE variant. • SQL application programming interfaces – Requires management of sessions, sql statements and some control of query optimization. – Call-level interfaces – Embedded SQL Kjell Orsborn 8/12/09
  • 4. UU - IT - UDBL 4 Call-Level Interfaces • Vendor-specific call-level interfaces – An SQL API usually for one or several host languages like C, C++, Java, Fortan, COBOL etc. – Support to manage sessions, SQL statements and data conversions • SQL Call Level Interface (CLI), – The Call Level Interface (CLI) is a standard SQL API created by The Open Group. The API is defined for C and COBOL only. ISBN: 1-85912-081-4, X/Open Document Number: C451, 1995. • SQL/CLI – Call-Level Interface (SQL/CLI) is an implementation-independent CLI to access SQL databases. SQL/CLI is an ISO standard ISO/IEC 9075-3:1995 Information technology -- Database languages -- SQL -- Part 3: Call-Level Interface (SQL/CLI). The current SQL/CLI effort is adding support for SQL:1999. • ODBC – (Microsoft) Open Database Connectivity is a standard SQL API. ODBC is based on the Call Level Interface (CLI) specifications from SQL, X/Open (now part of The Open Group), and the ISO/IEC. ODBC was created by the SQL Access Group and released Sept, 1992. • JDBC - Java Database Connectivity – JDBC is an SQL API for Java (to be strictly correct, JDBC is not an acronym). Kjell Orsborn 8/12/09
  • 5. UU - IT - UDBL 5 The ODBC architecture • ODBC API is independent of any one programming language, database system or operating system. Kjell Orsborn 8/12/09
  • 6. UU - IT - UDBL 6 The JDBC architecture • JDBC API is independent of (relational) DBMS and operating system Kjell Orsborn 8/12/09
  • 7. UU - IT - UDBL 7 Alt. JDBC architecture (JDBC-ODBC bridge) • Makes ODBC accessible from JDBC such that no special JDBC drivers are required. Kjell Orsborn 8/12/09
  • 8. UU - IT - UDBL 8 Programming with SQL CLI interfaces JDBC example • The JDBC API (Application Program Interface) is a set of Java interfaces that allow database applications to: – open connections to a database, – execute SQL statements, and – process the results. • These include: – java.sql.DriverManager, which loads the specific drivers and supports creating new database connections – java.sql.Connection, which represents a connection to a specific database – java.sql.Statement, which allows the application to execute a SQL statement – java.sql.PreparedStatement, which represents a pre-compiled SQL statement – java.sql.ResultSet, controls access to rows resulting from executing a statement Kjell Orsborn 8/12/09
  • 9. UU - IT - UDBL 9 JDBC example import java.sql.*; public class JDBCExample {    public static void main(String args[]) { String url = "jdbc:mySubprotocol:myDataSource"; Connection con; String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME > 10000"; Statement stmt; try {     Class.forName("myDriver.ClassName"); }catch(java.lang.ClassNotFoundException e) {    System.err.print("ClassNotFoundException: ");    System.err.println(e.getMessage()); } try {     con = DriverManager.getConnection(url, "myLogin", "myPassword");     stmt = con.createStatement();     ResultSet rs = stmt.executeQuery(query);     while (rs.next()) {     String s = rs.getString(”NAME");        System.out.println(s);     }     rs.close();     stmt.close();     con.close(); }catch(SQLException ex) {    System.err.print("SQLException: ");    System.err.println(ex.getMessage()); }}} Kjell Orsborn 8/12/09
  • 10. UU - IT - UDBL 10 JDBC example (prepared statement) import java.sql.*; public class JDBCExample {    public static void main(String args[]) { String url = "jdbc:mySubprotocol:myDataSource"; Connection con; String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME > ?; Int incomeLimit; PreparedStatement stmt; try {     Class.forName("myDriver.ClassName"); }catch(java.lang.ClassNotFoundException e) {    System.err.print("ClassNotFoundException: ");    System.err.println(e.getMessage()); } try {     con = DriverManager.getConnection(url, "myLogin", "myPassword"); stmt = con.prepareStatement(query); while(....) {    .... // Code to read lower income limit into incomeLimit stmt.setInt(1,incomeLimit); ResultSet rs = stmt.executeQuery();     while (rs.next()) {        System.out.println(rs.getString(”NAME"));     }}     rs.close();     stmt.close();     con.close(); }catch(SQLException ex) {    System.err.print("SQLException: ");    System.err.println(ex.getMessage()); }}} Kjell Orsborn 8/12/09
  • 11. UU - IT - UDBL 11 Embedded SQL • Host language include embedded and specially marked SQL statements. • Embedded statements are extracted by preprocessor, translated and replaced by database calls, precompiled (prepared) and stored on server. • The preprocessed application is then compiled normally • Supports dynamic recompilation • Reduces optimization cost and can be somewhat simpler than CLI programming. Kjell Orsborn 8/12/09