Dbms Imp Answers
Dbms Imp Answers
1.Compare DBMS and early file systems bringing out the major advantages of the
database approach.
A.
2 Explain different types of attributes in ER model with suitable examples for each.
A.
In DBMS, there are various types of attributes available:
Simple Attributes
Composite Attributes
Single Valued Attributes
Multi-Valued Attributes
Derived Attributes
Complex Attributes (Rarely used attributes)
Key Attributes
Stored Attributes
Now, we will study all of these different types of attributes in DBMS in detail along with
their diagrams and examples :)
Simple Attributes
Simple attributes in an ER model diagram are independent attributes that can't be
classified further and also, can't be subdivided into any other component. These
attributes are also known as atomic attributes.
Example Diagram:
As we can see in the above example, Student is an entity represented by a rectangle, and
it consists of attributes: Roll_no, class, and Age. Also, there is a point to be noted that we
can't further subdivide the Roll_no attribute and even the other two attributes into sub-
attributes. Hence, they are known as simple attributes of the Student entity.
Composite Attributes
Composite attributes have opposite functionality to that of simple attributes as we can
further subdivide composite attributes into different components or sub-parts that form
simple attributes. In simple terms, composite attributes are composed of one or more
simple attributes.
Example Diagram
As we can see in the above example, Address is a composite attribute represented by an
elliptical shape, and it can be further subdivided into many simple attributes like Street,
City, State, Country, Landmark, etc.
Single-Valued Attributes
Single valued attributes are those attributes that consist of a single value for each entity
instance and can't store more than one value. The value of these single-valued attributes
always remains the same, just like the name of a person.
Example Diagram:
As we can see in the above example, Student is an entity instance, and it consists of
attributes: Roll_no, Age, DOB, and Gender. These attributes can store only one value from
a set of possible values. Each entity instance can have only one Roll_no, which is a unique,
single DOB by which we can calculate age and also fixed gender. Also, we can't further
subdivide these attributes, and hence, they are simple as well as single-valued
attributes.
Multi-Valued Attributes
Multi-valued attributes have opposite functionality to that of single-valued attributes, and
as the name suggests, multi-valued attributes can take up and store more than one value
at a time for an entity instance from a set of possible values. These attributes are
represented by co-centric elliptical shape, and we can also use curly braces { }to
represent multi-valued attributes inside it.
Example Diagram:
As we can see in the above example, the Student entity has four attributes: Roll_no and
Age are simple as well as single-valued attributes as discussed above but Mob_noand
Email_idare represented by co-centric ellipse are multi-valued attributes.Each student
in the real world can provide more than one email-id as well as a mobile contact number,
and therefore, we need these attributes to be multi-valued so that they can store multiple
values at a time for an entity instance.
Derived Attributes
Derived attributes in DBMS are those attributes whose values can be derived from the
values of other attributes. They are always dependent upon other attributes for their
value.
For example,As we were discussing above, DOB is a single-valued attribute and remains
constant for an entity instance. From DOB, we can derive the Age attribute, which changes
every year, and can easily calculate the age of a person from his/her date of birth value.
Hence, the Age attribute here is derived attribute from the DOB single-valued attribute.
Example Diagram:
Derived attributes are always represented by dashed or dotted elliptical shapes.
Key Attributes
Key attributes are special types of attributes that act as the primary key for an entity and
they can uniquely identify an entity from an entity set. The values that key attributes store
must be unique and non-repeating.
Example Diagram:
As we can see in the above example, we can say that the Roll_noattribute of the Student
entity is not only simple and single-valued attribute but also, a key valued attribute as
well. Roll_noof a student will always be unique to identify the student. Also note that the
Genderand Age of two or more persons can be same and overlapping in nature and
obviously, we can't identify a student on the basis of them. Hence, genderand ageare not
key-valued attributes.
Complex Attributes
Complex attributes are rarely used in DBMS. They are formed by the combination of multi-
valued and composite attributes. These attributes always have many sub-sections in their
values.
Example Diagram:
Stored Attributes
Values of stored attributes remain constant and fixed for an entity instance and also, and
they help in deriving the derived attributes. For example,the Age attribute can be derived
from the Date of Birth attribute, and also, the Date of birth attribute has a fixed and
constant value throughout the life of an entity. Hence, the Date of Birth attribute is a
stored attribute.
Example Diagram:
As we can see in the above image, there are different types of attributes in DBMS, well
slotted for each field for an entity instance.
This constraint specifies the number of instances of an entity that can participate in a
relationship type.
Total Participation
Each entity in the entity set is involved in at least one relationship in a relationship set
i.e. the number of relationship in every entity is involved is greater than 0.
Consider two entities Employee and Department related via Works_For relationship.
Now, every Employee works in at least one department therefore an Employee entity
exist if it has at least one Works_For relationship with Department entity. Thus the
participation of Employee in Works_For is total relationship.Total Participation is
represented by double line in ER diagram.
Partial Participation
Each entity in entity set may or may not occur in at least one relationship in a
relationship set.
For example: Consider two entities Employee and Department and they are related to
each other via Manages relationship. An Employee must manage a Department, he or
she could be the head of the department. But not every Employee in the company
manages the department. So, participation of employee in the Manages relationship
type is partial i.e. only a particular set of Employees will manage the Department but
not all.
See the example shown in the ERD below; [arrow head side - one side, without arrow –
many side]
A.
6)Draw the ER- Diagram for bus reservation system?
7)Explain data base languages.
Data definition language (DDL) creates the framework of the database by specifying
the database schema, which is the structure that represents the organization of data.
Its common uses include the creation and alteration of tables, files, indexes and
columns within the database. This language also allows users to rename or drop the
existing database or its components. Here's a list of DDL statements:
CREATE:Creates a new database or object, such as a table, index or column
ALTER:Changes the structure of the database or object
DROP:Deletes the database or existing objects
RENAME:Renames the database or existing objects
Data manipulation language (DML) provides operations that handle user requests,
offering a way to access and manipulate the data that users store within a database.
Its common functions include inserting, updating and retrieving data from the
database. Here's a list of DML statements:
INSERT:Adds new data to the existing database table
UPDATE:Changes or updates values in the table
DELETE:Removes records or rows from the table
SELECT:Retrieves data from the table or multiple tables
Data control language (DCL) controls access to the data that users store within a
database. Essentially, this language controls the rights and permissions of the
database system. It allows users to grant or revoke privileges to the database. Here's
a list of DCL statements:
GRANT:Gives a user access to the database
REVOKE:Removes a user's access to the database
8 Define database and what are the responsibilities of the DBA and the database
designers
A.
A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a database
management system (DBMS). Together, the data and the DBMS, along with the
applications that are associated with them, are referred to as a database system, often
shortened to just database.
A.
1. List the Employees who are working in Bangalore.
σ CityName='Bangalore' (Emp)
Explanation: σ (selection) operator is used to filter the tuples from the Emp relation where
the CityName attribute is equal to 'Bangalore'.
2. List the details of female Employees whose salary is greater than 24999.
Explanation: σ operator is used to select the tuples from the Emp relation where the
Gender attribute is equal to 'Female' and the Sal attribute is greater than 24999.
3. Display name, age, city of employees whose id is 202 and age is less than 24.
Explanation: σ operator is used to select the tuples from the Emp relation where the Id
attribute is equal to 202 and the Age attribute is less than 24. Then, π (projection) operator
is used to project the Name, Age, and CityName attributes from the resulting tuples.
Explanation: ⨝ (natural join) operator is used to join the Emp and Role relations based on
the Job_Id attribute. Then, σ operator is used to select the tuples from the resulting join
where the Role attribute is equal to 'Manager'. Finally, π operator is used to project the
Name and Sal attributes from the resulting tuples.
11)Explain about derived operators in Relational Algebra
A.
Derived operators in Relational Algebra refer to additional operators that can be derived
or constructed using the basic operators of Relational Algebra. These derived operators
provide more expressive power and allow for complex queries and operations to be
performed on relational databases. Here are some commonly used derived operators in
the context of DBMS:
1. Union (⋃): The union operator combines tuples from two relations into a single
relation. It returns all distinct tuples that are present in either of the two relations.
2. Intersection (⋂): The intersection operator combines tuples that are common to two
relations. It returns only the distinct tuples that exist in both of the two relations.
3. Difference (-): The difference operator returns tuples that exist in one relation but
not in another. It retrieves the distinct tuples from the first relation that do not
appear in the second relation.
4. Selection (σ): The selection operator allows for specifying conditions to filter or
retrieve specific tuples from a relation. It is used to define a subset of tuples based
on a given condition.
5. Projection (π): The projection operator selects specific attributes or columns from a
relation while discarding the rest. It helps in creating a new relation with a reduced
number of attributes.
6. Join (⨝): The join operator combines tuples from two or more relations based on a
common attribute. It helps in creating a new relation by matching and merging
tuples with matching attribute values.
7. Division (÷): The division operator is used to find tuples that satisfy a certain
condition based on another relation. It retrieves tuples from one relation that, when
combined with each tuple in another relation, produce a complete tuple.
8. Rename (ρ): The rename operator is used to change the name of attributes or
relations in a relation. It allows for assigning more meaningful or descriptive names
to attributes or relations.
UNIQUE Constraint
The UNIQUEconstraint in a column means that the column must have unique value. For
example,
Here, the value of the college_codecolumn must be unique. Similarly, the value of
college_idmust be unique as well as it cannot store NULLvalues.
Here, the value of the college_codecolumn references the row in another table named
Customers.It means that the value of customer_idin the Orderstable must be a value from
the idcolumn of the Customerstable.
CHECK Constraint
The CHECKconstraint checks the condition before allowing values in a table. For example,
Here, the value of the amountcolumn must be greater than or equal to 100. If not, the
SQL statement results in an error.
DEFAULT Constraint
The DEFAULTconstraint is used to set the default value if we try to store NULLin a column.
For example,
14)Discuss different types of anomalies. Why are they considered bad? Illustrate with
Example
A.
There can be three types of an anomaly in the database:
Insertion Anomaly
If there is a new row inserted in the table and it creates the inconsistency in the table then
it is called the insertion anomaly. For example, if in the above table, we create a new row
of a worker, and if it is not allocated to any department then we cannot insert it in the
table so, it will create an insertion anomaly.
Deletion Anomaly
If we delete some rows from the table and if any other information or data which is
required is also deleted from the database, this is called the deletion anomaly in the
database. For example, in the above table, if we want to delete the department number
ECT669 then the details of Rajesh will also be deleted since Rajesh's details are dependent
on the row of ECT669. So, there will be deletion anomalies in the table.
To remove this type of anomalies, we will normalize the table or split the table or join the
tables. There can be various normalized forms of a table like 1NF, 2NF, 3NF, BCNF etc. we
will apply the different normalization schemes according to the current form of the table.
Made with❤️by Telegram @oxrogerthat