0% found this document useful (0 votes)
13 views

chapter 1 Basic Algorithms for Executing Query Operations (6)

The document provides an overview of Object-Oriented Programming (OOP) concepts such as object identity, structure, encapsulation, type hierarchies, and inheritance. It also discusses basic algorithms for executing query operations, heuristic methods for query optimization, and semantic query optimization techniques. Key points include the importance of object identity, the role of encapsulation in reducing complexity, and various strategies for optimizing database queries.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

chapter 1 Basic Algorithms for Executing Query Operations (6)

The document provides an overview of Object-Oriented Programming (OOP) concepts such as object identity, structure, encapsulation, type hierarchies, and inheritance. It also discusses basic algorithms for executing query operations, heuristic methods for query optimization, and semantic query optimization techniques. Key points include the importance of object identity, the role of encapsulation in reducing complexity, and various strategies for optimizing database queries.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Chapter On

Overview of Object-Oriented Concepts Object Identity, Object Structure, and


Type Constructors Encapsulation of Operations, Methods, and Persistence
Type Hierarchies and Inheritance

Here's an overview of the key concepts of Object-Oriented Programming (OOP), including


object identity, structure, encapsulation, type hierarchies, and inheritance:

Object-Oriented Concepts

1. Object Identity:
o In OOP, objects are instances of classes that have a unique identity.
o This identity is distinct from the object's state or attributes. Even if two objects
have the same state, they are considered different entities because they have
different identities.
o Object identity is crucial in distinguishing between object instances in memory
and is typically represented by a reference or pointer in programming languages.
2. Object Structure:
o An object is composed of attributes (data members) and methods (functions or
procedures).
o Attributes define the state of the object, while methods define the behavior.
o Object structure allows for complex data types that can aggregate attributes and
methods, enabling the modeling of real-world entities.
3. Type Constructors:
o Type constructors are mechanisms that allow the creation of new data types based
on existing ones.
o Common types of constructors include:
 Classes: Define new objects with a specific structure and behavior.
 Enumerations: Create a type with a fixed set of possible values.
 Abstract Data Types (ADTs): Encapsulate data and operations together.

Encapsulation of Operations

 Encapsulation refers to the bundling of data (attributes) and methods (operations) that
operate on that data into a single unit or object.
 It restricts direct access to some of an object's components, which reduces complexity
and increases the robustness of the code.
 Methods are the procedures defined within a class that can manipulate the object's state.
 Persistence in OOP refers to the capability of an object to exist beyond the execution of a
program, often achieved through serialization (storing the object’s state in a file/database)
and deserialization (reconstructing the object from stored data).

Type Hierarchies and Inheritance

1|Page
Advanced database
1. Type Hierarchies:
o Type hierarchies represent the relationships between classes in OOP, often
depicted as trees.
o This organization allows for polymorphism, where a method can operate on
objects of different classes that share a common parent class.
2. Inheritance:
o Inheritance is a cornerstone of OOP that allows a new class (subclass or derived
class) to inherit the properties and behaviors (methods) of another class
(superclass or base class).
o It promotes code reusability and can be classified into:
 Single Inheritance: A subclass inherits from one superclass.
 Multiple Inheritance: A subclass inherits from multiple superclasses
(supported in languages like C++ but not in others like Java).
 Multilevel Inheritance: A subclass inherits from a superclass which, in
turn, is a subclass of another superclass.
o Inheritance enables developers to create more specialized subclasses that extend
or override behaviors of the parent class.

Basic Algorithms for Executing Query Operations

1. Nested Loop Join: For each row in one table, scan the other table to find matches.
2. Sort-Merge Join: Sort both tables by join keys, then merge them.
3. Hash Join: Build a hash table on the smallest table, then probe with the other table.
4. Selection and Projection Algorithms: Scan to filter rows or remove columns,
respectively.
5. Index-Based Access: Use indexes to speed up operations like selection and joins.

Using Heuristic in Query Optimization

Heuristics are rules of thumb or guidelines that help optimize queries. Common heuristic rules
include:

1. Select before joins: Filter rows early to reduce the number of records processed in joins.
2. Push selections and projections down: Apply selection and projection operations as
early as possible in the query execution plan.
3. Join Ordering: Choose the order of joins to minimize intermediate result sizes.
4. Materialization: Decide when to materialize intermediate results based on costs.

Using Selectivity and Cost Estimates in Query Optimization

2|Page
Advanced database
 Selectivity: Refers to the fraction of rows that satisfy a condition in a selection operation.
High selectivity means fewer rows are returned, which is generally preferable for
efficiency.
 Cost Estimates: Determine the estimated resource usage for different operations (CPU,
I/O, memory). Use information about the size of tables, distribution of data, and index
availability.

Optimizers often combine selectivity estimates with cost models to choose the best execution
plan.

Semantic Query Optimization

Semantic query optimization uses knowledge of the data and its constraints to rewrite queries for
improved performance. Techniques include:

1. Use of Integrity Constraints: Understanding constraints (like functional dependencies)


can help in eliminating unnecessary joins or selections.
2. View Replacement: Replace parts of the query with equivalent subqueries or views if
they lead to reduced execution times.
3. Rewriting Queries: Utilizing equivalent expressions to alter the form of the SQL query
without changing its result but improving execution efficiency.
4. Data Distribution Knowledge: Using knowledge about data distribution to push
operations that would reduce the size of intermediate results.

3|Page
Advanced database

You might also like