Cs403 Short Notes
Cs403 Short Notes
Ch: 19
Q: Normalization is based on the concept of …….?
Functional dependency
Functional dependency:
If A and B are attributes of a relation R, then B is functionally dependent on
A
if each value of A in R is associated with exactly one value of B in R;
Functional dependency Notation:
Inference Rules:
Called inference axioms or Armstrong axioms.
Names Rules
1. Reflexivity: If B is a subset of A, then A B.
This also implies that A A always
holds. Functional dependencies of
this type are called trivial
dependencies.
2. Augmentation: If we have A B then AC BC
3. Transitivity: If we have A B and B C then A
C.
4. Additivity of Union: If we have A B and A C then A
BC.
5. Projectivity or Decomposition: If we have A BC and A B then
A C.
6. Pseudo transitivity: If we have A B and CB D then
AC D.
Normalization
Advantages of Normalization:
1. Remove or reduce redundancy.
2. Efficiently organizing data.
Two Goal of Normalization:
1. Eliminate redundant data
2. Ensure data dependencies
There are two type of data dependency:
1. Row Level.
2. Column Level.
Q: How many type of normalization?
ANS:
There three type of normalization.
1. 1st Normal Form
2. 2nd Normal Form
3. 3rd Normal Form
Ch: 20
What are the Anomalies in DBMS?
ANS:
An inconsistent, incomplete or incorrect state of database.
Redundancy
Insertion Anomaly
Deletion Anomaly
Updation Aonaly
Ch: 22
For the physical database design we need to check the usage of the data in
term of its size and the frequency.
Grouping of attributes in the logical order.
Arrangement of Similar records into the secondary memory (hard disk)
DESIGNING FIELDS:
Fields mean columns.
Field is the smallest unit of application data.
Data types:
1. the structure defined for placing data in the attributes
2. Set of values along with the operations that can be performed.
Data Types
Data type Size
VARCHAR Now deprecated -
VARCHAR is a synonym
for VARCHAR2 but this
usage may change in
future versions.
CHAR(size) Fixed length character 1 to 32767
data of length size bytes.
This should be used for
fixed length data. Such as
codes A100, B102...
NUMBER (p, s) Magnitude 1E-130 .. -84 to 127
10E125 maximum
precision of 126 binary
digits, which is roughly
equivalent to 38 decimal
digits
The scale s can range
from -84 to 127. For
floating point don't
specify p,s REAL has a
maximum precision of 63
binary digits, which is
roughly equivalent to 18
decimal digits
LONG Character data of 32760
variable length (A bigger
version the VARCHAR2
data type)
DATE Valid data range 4712 to 9999
RAW(size) Raw binary data of 32767
length size bytes. You
must specify size for a
RAW value.
LONG RAW Raw binary data of 32760
variable length. (not
interpreted by PL/SQL)
BLOB Binary Large Object 4gigabytes
Referential Integrity:
keep the input values for a specific attribute in specific limits in comparison to
any other attribute of the same or any other relation.
Ch: 23
Denormalization: move from higher to lower normal forms of database
modeling in order to speed up database access.
Denormalization process is applied for deriving a physical data model from a
logical form.
Logical DB Design In physical DB design
accessed by same PK accessed by DBMS
Q: …… may decompose one logical relation into separate physical records,
combine some or do both?
i): Denormalization ii): Normalization
Many to many binary relationships mapped to three relations.
One to one binary Relationship:
Merge two Entity types into one with one to one relationship.
One to many binary Relationship: when the ET on one side does not participate in any other relationship,
then many side ET is appended with reference data rather than the FK.
Ch: 25
SQL-92.
SQL: Structured Query Language
Also pronounced as “Sequel”
A de-facto standard for relational DBMS
Standard accepted by bodies like ANSI and ISO
SQL is an ANSI standard computer language for accessing and manipulating
databases.
Standard SQL commands such as: "Select", "Insert", "Update", "Delete",
"Create", and "Drop"
Rules of SQL Format:
read, write, and remove.
SQL Commands:
Two commands:
1. DDL: Data Definition Language (create , alter , Drop and
destroy/delete)
2. DML: Data Manipulation Language (insert, retrieve , deletion and
modify)
3. DCL: Data Control language (GRANT and REVOKE)
DDL: CADDD
DML: IRDM
Following are the rules for writing the commands in SQL:-
•Reserved words are written in capital like SELECT or INSERT.
• User-defined identifiers are written in lowercase
• Identifiers should be valid, which means that they can start with @,
alphabets ,or with numbers.
The maximum length can be of 256. The reserved words should not be used
as identifiers.
[ ] it is optional.
{ } it is necessary.
| choice.
Data Types in SQL Server:
1. Integer
Integers
Name Range
Biggint -2 -9,223,372,036,854,775,808) to 261
61
- 1 (9,223,372,036,854,775,808)
Int -231 -2,147,483,648) to 231 - 1
(2,147,483,648)
Smallint -215 (-32,768) to 215 - 1 (32,767)
Tinyint 0 to 255
2. bit
Integer data with either a 1 or 0 value.
4. Text:
It handles the textual data.
Following are the different data types.
• Char: By default 30 characters, max 8000
• Varchar: Variable length text, max 8000
• Text: Variable length automatically
• nchar: nvarchar, ntext
5. Money:
: handles monetary data
o smallmoney: 6 digits, 4 decimal
o money: 15 digits, 4 decimal
6. Floating point
o Float
o Real
7. Date
o Smalldatetime
o datetime
Data dictionary or Data directory:
DDL statements are compiled, resulting in a set of tables stored in a special
file called a data dictionary or data directory.
Other name of data dictionary is metadata.
Two types of DML:
Procedural: (What to do and how to do)
in which the user specifies what data is needed and how to get it.
Nonprocedural: (What to do)
in which the user only specifies what data is needed
Ch: 26
Ch: 27
Alter Table Statement: (Columns)
make changes in the definition of a table already created through Create
statement.
Q: Write the use of alter table statement?
ANS:
It can
1. Add column
2. drop the attributes or
3. constraints, activate or deactivate constraints.
4. It modifies the design of an existing table.
5. Change column
6. Drop Column
7. Modify Column
Syntax:
ALTER TABLE table
{
ADD [COLUMN] column type [(size)] [DEFAULT default] |(See lecture
56)
ALTER [COLUMN] column type [(size)] [DEFAULT default] |
ALTER [COLUMN] column SET DEFAULT default |
DROP [COLUMN] column |
RENAME [COLUMN] column TO columnNew
}
Use RENAME COLUMN: to rename an existing column.
We cannot add, delete or modify: more than one column at a time.
TRUNCATE DELETE DROP
It is used to delete all It is used to delete one It is used to drop the
the rows of any table or many records/row. complete table from the
but rows would exist. database
Drop table: then table should be fully delete.
Truncate table: then only data inside the table should be deleted.
The Data Manipulation Language (DML) is used to or DML component or
commond:
1. Insert To add new rows to tables.
2. Select To retrieve rows from tables.
3. Update To modify the rows of tables.
DML does not used to:
a. Add new rows to tables
b. Retrieve rows from table
c. Modify the rows of tables
d. Alter a table definition
Q: SQL is a ……….language?
i) non-procedural ii) Procedural
There are two types of DML:
1. First is procedural in which: the user specifies what data is needed and
how to get it.
2. Second is nonprocedural in which: the user only specifies what data is
needed.
Ch: 28
The INSERT statement:
1. Insert a single record
2. Multiple records into a table.
NOT operator
Inverses the predicate’s value.
BETWEEN Operator
The BETWEEN condition allows you to retrieve values within a specific
range.
The syntax for the BETWEEN condition is:
SELECT columns
FROM tables
WHERE column1 between value1 and value2;
The BETWEEN function can be used in any valid SQL statement:
select, insert, update, or delete.
IN operator:
The IN function helps reduce the need to use multiple OR conditions.
It is sued to check in a list of values.
The syntax for the IN function is:
SELECT columns
FROM tables
WHERE column1 in (value1, value2,.... value_n);
Like Operator
Allows you to use wildcards in the where clause of an SQL statement.
Perform: pattern matching.
The patterns that you can choose from are:
1. %: Match string of any length (including zero length)
2. _ Match a single character
Ch: 30
Functions in SQL
one-word command that return a single value.
The value of a function can be determined by input parameters.
There are normally two types of functions:
1. First is Built: in, which are provided by any specific tool or language.
2. User defined: which are defined by the user.
Categories of functions Depend on:
1. The arguments
2. The return value
Functions are categorized as under:
– Mathematical (ABS, ROUND, SIN, SQRT)
– String (LOWER, UPPER, SUBSTRING, LEN)
– Date (DATEDIFF, DATEPART, GETDATE())
– System (USER, DATALENGTH, HOST_NAME)
– Conversion (CAST, CONVERT)
Aggregate Functions:
Functions that operate on a set of rows and return a single value.
If used among many other expressions in the item list of a SELECT statement,
the SELECT must have a GROUP BY clause.
No GROUP BY clause is required if the aggregate function is the only value
retrieved by the SELECT statement.
Following are some of the aggregate functions:
Ch: 31
Inner Join:
Only those rows from two tables are joined that have same value in the
common attribute.
The common attributes are required to:
1. Not have the same name in both tables.
2. Must have the same domain in both tables.
Q: Write the technique of inner join?
ANS:
1. SELECT * FROM course INNER JOIN program
ON course.prName = program.prName
2. Select * FROM Course c inner join program p
ON c.prName = p.prName
3. SELECT * FROM course, program
WHERE course.prName = program.prName
Suppose we have two tables T1 and T2, Tuples of T1 that do not match some
row in T2 will not appear in ….?
a. Outer join
b. Inner join
c. Both I and II
d. None of the above
Outer Join:
The join operation that rely on null values, called outer joins.
COURSE rows without a matching PROGRAM row appear exactly once in
the result.
Several variants of the outer join:
1. Left outer join
2. Right outer join
3. Full outer join
In a right outer join: COURSE rows without a matching PROGRAM row
appear in the result, but not vice versa.
In a left outer join: PROGRAM rows without a matching COURSE row
appear in the result, but not vice versa.
In a full outer join: both COURSE and PROGRAM rows without a match
appear in the result.
(Of course, rows with a match always appear in the result, for all these
variants, just like the usual joins or inner joins).
Semi Join:
Another form of join that involves two operations.
First inner join is performed on the participating tables and then resulting
table is projected on the attributes of one table.
Following are the methods of accessing data from different tables:
Cartesian Product
Inner join ( Rely on common attributes)
Outer Join ( Rely on NULL values)
Full outer join (rows without a match appear in the result)
Semi Join (Two operation: inner join+ project)
Natural Join
Sub query: or (nested query)
Nested query:
Query that has another query embedded within it; the embedded query is
called a sub query.
A subquery typically appears:
within the WHERE clause of a query.
A subquery sometime appears:
in the FROM clause or the HAVING clause.
If the subquery return a single value: then we can use operators like = < > etc.
If the subquery returns multiple values then we can use operators like IN,
LIKE etc.
The IN operator allows us to test whether a value is in a given set of elements;
The subquery can be nested to any level.
The queries are evaluated: in the reverse order,
1. the inner most is evaluated first,
2. then the outer one
3. finally the outer most.
Ch: 32
Program written to perform different requirement created by the users /
Organization are called …
a. System program
b. Chip Program
c. Application Program
d. Low level program
Which of the following are the general activities, which are performed during
the development of application programs?
► Data input programs ► Processing ► Editing ► Display ► All of given
(Page 238)
Which of the following is true about application programs?
► develop before the database design
► Tools selection is made after the development database
► meant to perform different operations by the user (Page 238)
► must to design before the designing and developing database
User interface:
Type of user interface: (Two)
• Text based (UI)
• Graphical User Interface (GUI) most commonly called as Form
Text Based User Interface (UI):
In text based user interface certain keyboard numbers
For example:
Adding a Record --------- 1
Deleting a Record --------- 2
Enrollment --------- 3
Result Calculation --------- 4
Exit --------- 5
It should be user friendly and user must not search for required buttons or
text boxes” this statement is about.
a. Application program
b. User friendly interface
c. Language
d. System program
Which of the following is a feature of a good interface:
► User friendly ► Consistency ► Process based
Windows Controls: (take input and display output)
like buttons, checkboxes etc.
Numbers, Dates and Text:
Normally text boxes are used for the display of dates.
Ch: 33
Following things must be ensured for input forms:
• Forms should be user friendly
• Data integrity must be ensured,
• Checks can be applied within the tables definition
How creating database in MS Access?
a. First we will run MS Access and select New option from the file. Next it
will ask the name of database.
b. After running MS Access, create database option is selected directly
c. Go to the tool option of MS Access and select create Database option with
suitable name
d. Click on the file menu, select database option and then click it
The should be user friendly. Data integrity must be ensured and checks can be
applied within the tables.
a. Input forms
b. Computer language
c. Application programming
d. Database
Forms must be designed and arranged in a systematic manner.
Which of the following is not true about input forms?
► Provide an easy, effective, efficient way to enter data into a table
► Especially useful when the person entering the data is not familiar with the
inner workings
► Provide different controls to add data into the tables
► One input forms can populate one table at a time (Page 246)
Ch: 34
Classification of Physical Storage Media:
Media are classified according to three characteristics
Speed of access
Cost per unit of data
Reliability
We can also differentiate storage as either
Volatile storage (Power off storage lost)
Non-volatile storage (Power off storage not lost)
Typical media available are:
Cache
Main memory
Flash Memory
Magnetic disk
Optical storage (CD or DVD)
Tape storage
Cache
Cache: Pronounced cashe.
Two types of caching are commonly used in personal computers:
1. Memory caching (RAM)
2. Disk caching
A memory cache, sometimes called a cache store or ......?
a. ROM
b. DROM
c. RAM
d. Hard disk
The most recently accessed data from the disk (as well as adjacent
sectors) is stored in a …….?
a. Memory buffer
b. EPROM
c. ROM
d. Hard disk
Cache is a portion of memory made of high speed and cheaper _used for
main memory.
a. RAM,ROM
b. ROM,RAM
c. PROM,EPROM
d. Static RAM(SRAM),DRAM
SRAM: high-speed static RAM (SRAM)
DRAM: slower and cheaper DRAM
The Intel 80486 microprocessor: contains an 8K memory cache.
The Pentium has contains a 16K memory cache.
Level 1 (L1) cashes:
Such internal caches are often called Level 1 (L1) caches.
Level 2 (L2) cache:
External cache
L1 and L2 caches sit between the…. and the…..?
CPU, DRAM
Q: Accessing the speed of RAM ………. than hard disk?
ANS:
Thousands of times faster
Cache hit:
When data is found in the cache.
Main memory: known as RAM, standing for Random Access Memory.
Main memory: Constructed from (ICs) integrated circuits.
The access time to read or write any particular byte are independent of
whereabouts in the memory that byte is, and currently is approximately 50
nanoseconds (a thousand millionth of a second).
Main memory is expensive compared to external memory.
CPU transfer data to and from the main memory: in groups of two, four or
eight bytes.
Flash memory is a form of EEPROM.
1. Non-volatile
2. Stores information on a silicon chip
FAMOS: Floating-Gate Avalanche-Injection Metal Oxide Semiconductor.
Magnetic disk is round plate on which data can be encoded.
Two basic types of disks:
1. Magnetic disks
2. Optical disks
Types of Magnetic disks:
1. Floppy Disk:
2. Hard Disk
Floppy Disk: A typical 5¼-inch floppy disk can hold 360K or 1.2MB
(megabytes).
3½-inch floppies normally store 720K, 1.2MB or 1.44MB of data.
Hard disks can store anywhere from 20MB to more than 10GB.
Q: Which disk speed is faster?
i): Hard disk ii): Floppy disk
Hard disks are also from 10 to 100 times faster than floppy disks.
Optical disks come in three basic forms:
1. CD-ROM:
2. WORM
3. Erasable Optical (EO)
CD-ROM: Most optical disks are read-only.
WORM: Stands for write-once, read-many.
Erasable optical (EO): EO disks can be read to, written to, and erased just
like magnetic disks.
Laser records data by burning microscopic holes in the surface of the disk
with a
► Optical disk (Page 257)
► Floppy disk
The machine that spins a disk is called a disk drive.
Each disk drive is one or more heads (often called read/write heads) that
actually read and write data.
Disks: Non Volatile
RAID: Redundant Array of (Independent ) or Inexpensive Disks.
Striping:
Fundamental to RAID is "striping", a method of concatenating multiple
drives into one logical storage unit.
One sector (512 bytes) or as large as several megabytes (1MB).
RAID 0 RAID 1 RAID 2 RAID 3 RAID 4 RAID
not redundant redundant Hamming error stripes data at a byte stripes data at RAID-5 is the
correction level across several a block level best choices in
codes drives across several multi-user
drives environments
Data loss Data not SCSI drives Byte-level striping At least
loss support built-in requires hardware three and
error support for efficient
detection, use
more
typically
five drives
are
required for
RAID-5
arrays.
Ch: 35
File Organizations:
In this scheme, all the records have the:
1. the same size
2. the same field format
3. the fields having fixed size
Different record have different keys.
Log file are structured as: a pile.
Log file also called…..?
b. Transaction file c. Temporary file d. Hash file
Files store data and programs.
The method of access which uses key trAnsformation is known as
A. Direct
B. Hash
C. Random
D. Sequential
File protection:
When multiple users have access to files, it may be desirable to control by
whom and in what ways files may be accessed. This control is known as file
protection.
Type of Direct Access File Organization: (Two)
1. Indexed Sequential
2. Direct File Organization
Indexed Sequential:
The simplest indexing structure is the single-level one.
A file whose records are pair’s key-pointer.
where the pointer is the position in the data file of the record with the given
key.
Ch: 36
….provides rapid, non-sequential , direct access to records/Rows?
a. Hashing
b. Collisions handling
c. Non hashing
d. Sequential
Q: Hashing ….?
i): Direct access ii): sequential access
Hashing:
A key record field is used to calculate the record address by subjecting it to
some calculation; a process called hashing.
A hash function h is a function from the set of all search key values K to the
set of all bucket addresses B.
A good hash function gives an average-case lookup.
The worst hash function maps all keys to the same address/bucket.
The best hash function maps all keys to distinct addresses.
Following are the major characteristics of hash function:
• No indexes to search or maintain
• Very fast direct access
• Inefficient sequential access
• Use when direct access is needed, but sequential access is not.
Hashing Algorithms:
Two types
1. Prime division/remainder
2. Folding method
Perfect hashing function:
The direct address approach requires that the function, h(k), is a one-to-one
mapping from each k to integers in (1,m). Such a function is known as a
perfect hashing function
A perfect hash function map a key to distinct location having search time
► O(1) Page no 266
► O(n)
► O(n+1)
► O(n-1)
Handling the Collisions:
Various techniques are used to manage this problem:
• Chaining,
• Overflow areas,
• Re-hashing,
• Using neighboring slots (linear probing),
• Quadratic probing,
• Random probing, ...
Which of the following is disadvantage/tradoff of chaining technique to handle
the collisions?
► Unlimited Number of elements
► Fast re-hashing
► Overhead of multiple linked lists (Page 269)
If there is a further collision, we re-hash until an empty "slot" in the table is
found.
Advantage of Re-Hashing technique to handle the collisions?
► Collisions don’t use primary table space
► Unlimited number of elements
► Fast access through use of main table space (Page269 )
One of the simplest re-hashing functions is +1 (or -1).
Linear probing: also implements a quadratic re-hash function.
Overflow area:
Another scheme will divide the pre-allocated table into two sections:
1. The primary area to which keys are mapped
2. An area for collisions, normally termed the overflow area.
Method for handling collisions:
• Open addressing (array of (key, value) pairs.)
• Chaining
The hash table is an array of (key, value) pairs.
Q: Write the difference ways of choosing an alternative location?
ANS:
1. Linear probing
2. Double hashing
3. Rehashing
Linear Probing:
The simplest probing method is called linear probing.
In linear probing, the probe sequence is simply:
the sequence of consecutive locations, beginning with the hash value of the
key.
If the end of the table is reached: the probe sequence wraps around and
continues at location 0.
Only if the table is completely full will the search fail.
Summary Hash Table Organization
Organization Advantages Disadvantages
Ch: 37
An index on a table is a disk-based data structure.
(stored as file) that speeds up selections on the search key fields for the index.
An index contains a collection of data entries.
There can be multiple (different) indexes per file.
An index in a book is a list of words with the page numbers that contain each
word.
An index in a database is a list of values in a table with the storage locations of
rows in the table that contain each value.
Indexes can be created on either:
1. A single column
2. A combination of columns in a table
Inverted files or inversion , linked list, B+ trees, there are the three
implementation approaches of
a. Sequential Access
b. Hashing
c. Non sequential
d. Indexes
Following are the three-implementation approaches of Indexes:
• Inverted files or inversions
• Linked lists
• B+ Trees
Can be defined when even there is no data in the table , existing values
are checked in execution of this command , it supports section of forms
, these are the major properties of
a. Sequential approach
b. Direct approach
c. view
d. indexes
Index Classification:
Clustered vs. Un-clustered Indexes
Single Key vs. Composite Indexes
Tree-based, inverted files, pointers
Primary Index
o If the index is created on the basis of the primary key of the table, then
it is known as primary indexing.
Primary keys are unique to each record and contain 1:1 relation
1. Dense index
2. Sparse index
Secondary Indexes:
Users often need to access data on the basis of non-key or non-unique
attribute.
Secondary Index is a two column file, which stores the address of every tuple
of the table.
Inverted files or inversions:
More than one inversions can be created, even on all attributes
Inverted file contains the values of attribute in sorted order and the relative
address of the record.
Each node stores key values and pointers; nodes are connected through links.
B+ Trees:
Number of pointers in a node is one more than the number of keys
Number of pointers called order of tree
Distance of all leaf nodes from the root is same
Index can also be created on composite attributes.
Properties of Indexes:
Indexes can be defined even when there is no data in the table
Existing values are checked on execution of this command
Support selections of form
field <operator> constant
Support equality selections
Either “tree” or “hash” indexes help here.
Index support Range selections:
1. <, >
2. <=
3. >=
4. BETWEEN)
To select the range while creating Indexes, the operator that is not used is .
Equals to (==)
Less than (<)
BETWEEN
Ch: 38
Fast random access: an index structure may be used.
Primary index or Clustering index Secondary index or Non Clustering
index
records is sequentially different from the sequential order
primary index, or clustering index. secondary indices, or nonclustering
indices
The data rows are not sorted and stored in order based on their nonclustered keys.
The leaf layer of a nonclustered index does not consist of the data pages. Nonclustered indexes can
be defined on either a table with a clustered index or a heap.
NOTE: See cluster and nocluster again
Because nonclustered indexes store clustered index keys as their row locators, Clustered index keys
as small as possible.
Do not choose large columns as the keys to clustered indexes if a table also has nonclustered
indexes.
Ch: 39
Views are generally used to focus, simplify and customize the perceptions each
user has of the
a. Database
b. Program
c. Operating system
d. View
A view is defined to combine certain data from one or more tables for
different reasons
Views have other options such as totals and subtotals.
A "view" is essentially a dynamically generated.
Q: There are two ways to create a new view in your database:
1. Create a new view from scratch.
2. Or, make a copy of an existing view and then modify it.
There are ways to create a new view in your database
a. Three
b. Two
c. Five
Q: Types of views?
ANS:
1. Materialized View
2. Simple Views
3. Complex View
4. Dynamic Views.
Materialized View:
A materialized view is a replica of a target master from a single point in time.
materialized views are updated from one or more masters through individual
batch updates, known as a refreshes refreshes refreshes refreshes, from a
single master site or master materialized view site
Simple view:
As defined earlier simple views are created from tables and are used for
creating secure manipulation over the tables or structures of the database.
Views make the manipulations easier to perform on the database.
Dynamic Views:
In which data is not stored and the expressions used to build the view are used
to collect the data dynamically.
Dynamic views generally are:
1. complex views
2. views of views
3. views of multiple tables
Views can be referred in SQL statements like tables.
Which of the following is INCORRECT about VIEWS?
► It is not possible to left out the data which is not required for a specific
view. (Page 280)
► A database view displays one or more database records on the same page.
► Views can be used as security mechanisms
► Views are generally used to focus the perception each user has of the
database.
Deleting Views:
A view can be dropped using the DROP VIEW command.
Ch: 41
Views are virtual tables.
Other name of materialized views:
also called indexed views created through clustered index.
Indexes: cannot be accessed directly using a SELECT statement.
Materialized views: can be accessed directly using a SELECT statement.
Materialized views and Indexes are NOT similar by the following way(s).
► They must be refreshed when the data in their master tables changes.
► They can be accessed directly using a SELECT statement (Page 291)
► All of given
Materialized views in data warehouses are typically referred to as summaries.
A materialized view can be partitioned.
You can define a materialized view on a partitioned table and one or more
indexes on the materialized view.
Simple view:
View on single table is simple.
Complex view:
Involving multiple tables is called complex view.
Transaction Management:
an indivisible unit of work comprised of several operations.
ACID: Atomicity, Consistency, Isolation, and Durability.
In which of the following, Materialized Views are suitable
► Data warehousing
► Decision support
► Mobile computing
► All of the Given (Page 290)
Which of the following should be a property of a database transaction?
► Atomicity
► Consistency
► Isolation
► Durability
► All
A transaction can thus end/termination in two ways:
1. Commit (successful execution)
2. Rollback or Abort (Error)
Ch: 42
• To read a database object: it is first brought into main memory from disk, and then its value is
copied into a program variable.
Main memory to disk
• To write a database object: in-memory copy of the object is first modified and then written to
disk.
Database `objects: are the units in which programs read or write information.
Transaction:
a set of actions that are partially ordered.
Q: A transaction is seen by the DBMS as a……, or list, of actions?
► Series
► Parallel
Denote the transactions:
A transaction T reading an object O as
Reading: RT (O);
Writing: WT (O).
When the transaction T is clear from the context, we will omit the subscript.
A schedule is a list of actions (reading, writing, aborting, or committing) from
a set of transactions.
The order in which two actions of a transaction T appear in a schedule must
be the same as the order in which they appear in T.
I/O activity can be done in parallel with CPU activity in a computer.
Strict Two-Phase Locking (Strict 2PL): Has two rules.
Deadlock:
A cycle of transactions waiting for locks to be released is called a
deadlock.
The second rule in Strict 2PL is:
All locks held by a transaction are released when the transaction is completed.
We can prevent deadlocks: by giving each transaction a priority.
The lower the timestamp, the higher the transaction's priority
Ch: 43
Log entry is made only for the ….. operation?
► Write
► Read
Write Sequence or operation:
X = X + 10
Write X …….
Write Sequence or operation Data Entry in log file will be
X = X + 10 <Tn, X, 33>
Ch: 45
Interaction is in the process of changing system state.
Transaction isolation levels.
Two primary modes for taking locks:
1. Optimistic
2. Pessimistic.
Pessimistic locking guarantees that the first transaction can always apply a
change to the data it first accessed.
Optimistic locking mode: the first transaction accesses data but does not take
a lock on it.
Types of Locks:
1. Shared 2. Update 3. Exclusive locks
Q: Shared locks are used when data is …..(usually in pessimistic locking
mode).
a. Read b. Write
Deadlock is a situation when two transactions are waiting for each other to
release a lock.
Wait – for Graph:
Q: ….. is used for the detection of deadlock.
ANS:
Wait – for Graph
Arrowhead represents that a transaction has locked a particular data item.
Two Phase Locking:
The locks are granted and released in two phases, the growing and
shrinking phase
Finer the granularity more concurrency but more overhead
When a lock at lower level is applied, compatibility is checked upward.
The granularity of locks: how much of the data is locked at one time.