DBMS Q&a
DBMS Q&a
-Providing Storage Structures and Search Techniques for Efficient Query Processing :
DBMS maintains indexes that are utilized to improve the execution time of queries and updates.
DBMS has a buffering or caching module that maintains parts of the database in main memory
buffers. The query processing and optimization module is responsible for choosing an efficient
query execution plan for each query submitted to the system.
#Reduced Development Time: Once a database is set up, creating new applications takes much
less time with a DBMS compared to traditional file systems, potentially one-sixth to one-fourth of
the time.
#Flexibility: DBMSs allow changes to the database structure without affecting the data or existing
applications.
# Up-to-date Information: DBMS ensures that the latest information is available to all users, which
is crucial for applications like reservation systems and banking.
#Economies of Scale: The DBMS approach consolidates data and applications, allowing the
organization to invest in more powerful shared resources, reducing overall costs.
Ans: The goal of the three-schema architecture is to separate the user applications from the
physical database. In this architecture, schemas can be defined at the following three levels:
1. The internal level has an internal schema, which describes the physical storage structure of the
database. The internal schema uses a physical data model and describes the complete details of
data storage and access paths for the database.
2. The conceptual level has a conceptual schema, which describes the structure of the whole
database for a community of users. The conceptual schema hides the details of physical storage
structures and concentrates on describing entities, data types, relationships, user operations, and
constraints. Usually, a representational data model is used to describe the conceptual schema
when a database system is implemented.
3. The external or view level includes a number of external schemas or user views. Each external
schema describes the part of the database that a particular user group is interested in and hides
the rest of the database from that user group. Each external schema is typically implemented using
a representational data model, possibly based on an external schema design in a high-level data
model.
In a DBMS based on the three-schema architecture, each user group refers to its own external
schema. Hence, the DBMS must transform a request specified on an external schema into a
request against the conceptual schema, and then into a request on the internal schema for
processing over the stored database. If the request is a database retrieval, the data extracted from
the stored database must be reformatted to match the user’s external view.
The processes of transforming requests and results between levels are called mappings.
Ans: Entity: a thing in the real world with an independent existence. An entity may be an object
with a physical existence (for example, a particular person, car, house, or employee) or it may be
an object with a conceptual existence (for instance, a company, a job, or a university course).
Entity Types: An entity type defines a collection (or set) of entities that have the same attributes.
Each entity type in the database is described by its name and attributes. For example, a company
employing hundreds of employees may want to store similar information concerning each of the
employees. These employee entities share the same attributes, but each entity has its own
value(s) for each attribute.
Ans: Attributes: Particular properties that describe entity. For example, an EMPLOYEE entity may
be described by the employee’s name, age ,address, salary and job.
Types of attributes:
1.Composite versus Simple (Atomic) Attribute
2.Single-valued versus multivalued
3.Stored versus derived
4.NULL values
5.Complex attributes
-Complex Attributes:
- These combine composite and multivalued attributes. Example: A person can have multiple residences and
phones.
Addressphone {
c. Notations of ER diagram :
Ans:
Ans:
6.Draw ER diagram for Banking System.
Ans:
Alternate Navathe/elsmari
1. Tuple : A tuple refers to a single row or record in a database table. It is an ordered set of values representing a
specific entity or object. Each attribute or column in a table corresponds to a value in the tuple.
2. Domain: A domain D is a set of atomic values. By atomic we mean that each value in the domain is indivisible as far as
the formal relational model is concerned. A common method of specifying a domain is to specify a data type from which
the data values forming the domain are drawn. It is also useful to specify a name for the domain, to help in interpreting
its values.
3. Attributes: An attribute Ai is the name of a role played by some domain D in the relation schema
R. D is called the domain of Ai and is denoted by dom(Ai).
4. Relation Schema : A relation schema R, denoted by R(A1, A2, ...,An), is made up of a relation name
R and a list of attributes A1, A2, ...,An. Each attribute Ai is the name of a role played by some
domain D in the relation schema R. D is called the domain of Ai and is denoted by dom(Ai). A
relation schema is used to describe a relation; R is called the name of this relation.
Ans: Constraints are restrictions on the actual values in a database state. These constraints are
derived from the rules in the miniworld that the database represents. Constraints on databases can
generally be divided into three main categories:
#Domain Constraints:
- Each attribute must have an atomic value from its domain.
- Common data types include integers, floats, characters, Booleans, strings, dates, times, timestamps, and money.
- A superkey is a set of attributes where no two tuples can have the same values. Every relation has at least one
superkey, which is all its attributes combined.
-A key K of a relation schema R is a superkey of R with the additional property that removing any
attribute A from K leaves a set of attributes K that is not a superkey of R anymore. Hence, a key
satisfies two properties:
1. Two distinct tuples in any state of the relation cannot have identical values for (all) the attributes
in the key. This first property also applies to a superkey.
2. It is a minimal superkey that is, a superkey from which we cannot remove any attributes and still
have the uniqueness constraint in condition 1 hold.This property is not required by a superkey.
- A candidate key is any key in a relation that could serve as a unique identifier. For example, a CAR relation
might have License_number and Engine_serial_number as candidate keys.
- A primary key is a designated candidate key used to uniquely identify tuples. It's usually underlined. Other
candidate keys are called unique keys.
- Attributes can have constraints to disallow NULL values. For example, the Name attribute in STUDENT might
be constrained to be NOT NULL.
Ans:
Ans: The Update (or Modify) operation is used to change the values of one or more attributes in a
tuple (or tuples) of some relation R. It is necessary to specify a condition on the attributes of the
relation to select the tuple (or tuples) to be modified.
Examples:
1. Operation:
Update the salary of the EMPLOYEE tuple with Ssn = ‘999887777’ to 28000.
2. Operation: Update the Dno of the EMPLOYEE tuple with Ssn = ‘999887777’ to 7.
Result: Unacceptable, because it violates referential integrity.
3. Operation: Update the Ssn of the EMPLOYEE tuple with Ssn = ‘999887777’ to ‘987654321’.
Result: Unacceptable, because it violates primary key constraint by repeating a value that already
exists as a primary key in another tuple; it violates referential integrity constraints because there
are other relations that refer to the existing value of Ssn .
Updating an attribute that is neither part of a primary key nor of a foreign key usually causes no
problems; the DBMS need only check to confirm that the new value is of the correct data type and
domain.
a. Unary operations :
The SELECT operation in databases filters tuples (rows) from a relation based on a specified condition.
It selectively retrieves only those tuples that satisfy the given condition, discarding others.
Selection Condition:
where,
- the symbol is used to denote the select operator
- the selection condition is a Boolean (conditional) expression specified on the attributes of relation
R
- tuples that make the condition true are selected
*appear in the result of the operation
- tuples that make the condition false are filtered out
*discarded from the result of the operation
Example:
σ DNO = 4 (EMPLOYEE)
Select the tuples for all employees who either work in department 4 and make over $25,000
per year, or work in department 5 and make over $30,000
where
- π(pi) - symbol used to represent the PROJECT operation,
<attributelist> - desired sublist of attributes from the attributes of relation R.
The result of the PROJECT operation has only the attributes specified in <attribute list> in the same
order as they appear in the list. Hence, its degree is equal to the number of attributes in <attribute
list>
Example : 1. To list the employee’s first and last name and salary we can use the PROJECT
operation as follows:
If the attribute list includes only non-key attributes of R, duplicate tuples are likely to occur. The
result of the PROJECT operation is a set of distinct tuples, and hence a valid relation. This is known
as duplicate elimination. For example, consider the following PROJECT operation:
π gender, Salary(EMPLOYEE)
The tuple <’F’,25000> appears only once in the resulting relation even though this combination of
values appears twice in the EMPLOYEE relation.
The number of tuples in a relation resulting from a PROJECT operation is always less than or equal
to the number of tuples in R. Commutativity does not hold on PROJECT
π gender, Salary(EMPLOYEE)
Ans:
#The JOIN operation, denoted by ⋈ , is used to combine related tuples from two relations into
single “longer” tuples. It allows us to process relationships among relations. The general form of a
JOIN operation on two relations R(A1, A2, ..., An) and S(B1, B2, ..., Bm) is R <join condition>S
To get the manager’s name, we need to combine each department tuple with the employee tuple
whose Ssn value matches the Mgr_ssn value in the department tuple
The result of the JOIN is a relation Q with n + m attributes Q(A 1, A2, ..., An,B1, B2, ..., Bm in that
order.Q has one tuple for each combination of tuples one from R and one from S whenever the
combination satisfies the join condition. This is the main difference between CARTESIAN PRODUCT
and JOIN. In JOIN, only combinations of tuples satisfying the join condition appear in the result,
whereas in the CARTESIAN PRODUCT all combinations of tuples are included in the result. The join
condition is specified on attributes from the two relations R and S and is evaluated for each
combination of tuples.
The DIVISION operation, denoted by ÷, is useful for a special kind of query that sometimes occurs
in database applications. An example is to Retrieve the names of employees who work on all the
projects that ‘John Smith’ works on. To express this query using the DIVISION operation, and
proceed as follows.
-First retrieve the list of project numbers that ‘John Smith’ works in the intermediate
relation SMITH_PHNOS:
-Next, create a relation that includes a tuple <Pno, Essn> whenever the employee whose Ssn is
Essn works on the project whose number is Pno in the intermediate relation SSN_PNOS:
Finally, apply the DIVISION operation to the two relations, which gives the desired employees social
security numbers;
Ans: