Beruflich Dokumente
Kultur Dokumente
Ans.
For Understanding :
(1. Physical level : how the data is stored physically and where it is
stored in
database.
2. Logical level : what information or data is stored in the database
(like what is the
datatype or what is format of data.
3.View level : end users work on view level. if any amendment is made
it can be
saved by other name.
2) Logical level.
The next-higher level of abstraction describes what data are
stored in the database, and what relationships exist among those data. The
logical level thus describes the entire database in terms of a small number of
relatively simple structures.
3) View level.
The highest level of abstraction describes only part of the entire
database. The variety of information stored in a large database. Many users
of the database system do not need all this information; instead, they need
to access only a part of the database. The view level of abstraction exists to
simplify their interaction with the system.
E.g. tellers in a bank get a view of customer accounts, but not of payroll data.
Q.2) What is Data Abstraction?
Ans.
Abstraction, in general, is the process of taking away or removing
characteristics from something in order to reduce it to a set of essential
characteristics. As in abstract art, the representation is likely to be one
potential abstraction of a number of possibilities. Adatabase abstraction
layer, for example, is one of a number of such possibilities.
Data abstraction is usually the first step in database design. A
complete database is much too complex a system to be developed without
first creating a simplified framework. Data abstraction makes it possible for
the developer to start from essential elements -- data abstractions -- and
incrementally add data detail to create the final system.
The doctor
is interested in name, height, weight, age, blood group, previous or existing
diseases etc of a person
An employer sees (abstracts) a person as Employee. The employer is
interested in name, age, health, degree of study, work experience etc of a person.
Data Independence:
Data independence is the type of data transparency that matters for a centralized DBMS. It refers
to the immunity of userapplications to changes made in the definition and organization of data.
There's a lot of data in whole database management system other than user's data. DBMS comprises of three kinds
of schemas, which is in turn data about data (Meta-Data). Meta-data is also stored along with database, which once
stored is then hard to modify. But as DBMS expands, it needs to be changed over the time satisfy the requirements of
users. But if the whole data were highly dependent it would become tedious and highly complex.
All schemas are logical and actual data is stored in bit format on the disk. Physical data independence is the power to
change the physical data without impacting the schema or logical data.
For example, in case we want to change or upgrade the storage system itself, that is, using SSD instead of Harddisks should not have any impact on logical data or schemas.
Entity Set:
An entity set is a set of entities of the same type (e.g., all persons having an
account at a bank).
Entity sets need not be disjoint. For example, the entity set employee (all
employees of a bank) and the entity set customer (all customers of the bank)
may have members in common.
An entity is represented by a set of attributes.
o E.g. name, S.I.N., street, city for ``customer'' entity.
o The domain of the attribute is the set of permitted values (e.g. the
telephone number must be seven positive integers).
Formally, an attribute is a function which maps an entity set into a domain.
where
is a relationship.
For example, consider the two entity sets customer and account. (Fig. 2.1 in the text).
We define the relationship CustAcct to denote the association between customers and
their accounts. This is a binary relationship set (see Figure 2.2 in the text).
Going back to our formal definition, the relationship set CustAcct is a subset of all the
possible customer and account pairings.
This is a binary relationship. Occasionally there are relationships involving more than
two entity sets.
The role of an entity is the function it plays in a relationship. For example, the
relationship works-for could be ordered pairs of employee entities. The first employee
takes the role of manager, and the second one will take the role of worker.
A relationship may also have descriptive attributes. For example, date (last date of
account access) could be an attribute of the CustAcct relationship set.
Q.6) Define Simple , composite attributes and single valued and multivalued
attributes?
Ans
E.g., A Class entity cannot exist unless related to a Faculty member entity
in this example, not necessarily at Juniata.
Partial Participation: There exist an instance of the first entity type that dont share an instance
of the relationship type with the other entity type.
CustomerNo
FirstName
LastName
Sally
Thompson
Sally
Henderson
Harry
Henderson
Sandra
Wellington
specialization is the results of taking subsets of a higher level entity set to form a lower level entity
sets.
2. In generalization,each higher level entity must also be a lower level entity.
In specialization,some higher level entities may not have lower-level entity sets at all.
3. Specialization is a Top Down process where as Generalization is Bottom Up process.
Q.12) What is Aggregation?
Ans.
One limitation of the E-R model is that it cannot express relationships among the
relationships so to overcome this we use aggregation.
Aggregation is a process when the relation between two entity is treated as a single
entity.
UML Notation:
Example
5 Marks
Q.1) Compare database systems with file systems.
Database Systems
File Systems
Entity-Relationship Model
Entity-Relationship model is based on the notion of real world entities and relationship among them. While formulating
real-world scenario into database model, ER Model creates entity set, relationship set, general attributes and
constraints.
ER Model is best used for the conceptual design of database.
ER Model is based on:
[Image: ER Model]
Entity
An entity in ER Model is real world entity, which has some properties called attributes. Every attribute is defined by
its set of values, called domain.
For example, in a school database, a student is considered as an entity. Student has various attributes like name, age
and class etc.
Relationship
The logical association among entities is called relationship. Relationships are mapped with entities in various ways.
Mapping cardinalities define the number of association between two entities.
Mapping cardinalities:
one to one
one to many
many to one
many to many
->
Relational Model
->
Previously, we covered modeling the users view as an E-R diagram. Entities, Relationships,
directly in a database.
Relational Model includes: Relations, Tuples, Attributes, keys and foreign keys.
Relation: A two dimensional table make up of tuples (This is a simple definition that
o
o
Relational Model
Database
Traditional Programmer
Entity
Relation
Table
File
Entity Instance
Tuple
Row
Record
Attribute
Attribute
Column
Field
Identifier
Key
Key
Q.3) What is relational algebra ? Describe any three operations with eg?
Ans
Relational Algebra is :
the formal description of how a relational database operates
an interface to the data stored in the database itself
the mathematics which underpin SQL operations
Operators in relational algebra are not necessarily the same as SQL
operators, even if they have the same name. For example, the SELECT
statement exists in SQL, and also exists in relational algebra. These two uses
of SELECT are not the same. The DBMS must take whatever SQL statements
the user types in and translate them into relational algebra operations before
applying them to the database.
Terminology
Relation - a set of tuples.
Tuple - a collection of attributes which describe some real world entity.
Attribute - a real world role played by a named domain.
Domain - a set of atomic values.
Set - a mathematical definition for a collection of objects which contains
no duplicates.
Select Operation ()
Selects tuples that satisfy the given predicate from a relation.
Notation p(r)
Where p stands for selection predicate and r stands for relation. p is prepositional logic
formulae which may use connectors like and, or and not. These terms may use
relational operators like: =, , , < , >, .
For example:
subject="database"(Books)
Output : Selects tuples from books where subject is 'database'.
subject="database"
(Books)
and price="450"
Output : Selects tuples from books where subject is 'database' and 'price' is 450.
subject="database"
(Books)
Output : Selects tuples from books where subject is 'database' and 'price' is 450 or the
publication year is greater than 2010, that is published after 2010.
Project Operation ()
Projects column(s) that satisfy given predicate.
Notation: A1, A2, An (r)
Where a1, a2 , an are attribute names of relation r.
Duplicate rows are automatically eliminated, as relation is a set.
for example:
subject,
author
(Books)
Selects and projects columns named as subject and author from relation Books.
Union Operation ()
Union operation performs binary union between two given relations and is defined as:
r s = { t | t r or t s}
Notion: r U s
Where r and s are either database relations or relation result set (temporary relation).
author
(Books)
author
(Articles)
Output : Projects the name of author who has either written a book or an article or both.
Attribute inheritance
The attributes of higher level entity set are inherited by lower level entity set.
Aggregation
Aggregation is an abstraction in which relationship sets are treated as higher level entity
sets. Here a relationship set is embedded inside an entity set, and these entity sets can
participate in relationships.
(name, pizzeria) is a
key
Find the names of all females who eat either mushroom or pepperoni pizza (or both).
Find the names of all females who eat both mushroom and pepperoni pizza.
d. Find all pizzerias that serve at least one pizza that Amy eats for less than $10.00.
e.
Find all pizzerias that are frequented by only females or only males.
For each person, find all pizzas the person eats that are not served by any pizzeria the person f
f. (name) / pizza pairs.
g.
h.
i.
Find the names of all people who frequent only pizzerias serving at least one pizza they eat.
Find the names of all people who frequent every pizzeria serving at least one pizza they eat.
Find the pizzeria serving the cheapest pepperoni pizza. In the case of ties, return all of the chea
2. Consider a schema with two relations, R(A, B) and S(B, C), where
all values are integers. Make no assumptions about keys. Consider
the following three relational algebra expressions:
Two of the three expressions are equivalent (i.e., produce the same
answer on all databases), while one of them can produce a different
answer. Which query can produce a different answer? Give the
simplest database instance you can think of where a different
answer is produced.
2. Query (c) is different. Let R = {(3, 4)} and S = {(1, 2)}. Then
query (a) and (b) produce an empty result while (c) produces {(3,
2)}.
4.
https://www.classle.net/book/dbms