4) databases


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

4) databases

  1. 1. Vikas Manoria IT Specialist – IBM Academic Initiative [email_address] Section - 4) Databases
  2. 2. Section 4 - Databases (5%) <ul><li>Create a database connection </li></ul><ul><li>Use the SQL Statement wizard </li></ul><ul><li>Sample contents of a database table </li></ul>
  3. 3. Purpose and Scope of the Database Tools <ul><li>Used by Web Developers and EJB Developers </li></ul><ul><ul><li>HTML form design </li></ul></ul><ul><ul><li>Map EJBs to databases </li></ul></ul><ul><li>The Data Perspective provides functionality to </li></ul><ul><ul><li>Connect to a database </li></ul></ul><ul><ul><ul><li>Optionally filter tables by pattern </li></ul></ul></ul><ul><ul><li>Import existing schema to local system </li></ul></ul><ul><ul><ul><li>XMI files describe the database, schema, and objects contained in the DB </li></ul></ul></ul><ul><ul><ul><li>Only the schema definition is imported, NOT the data </li></ul></ul></ul><ul><ul><li>Create new databases, schemas, tables, views, stored procedures, or user-defined functions </li></ul></ul>
  4. 4. Features of the Data Perspective Tools <ul><li>The built-in Derby database allows one client connection. </li></ul><ul><ul><li>There is no extra installation required to use this database. </li></ul></ul><ul><li>They provide the ability to create new databases and database objects using Class diagram, Information Engineering (IE) diagram, and Integration Definition for Function Modeling (IDEF1X) diagram logical modeling diagrams. </li></ul><ul><li>You can import and use existing database models. </li></ul><ul><li>You can also generate XML schemas from existing database models. </li></ul><ul><li>The tools allow you to build and execute SQL queries interactively from an imported database model, or through an active connection, using the SQL Editor and SQL Query Builder. </li></ul>
  5. 5. Data Perspective <ul><li>Use this perspective to work with databases, database objects and SQL statements </li></ul><ul><li>The Data Perspective views are: </li></ul><ul><ul><li>Database Explorer </li></ul></ul><ul><ul><li>Data Output </li></ul></ul><ul><ul><li>Data Project Explorer </li></ul></ul><ul><ul><li>Model Report </li></ul></ul><ul><li>This module will examine each of these to see its use </li></ul>
  6. 6. Database Explorer View: Connecting to a Database <ul><li>Right-click in the view and choose New Connection </li></ul><ul><li>Give the connection a name </li></ul><ul><li>Enter the details for the database </li></ul>2 3 1
  7. 7. Data Project Explorer View <ul><li>You can work locally with data objects. </li></ul><ul><li>This view allows you to create two types of projects </li></ul><ul><ul><li>Data design projects </li></ul></ul><ul><ul><li>Data development projects </li></ul></ul>
  8. 8. Contents of the Project in the Data Project Explorer <ul><li>The project contains structure </li></ul><ul><ul><li>No data is copied to the project </li></ul></ul><ul><li>The Connection contains structure and a link back to the data </li></ul><ul><ul><li>Data can be sampled from the Database Explorer view </li></ul></ul>Project Database Name Col.1 Col.2 Col.3 Col.4 REAL SCHEMA VARCHAR VARCHAR INTEGER Database Name Col.1 Col.2 Col.3 Col.4 REAL SCHEMA VARCHAR VARCHAR INTEGER Database Name Col.1 Col.2 Col.3 Col.4 123 A B 125 124 C REAL SCHEMA VARCHAR VARCHAR INTEGER
  9. 9. DB Output View <ul><li>One of the principal uses of the Data Perspective is to verify values in the database </li></ul><ul><ul><li>What is there before any code executes? </li></ul></ul><ul><ul><li>What was written after an SQL operation? </li></ul></ul><ul><li>The DB Output view displays data from the connection created in the Database Explorer view </li></ul>
  10. 10. Creating SQL Statements <ul><li>There are two ways to create an SQL statement in Rational Application Developer: </li></ul><ul><ul><li>SQL Editor </li></ul></ul><ul><ul><ul><li>Is a standard text editor with Content Assist </li></ul></ul></ul><ul><ul><ul><li>Can edit multiple SQL statements </li></ul></ul></ul><ul><ul><li>SQL Query Builder </li></ul></ul><ul><ul><ul><li>Provides a visual editor </li></ul></ul></ul><ul><ul><ul><li>Can only edit one SQL statement </li></ul></ul></ul><ul><li>Both tools can be used to build an SQL statement. </li></ul><ul><ul><li>SQL Query Builder generates most of the SQL you would have to type into the SQL Editor </li></ul></ul><ul><li>Note that in the other perspectives, a SQL Scrapbook page: </li></ul><ul><ul><li>Resembles the SQL Editor </li></ul></ul><ul><ul><li>Does not start with a SQL statement template </li></ul></ul><ul><ul><li>Is not stored as SQL </li></ul></ul><ul><ul><li>Cannot have host variables </li></ul></ul>
  11. 11. Selecting How to Write the SQL Statement <ul><li>Select File > New > Other > Data > SQL Statement . </li></ul><ul><li>Choose </li></ul><ul><ul><li>SQL builder </li></ul></ul><ul><ul><li>SQL editor </li></ul></ul><ul><li>Different Statement Templates are available </li></ul><ul><ul><li>SQL builder: </li></ul></ul><ul><ul><ul><li>SELECT, INSERT, UPDATE, DELETE, FULLSELECT,WITH </li></ul></ul></ul><ul><ul><li>SQL editor </li></ul></ul><ul><ul><ul><li>Same as SQL builder </li></ul></ul></ul><ul><ul><ul><li>Plus: Sample Statements, None </li></ul></ul></ul>
  12. 12. Using the SQL Editor <ul><li>In the New SQL Statement dialog </li></ul><ul><ul><li>Name the statement(s) </li></ul></ul><ul><ul><ul><li>You can have multiple statements in the editor </li></ul></ul></ul><ul><ul><li>Choose the SQL editor </li></ul></ul><ul><ul><li>Choose a Statement Template </li></ul></ul><ul><li>In the Connection Selection dialog that opens </li></ul><ul><ul><li>Create a new connection </li></ul></ul><ul><ul><li>Reuse an existing connection </li></ul></ul><ul><li>In the editor </li></ul><ul><ul><li>Use Code Assist to build your </li></ul></ul><ul><ul><li>SQL statement </li></ul></ul><ul><ul><li>Right-click to </li></ul></ul><ul><ul><li>Use Database Connection </li></ul></ul><ul><ul><li>Right-click to Run SQL </li></ul></ul>
  13. 13. Using the SQL Builder <ul><li>You can open the SQL Builder by right-clicking the Statements folder and selecting New . </li></ul>1 2 3
  14. 14. Checkpoint <ul><li>If there is no database available, what can you generate in Rational Application Developer? </li></ul><ul><li>What is the database installed with Rational Application Developer? </li></ul><ul><li>What is the restriction on this database? </li></ul><ul><li>Name the three views associated with the Data Perspective. </li></ul><ul><li>How do you visually modify an SQL statement? </li></ul>
  15. 15. Checkpoint answers <ul><li>Definitions for database, schema, table, view, stored procedure, or user-defined function. </li></ul><ul><li>Derby </li></ul><ul><li>Only one connection is allowed at a time. </li></ul><ul><li>Database Explorer, Data Project Explorer, DB Output </li></ul><ul><li>The SQL Builder allows you to visually describe an SQL statement. </li></ul>
  16. 16. Lab <ul><li>Create DB Connection </li></ul><ul><li>View Table contents </li></ul><ul><li>Create DB Development Project </li></ul><ul><li>Work with SQL Statements </li></ul>
  17. 17. Japanese Hebrew Thank You English Merci French Russian Danke German Grazie Italian Gracias Spanish Obrigado Portuguese Arabic Simplified Chinese Traditional Chinese Thai Korean