Database Foundation Training


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
  • 04/07/11 Concepts What is Database A database is a collection of information that is organized so that it can easily be accessed, managed, and updated. In one view, databases can be classified according to types of content: bibliographic, full-text, numeric, and images. What is DBMS A DBMS is a set of software programs that controls the organization, storage, management, and retrieval of data in a database. DBMSs are categorized according to their data structures or types. The DBMS accepts requests for data from an application program and instructs the operating system to transfer the appropriate data. The queries and responses must be submitted and received according to a format that conforms to one or more applicable protocols. When a DBMS is used, information systems can be changed more easily as the organization's information requirements change. New categories of data can be added to the database without disruption to the existing system. What is DML Data Manipulation Language Select, Update, Insert, Delete What is DDL Data Definition Language Create, Drop, Alter, Truncate
  • 04/07/11
  • 04/07/11 Database Schema Table View Trigger Store Procedure Synonym DB Link Sequence
  • 04/07/11 CREATE [ TEMPORARY | TEMP ] TABLE table (     column type     [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT value ]     [ column_constraint_clause | PRIMARY KEY } [ ... ] ]     [, ... ]     [, PRIMARY KEY ( column [, ...] ) ]     [, CHECK ( condition ) ]     [, table_constraint_clause ]     ) [ INHERITS ( inherited_table [, ...] ) ]
  • 04/07/11 A  database index  is a  data structure  that improves the speed of data retrieval operations on a  database table  at the cost of slower writes and increased storage space. Indexes can be created using one or more  columns of a database table , providing the basis for both rapid random lookups and efficient access of ordered records. B-Trees Index (Primary Key) Bitmap Index Hash Index Reverse Index Index based on Function
  • 04/07/11 In  database   theory , a  view  consists of a stored  query  accessible as a virtual  table  composed of the result set of a  query . Unlike ordinary tables (base tables) in a  relational database , a view does not form part of the physical schema : it is a dynamic, virtual table computed or collated from  data  in the  database . Changing the  data  in a  table  alters the  data  shown in subsequent invocations of the view.
  • 04/07/11 A  stored procedure  is a  subroutine  available to applications accessing a  relational   database system . Stored procedures (sometimes called a  proc ,  sproc ,  StoPro ,  StoredProc , or SP ) are actually stored in the database  data dictionary .
  • 04/07/11 A  database trigger  is  procedural code  that is automatically executed in response to certain events on a particular  table  or  view  in a  database . The trigger is mostly used for keeping the integrity of the information on the database. For example, when a new record (representing a new worker) is added to the employees table, new records should be created also in the tables of the taxes, vacations, and salaries.
  • 04/07/11 A Synonym is nothing more than an alias or alternate name for a  table ,  view ,  Sequence , or other  Schema object . They are used mainly to make it easy for users to access database objects owned by other users. They hide the underlying object's identity and make it harder for a malicious program or user to target the underlying object. Because a synonym is just an alternate name for an object, it requires no storage other than its definition. When an application uses a synonym, Oracle forwards the request to the synonyms underlying base object. By coding your programs to use synonyms instead of table names, you insulate yourself from any changes in the name, ownership, or table locations. If you frequently refer to a table that has a long name, you might appreciate being able to refer to it with a shorter name without having to rename the table and alter the code referring to that table.
  • 04/07/11 A  database transaction  comprises a unit of work performed within a  database management system  (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. Transactions in a database environment have two main purposes: To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and many operations upon a database remain uncompleted, with unclear status. To provide isolation between programs accessing a database concurrently. Without isolation the program's outcomes are possibly erroneous.
  • 04/07/11
  • 04/07/11 What is DW Data Warehouse Intelligence is a term to describe a system used in an organization to collect data, most of which are transactional data, such as purchase records and etc., from one or more data sources, such as the database of a transactional system, into a central data location, the Data Warehouse, and later report those data, generally in an aggregated way, to business users in the organization. This system generally consists of an  ETL  tool, a Database, a Reporting tool and other facilitating tools, such as a Data Modeling tool.
  • 04/07/11
  • Database Foundation Training

    1. 1. Database Foundation Training Feb. 2011
    2. 2. Database & DBMS Insert, Update, Delete, Select Create. Drop, Alter, Truncate
    3. 3. Categories of Database <ul><li>Categories </li></ul><ul><ul><li>Relational Database (RDBMS) </li></ul></ul><ul><ul><ul><li>Microsoft SQL Server </li></ul></ul></ul><ul><ul><ul><li>Oracle </li></ul></ul></ul><ul><ul><ul><li>Sybase </li></ul></ul></ul><ul><ul><ul><li>IBM </li></ul></ul></ul><ul><ul><ul><li>Mysql </li></ul></ul></ul><ul><ul><li>Flat File Database </li></ul></ul><ul><ul><ul><li>Lotus Notes </li></ul></ul></ul>
    4. 4. Objects of Database <ul><li>Objects </li></ul><ul><ul><li>Database </li></ul></ul><ul><ul><ul><li>Schema </li></ul></ul></ul><ul><ul><ul><ul><li>Table </li></ul></ul></ul></ul><ul><ul><ul><ul><li>View </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Synonym </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Store Procedure </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Function </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Trigger </li></ul></ul></ul></ul>
    5. 5. Table Table Column Name Data Type Data Length Nullable Default Value Constraint (PK. FK) Index
    6. 6. Index Index B-Tree Index Bitmap Index Hash Index Reverse Index ... Select * From Tab1 Where Name=‘Kong’ And Corporation=‘IBM’ And Country=‘CN’ ID Name Corporation Country … . … . … .. … . 1258 Kong IBM CN 1259 Kong IBM CN … . … … … 1335 ZhaoPing HP EN
    7. 7. View <ul><li>View </li></ul><ul><ul><li>Views can represent a subset of the data contained in a table </li></ul></ul><ul><ul><li>Views can join and simplify multiple tables into a single virtual table </li></ul></ul><ul><ul><li>Views can act as aggregated tables, where the database engine aggregates data ( sum, average  etc) and presents the calculated results as part of the data </li></ul></ul><ul><ul><li>Views can hide the complexity of data; for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table </li></ul></ul><ul><ul><li>Views take very little space to store; the database contains only the definition of a view, not a copy of all the data it presents </li></ul></ul><ul><ul><li>Depending on the SQL engine used, views can provide extra security </li></ul></ul><ul><ul><li>Views can limit the degree of exposure of a table or tables to the outer world </li></ul></ul>
    8. 8. Store Procedure & Function Store Procedure CREATE { PROC | PROCEDURE } [schema_name.] procedure_name [ ;number ]     [ { @parameter [ type_schema_name. ] data_type }         [ VARYING ] [ = default ] [ OUT | OUTPUT ] [READONLY]     ] [ ,...n ] [ WITH <procedure_option> [ ,...n ] ] [ FOR REPLICATION ] AS { [ BEGIN ] sql_statement [;] [ ...n ] [ END ] } [;] Function CREATE FUNCTION [ schema_name. ] function_name( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type     [ = default ] [ READONLY ] }     [ ,...n ]   ] ) RETURNS return_data_type     [ WITH <function_option> [ ,...n ] ]     [ AS ]     BEGIN         function_body         RETURN scalar_expression     END [ ; ]
    10. 10. Synonym Synonym Public Synonym CREATE PUBLIC SYNONYM employees for hr.employees; Private Synonym CREATE SYNONYM addresses FOR hr.locations;
    11. 11. Transaction Transaction 1. To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and many operations upon a database remain uncompleted, with unclear status. 2. To provide isolation between programs accessing a database concurrently. Without isolation the program's outcomes are possibly erroneous.
    12. 12. How DML works Oracle Client 3.1 Syntax Validation 3.2 Objects Validation 3.3 Objects Locks 3.4 Access Right of Objects Validation 3.5 Explain Plan Sql Query Cache Sql Query Cache 2/5. SQL query + Plan 2. SQL query 1. SQL query Database 4. SQL query + Plan 6. SQL query + Plan 4.Exception
    13. 13. Database vs. Data Warehouse OLTP (Online Transaction Processing) OLAP (Online Analysis Processing)
    14. 14. Q & A Questions?