dbms
dbms
•Strict-2PL waits until the whole transaction to commit, and then it releases all the
locks at a time.
•Strict-2PL protocol does not have shrinking phase of lock release.
Objects –
An object is an abstraction of a real world entity or we can say it is an instance of
class. Objects encapsulates data and code into a single unit which provide data
abstraction by hiding the implementation details from the user. For example:
Instances of student, doctor, engineer in above figure.
Attribute –
An attribute describes the properties of object. For example: Object is STUDENT
and its attribute are Roll no, Branch, Setmarks() in the Student class.
Methods –
Method represents the behavior of an object. Basically, it represents the real-world
action. For example: Finding a STUDENT marks in above figure as Setmarks().
Class –
A class is a collection of similar objects with shared structure i.e. attributes and
behavior i.e. methods. An object is an instance of class. For example: Person,
Student, Doctor, Engineer in above figure.
Class student
{
Char Name[20];
Int roll_no;
--
--
Public:
Void search();
Void update();
}
In this example, students refers to class and S1, S2 are the objects of class which
can be created in main function.
Inheritance –
By using inheritance, new class can inherit the attributes and methods of the old
class i.e. base class. For example: as classes Student, Doctor and Engineer are
inherited from the base class Person.
In this example:
•The row key uniquely identifies each user.
•The column families personal and contact group related columns.
•The personal column family contains the columns name and age.
•The contact column family contains the columns email and phone.
16. a)Describe normalisation upto 3NF and BCNF with example. State the
desirable properties of decomposition.
Normalization:
→Normalization is the process of organizing the data in the database.
→Normalization is used to minimize the redundancy from a relation or set of
relations. It is also used to eliminate undesirable characteristics like Insertion,
Update, and Deletion Anomalies.
→Normalization divides the larger table into smaller and links them using
relationships.
→The normal form is used to reduce redundancy from the database table.
1. First Normal Form (1NF):
•A relation will be 1NF if it contains an atomic value.
•It states that an attribute of a table cannot hold multiple values. It must hold
only single-valued attribute.
•First normal form disallows the multi-valued attribute, composite attribute,
and their combinations.
Example:
EMPLOYEE TABLE:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE
14 John 7272826385, UP
9064738238
20 Harry 8574783832 Bihar
12 Sam 7390372389, Punjab
8589830302
TEACHER_DETAIL table:
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 Chemistry
25 Biology
47 English
83 Maths
83 Computer
EMPLOYEE table:
EMP_ID EMP_NAME EMP_ZIP
222 Harry 201010
333 Stephan 02228
444 Lan 60007
555 Kathrine 06389
666 John 462007
EMP_DEPT table:
EMP_DEPT DEPT_TYPE EMP_DEPT_TYPE
Designing D394 283
Testing D394 300
Stores D283 232
Developing D283 549
EMP_DEPT_MAPPING table:
DEPT_TYPE EMP_DEPT_TYPE
D394 283
D394 300
D283 232
D283 549
PROPERTIES OF DECOMPOSITION:
Decomposition refers to the division of tables into multiple tables to produce
consistency in the data. In this article, we will learn about the Database concept.
This article is related to the concept of Decomposition in DBMS. It explains the
definition of Decomposition, types of Decomposition in DBMS, and its properties.
PROPERTIES:
Lossless: All the decomposition that we perform in Database management system
should be lossless. All the information should not be lost while performing the join
on the sub-relation to get back the original relation. It helps to remove the
redundant data from the database.
Dependency Preservation: Dependency Preservation is an important technique in
database management system. It ensures that the functional dependencies between
the entities is maintained while performing decomposition. It helps to improve the
database efficiency, maintain consistency and integrity.
Lack of Data Redundancy: Data Redundancy is generally termed as duplicate
data or repeated data. This property states that the decomposition performed should
not suffer redundant data. It will help us to get rid of unwanted data and focus only
on the useful data or information.
Steps in Parsing:
•Lexical Analysis: The query is broken down into tokens such as keywords,
identifiers, and operators.Syntactical Analysis: The sequence of tokens is checked
against the SQL grammar rules.
•Semantic Analysis: The query is checked for semantic correctness, such as
verifying that the tables and columns exist.
3.Logical Plan Generation:
Once the query is parsed, a Logical Query Plan is generated. This plan describes
the sequence of high-level operations (e.g., select, project, join) needed to execute
the query.
Steps in Logical Plan Generation:
•Transformation Rules: The logical plan is transformed using a set of rules to
optimize the sequence of operations (e.g., pushing selections down to reduce the
size of intermediate results).
4.Cost Estimation:
The Cost Estimator evaluates different possible execution strategies for the query
and assigns a cost to each. The cost usually considers factors like I/O operations,
CPU usage, and memory consumption.
Components of Cost Estimation:
•Statistical Information: The optimizer uses statistics such as table size, index
availability, data distribution, and selectivity of predicates to estimate costs.
•Cost Metrics: Costs are usually estimated in terms of disk I/O (number of page
reads and writes), CPU usage, and response time.
•Plan Alternatives: For each logical operation (e.g., join), multiple physical
methods (e.g., nested loop join, hash join) are considered and their costs are
estimated.
5. Physical Plan Generation:
The logical plan is converted into a Physical Query Plan. This plan specifies the
actual algorithms and data access methods that will be used to execute the query.
Physical Operators:
•Table Access Methods: Methods like table scan, index scan, or index seek are
chosen based on the data and indexes available
•Join Algorithms: The optimizer selects between different join methods (e.g.,
nested loop join, sort-merge join, hash join) based on cost and data characteristics.
•Sorting and Aggregation: Operations like sorting, grouping, and aggregation are
optimized using efficient algorithms like quicksort, hash aggregation, etc.
6. Plan Selection:
The optimizer compares the costs of all possible physical plans and selects the one
with the lowest estimated cost.
•Search Space: The optimizer explores a large search space of possible execution
plans, considering various transformations and join orders.
•Heuristics vs. Exhaustive Search: Some optimizers use heuristics to limit the
search space (e.g., limiting the number of joins considered), while others may use
exhaustive search methods like dynamic programming.
7. Result of query:
The selected query execution plan is passed to the Query Executor, which actually
retrieves the data from the database.
•Execution Strategies:Pipelined Execution: Operators produce outputs that are
immediately consumed by the next operator, reducing the need for intermediate
storage.
•Materialized Execution: Intermediate results are stored temporarily, and
subsequent operations are performed on these stored results.