Contents• Startup & Shutdown• Processes• Memory• Storage
– File– Indexes
• Transaction Control• Application Development
Startup & Shutdown• An Oracle database is not available to users until the
Oracle DBA server is made available to the users– Start an instance of the Oracle server– Mount the database– Open the database
• Oracle uses the initialization file – “init.ora” for the initial database configuration– The amount of memory to allocate– The names of control files– Various limits (Eg: SQL, Work Area Buffer limits)– Other system parameters (Eg: Default optimization for SQL)
• Closing the database would be in the reverse order of Startup
How Oracle DB is Opened• Startup Oracle Instance
– Read the “init.ora” file.– Create SGA (System Global Area)– Create Background Processes
• Database is Mounted– Open the control file– Get the data files and Redo Log files– Associate (Data Data Files) to the Instance
• Open the Database: Opening a DB makes it available for normal database operations– Oracle opens the online Datafiles and online Redo
Log files
Processes
• Processes– Serving User Requests– Writing data to Data Files– Recording Transactions in Log Files– Monitoring the Functioning of the Database
Oracle Processes
• User Process: Serving Users (Sessions)• Server Process: SQL process, Read data,
Return results• Background Processes:
– Database Writer (DBW0)– Log Writer (LGWR)– Archiver (ARC0)– System Monitor (SMON)– Process Monitor (PMON)– Recoverer (RECO-Mostly for Distributed Databases)
Memory• Memory
– System Global Area (SGA) – (‘Heart of Oracle’)
• Oracle Processes
– Program Global Area (PGA) – (Data and Control information for Server Process)
• SQL Work Area (Sort, Sort, Hash Operations)• Private Work Area (User Specific)
Oracle Memory – SGA/PGA
• When multiple users are concurrently connected to the same instance, then the data in the instance’s SGA is shared among the users.
Oracle Memory - SGA
• Buffer Cache: Copies of data blocks read from datafiles
• Redo Log Buffer: Holds information about changes made to the database (Used in Recovery)
• Shared Pool: Catalog/Library Area, SQL Areas• Large Pool: I/O Server Processes,
Backup/Recovery, Parallel Execution• Java Pool: Java Virtual Machine Code and Data
Oracle Memory - PGA
• Private SQL Area: – SQL Code issued by Users or Programs
• Session Memory:– Memory allocated to User Program Code
• SQL Work Area:– User Data from the result of user Queries (SQL)– Used for Sorting/Hashing
Permanent Storage
• Storage– Data Files – (data content)– Online Redo Log Files – (online backup)– Archive Log Files – (archived backup files)– Initialization Files – “init.ora”– Control Files – (smooth database operation)– SGA Definition Files – (memory definition)– Oracle Processing Log and Error Files –
(monitor, debug)
Oracle Data Files
• Each database is logically divided into one or more tablespaces• One or more datafiles are explicitly created for each tablespace to
physically store the data of all logical structures in a tablespace.• USERS Tablespace: User’s tables, indexes and other objects• SYSTEM Tablespace: Oracle system related tables and Catalog
(metadata)• Files would contain Blocks - DB_BLOCK_SIZE parameter can be
set in Oracle. The value of this parameter must be a multiple of the physical block size at the device level (operating system level).
File Storage – Blocks
• The Oracle Database data block format is similar regardless of whether the data block contains table, index, or clustered data.
• Oracle Data Block contains the following:– Header– Table Directory– Row Directory– Row Data– Free Space
File Storage – Blocks• Header:
– The header contains general block information, – The block address– Type of segment (for example, data or index) – Transaction history
• Table Directory:– This portion of the data block contains information
about the table having rows in this block.– Data from more than one table may be stored in one
Block• Row Directory:
– Contains information about the actual rows in the block
– Arrays of pointers where the row is located within the Block (ROWIDs)
File Storage – Blocks• Overhead (Header, Table and Row
Directory):– The data block header, table directory, and
row directory are referred to collectively as overhead.
• Free Space:– Free space is allocated for insertion of new
rows and for updates to rows that require additional space (for example, when a trailing null is updated to a non-null value)
File Storage – Blocks• Row Data:
– This portion of the data block contains table or index data. Rows can span blocks.
• NULLs: To conserve space, a null in a column only stores the column length (zero). Oracle does not store data for the null column.
Cost of Disk Access (Older Sem)Search: Start at root; use key comparisons to get
to leaf.
• Cost = log F N – F = Fanout (# Pointers/node) = Order of the Node – N = # Leaf Nodes
• Essentially the Height of the tree = Number of nodes to be traversed in a path from the root to a leaf node
Search using Index (Older Sem)• Example: Given the following data file EMPLOYEE(NAME, SSN,
ADDRESS, JOB, SAL, ... )• Given:
– A record size R = 150 bytes – block size B = 512 bytes r = 30,000 records. Blocks are
unspanned• We get:
– Blocking factor Bfr= B div R= 512 div 150= 3 records/block– Number of file blocks b= (r/Bfr)= (30,000/3)= 10,000 blocks– Average linear search cost of:
• (b/2)= 10,000/2= 5,000 block accesses– If the file records are ordered, the binary search cost would be:
• log2b= log210,000= 14 block accesses• For an index on the SSN field, assume the field size VSSN=9 bytes,
assume the record pointer size PR=7 bytes. Then:– index entry size RI=(VSSN+ PR)=(9+7)=16 bytes– index blocking factor BfrI= B div RI= 512 div 16= 32 entries/block– number of index blocks b= (r/ BfrI)= (30,000/32)= 938 blocks– binary search needs log2b= log2938= 10 block accesses
Oracle - SQL Processing• Parse• Translating a SQL statement, verifying it to be a valid
statement• Performing data dictionary lookups to check table and
column definitions• Acquiring parse locks on required objects so that their
definitions do not change during the statement's parsing• Checking privileges to access referenced schema
objects• Determining the optimal execution plan for the statement• Loading it into a shared SQL area• For distributed statements, routing all or part of the
statement to remote nodes that contain referenced data
Oracle - SQL Processing
• Query Processing• Stage 3: Describe Results• Stage 4: Defining Output• Stage 5: Bind Any Variables• Stage 6: Execute the Statement• Stage 7: Parallelize the Statement• Stage 8: Fetch Rows of a Query Result
Transaction Management Commands
• COMMIT: Commits all the changes which has been done, to the Disk (Permanent)
• ROLLBACK: Reverts all the changes which has been done.
Read Consistency
• As data blocks are read on behalf of a query, the blocks which have not been written to the disk need to be queried. Only when the data is ‘commit’ted (written) to the disk, then the modified data can be read.
Statement Level Read Consistency
Design Of Applications• Entity Relationship (E-R) Diagram• Convert E-R Diagram to Schema Diagram• Validate and refine the Schema Diagram using
Functional Dependencies and Normalization
• Create the Physical Schema using Data Definition languages (DDL)
• Create additional objects (such as Indexes, Views, Constraints, Triggers, Procedures etc) depending upon the applications.
Normalization• Normalization: The process of decomposing unsatisfactory "bad" relations by
breaking up their attributes into smaller relations• Normal form: Condition using keys and FDs of a relation to certify whether a relation
schema is in a particular normal form
• Normal Forms:– 1st NF:
• NO Composite attributes• NO Multi-valued attributes
– 2nd NF:• Every non-prime attribute ‘A’ in R is fully functionally dependent on
the primary key– 3rd NF:
• The Relation should be in 2NF and no non-prime attribute ‘A’ in R is transitively dependent on the primary key
• Informally speaking: Every non-key attribute must depend on the whole key, and nothing but the key
– BCNF:• Stricter form of 3NF
References
• Oracle Documentation• http://docs.oracle.com/cd/B28359_01/serv
er.111/b28318/toc.htm
Processes:http://docs.oracle.com/cd/B28359_01/server.111/b28318/process.htm
Memory (Primary & Secondary): http://docs.oracle.com/cd/B28359_01/server.111/b28318/memory.htmhttp://docs.oracle.com/cd/B28359_01/server.111/b28318/physical.htm
Transaction Management:http://docs.oracle.com/cd/B28359_01/server.111/b28318/transact.htm