Dbms (St1) Solution
Dbms (St1) Solution
Printed Pages:
Session: 2024-25
Semester: 5th
Course Code: BCS 501 Roll No.:
Course Name: Database Management System Time: 75 Minutes
Maximum Marks: 30
Instructions:
1. Attempt All sections.
2. If require any missing data, then choose suitably.
Q. Question Marks CO KL PI
No.
Section-A Total Marks : 20
1 Attempt ANY ONE part from the following
a) 5 CO1 K2 1.4.1
Discuss three level of abstractions or schemas architecture of DBMS.
b) 5 CO1 K2 1.4.1
b) 5 CO1 K2 1.4.1
PLAYER(Pname)
TEAM(Tname)
GAME(Game#, Date, Time, Field, Key)
PLAYS_FOR(Pname, Tname, StartDate, EndDate)
PARTICIPATES(Pname, Game#, Performance)
HOME_TEAM(Game#, Tname, Inning, Runs, Hits, Errors, FinalScore)
AWAY_TEAM(Game#, Tname, Inning, Runs, Hits, Errors, FinalScore)
Write the relational algebra expressions to return the set of elds who own all the brands?
a) 5 CO2 K3 2.2.3
[Gate 2014]
Hierarchical Database Model, as the name suggests, is a database model in which the data is arranged in a hierarchical
tree edifice. As it is arranged based on the hierarchy, every record of the data tree should have at least one parent,
and each parent should have one or more child records, except for the child records in the last level. The Data can be
accessed by following through the classified structure, always initiated from the Root or the first parent. Hence this
model is named as Hierarchical Database Model.
Hierarchical database model is one of the oldest database models, which originated in 1950. One of the first
hierarchical database model was Information Management System developed by North American Rockwell company
and IBM.
In this model, data is stored in the form of records which are the collection of fields. The records are connected
through links. Each field in a record can contain only one value. The first node of the tree is called the root node. When
data needs to be retrieved, then the whole tree is traversed starting from the root node. This model can represent only
one-to-many relationships. It is not able to represent many-to-many relationships. (Note:- we will study relationships
in detail later in the course)
Let us take an example of college students who take different courses. A course can be assigned to a student, but a
student can take as many courses as they want.
Example:
It does not indicate the relationships and cannot answer the following queries:
What are the courses being offered by a faculty?
What are the courses being attended by a student?
Whom are the students being taught by a faculty?
Whom are the faculty teaching a student?
As shown in Figure. 1.7(a), when one course is taken by more than one student, then we need to replicate the student
record. As shown in the above example, Anil has registered for courses Java and Python and thus, the record of Anil is
repeated twice. Also, we can see that record of Rohan has also appeared twice in this model. It leads to the
redundancy of data. The same hierarchical structure can be represented for the link course to teacher shown in Figure
1.7(b).
A Hierarchical database model was widely used during the Mainframe Computers Era. Today, it is used mainly for
storing file systems and geographic information. It is used in applications where high performance is required, such as
telecommunications and banking. A hierarchical database is also used for Windows Registry in the Microsoft Windows
operating system. It is useful where the following two conditions are met:
1. The data should be in a hierarchical pattern, i.e., a parent-child relationship must be present.
2. The data in a hierarchical pattern must be accessed through a single path only.
Advantages:
Simplicity: It is conceptually simple due to the parent-child relationship. A clear chain of command or
authority is there. Data can be retrieved easily due to the explicit links present between the table
structures.
Data Integrity: Referential integrity is always maintained, i.e., any changes made in the parent table are
automatically updated in a child table.
Data Security: It is provided and enforced by DBMS.
Efficiency: It is efficient when a large number of one-to-many relationships exist in a database
Limitations:
A child record cannot be created if it is not linked to any parent record. In our example above, we cannot
create a course until it is opted by any student.
M: N relationship (many-to-many) is not supported.
Redundancy can result in data inconsistency.
Change in structure leads to change in all application programs.
No data manipulation language or data definition language.
Poor flexibility
Rigid structure
2. Network Model
The network model replaces the hierarchical tree with a graph, thus allowing more general connections among the
nodes. It allows a record to have more than one parent and multiple child records, thus permits many-to-many
relationships. The network model was adopted by the Conference on Data System Language (CODASYL) Data Base Task
Group in 1969 and underwent a major update in 1971. The operations on the network model are done with the help of
the circular linked list. A child node in the network model can have more than one parent record, as shown in Figure
1.8.
Example:
An example of a network model, as shown in Figure 1.9, shows that the record of Anil has two parent records Python
and Java. Similarly, the record of Rohan has two parent records of record type Course. It reduces the redundancy of
data as depicted in Figure 1.7(a), showing hierarchical structure storing the same set of records.
Limitations:
Implementation Complexity: It requires the knowledge of actual physical data storage for navigational data
access. The database administrators, designers, programmers, and even the end-users should be familiar
with the internal data structure. It can't be used to create user-friendly DBMS.
Absence of structural Independence: The data access method is navigational, which makes structural
change very difficult and impossible in most cases. So if changes are made in the database structure, then
all the application programs need to be modified.
Any change like updation, deletion, insertion is very complex.
The data operation like retrieval, deletion, and insertion is very complex because of the graph structure. The
network model uses the graph structure for data storage.
3. Relational Model
The relational model was introduced in 1970 by E. F. Codd (of IBM) in his landmark paper “A Relational Model of Data
for Large Shared Databanks” (Communications of the ACM, June 1970, pp. 377−387). The relational model foundation
is a mathematical concept known as a relation. A relation is also called a table, as a matrix composed of intersecting
rows and columns. These tables represent both data and relationships amongst the data. Each table corresponds to an
application entity. Each row in a relation is called a tuple and represents an instance of that entity. Each column
represents an attribute. The relational model also describes a precise set of data manipulation constructs based on
advanced mathematical concepts.
The relational data model is implemented through a very sophisticated relational database management system
(RDBMS). The RDBMS performs the same basic functions provided by the hierarchical and network DBMS systems, in
addition to other functions. Figure 1.10, shows a relational model corresponding to the network model of records
Course, Teacher and Student.
Relation Attributes
Student : (S_id, S_name, S_age)
Course : (C_id, C_name)
Teacher : (T_id, T_name)
Teacher Course : (T_id, S_id)
Student Course: (S_id, C_id)
According to DB-Engines, in January 2021, the most widely used systems were Oracle, MySQL (free software),
Microsoft SQL Server, PostgreSQL (Open Source, a continuation development after INGRES), IBM DB2, SQLite (free
software), Microsoft Access, MariaDB (free software), Teradata, Microsoft Azure SQL Database, Apache Hive (free
software; specialized for data warehouses)
According to research company Gartner, in 2011, the five leading proprietary software relational database vendors by
revenue were Oracle (48.8%), IBM (20.2%), Microsoft (17.0%), SAP including Sybase (4.6%), and Teradata (3.7%).[24]
Advantages:
Structural independence is promoted using independent tables. Database users need not be familiar with
internal data storage.
The tabular view improves conceptual simplicity. Database designers need to focus on logical design rather
than knowing the physical data storage details.
Ad hoc query capability is based on SQL. SQL is 4GL which permits the user to specify only what needs to be
done without specifying how it will be done.
Isolates the end-user from physical-level details
Improves implementation and management simplicity
Precision: The usage of relational algebra and relational calculus in the manipulation.
Limitations:
Requires substantial hardware and system software overhead: It requires more powerful hardware and also
physical storage devices to hide the complexity of implementation and data storage.
Conceptual simplicity gives untrained people the tools to use a good system poorly. Poor database design
degrades the performance when the database grows and it slows down a system.
May promote information problems, i.e., information island phenomenon. As relational data model is easy
to use, thus many departments may create their own database application, which creates the problem in
integrating information and may create the issues of data inconsistency, redundancy, duplication, etc.
Few relational databases have limits on the length of fields. It cannot be exceeded to accommodate more
information.
There are some database model that extends the concept of object-oriented programming are discussed below in
brief. The detailed discussion on these models is beyond the scope of this book.
Relational database models may fail to handle the needs of complex information systems. The problem with RDBMS is
that they force an information system to model into form of tables. Increasingly complex real-world problems
demonstrated a need for a data model that more closely represented the real world. In the object-oriented data model
(OODM), both data and their relationships are contained in a single structure known as an object. Object oriented
models represents an entity as a class and its instance as an object. A class represents both attributes and the behavior
of an entity. Object-oriented data models can typically be represented using Unified Modeling Language (UML) class
diagrams. It is used to represent data and their relationships. Some object-oriented databases are designed to work
well with object-oriented programming languages such as Delphi, Ruby, Python, JavaScript, Perl, Java, C#, Visual Basic
.NET, C++, Objective-C and Smalltalk; others such as JADE have their own programming languages
Advantages:
a. Capability to handle large number of different data types. It can store any type of data including text, numbers,
pictures, voice and video.
b. Object oriented programming with database technology
c. Semantic content is added.
d. Object oriented features improve productivity: Inheritance, Polymorphism and Dynamic binding
Limitations:
a. Difficult to maintain
b. Not suited for all applications.
Object relational systems combine the advantages of modern object oriented programming languages with relational
database features such as multiple views of data and a high-level, non-procedural query language. Relational database
systems are being enhanced by adding an object infrastructure to the database system itself, in the form of user
defined data types, functions and rules and by building relational extenders that support specialized applications as
image retrieval, advanced text searching and geographic applications. PostgreSQL is an Object-Relational Database
Management System.
Advantages:
a. Complex data sets can be saved and retrieved quickly and easily.
b. Works well with object-oriented programming languages.
Limitations:
a. Object databases are not widely adopted.
b. In some situations, the high complexity can cause performance problems.
c. High system overhead slows transactions
d. Ans 4A
1. Domain Integrity-
Domain integrity means the definition of a valid set of values for an attribute. You define data type, length or size, is null value allowed , is the value unique or not for an attribute ,the
default value, the range (values in between) and/or specific values for the attribute.
EXAMPLE- Consider a relation "STUDENT" Where "Stu_id" is a primary key and it must not contain any null value whereas other attributes may contain null value e.g "Branch"
in the following relation contains one null value.
11255324 Ajay ME
1. You can't delete a record from a primary table if matching records exist in a related table.
2. You can't change a primary key value in the primary table if that record has related records.
3. You can't enter a value in the foreign key field of the related table that doesn't exist in the primary key
of the primary table.
4. However, you can enter a Null value in the foreign key, specifying that the records are unrelated.
Ans 4B
Select Operation (σ)
It selects tuples that satisfy the given predicate from a relation.
Notation − σp(r)
Where σ stands for selection predicate and r stands for relation. p is prepositional logic formula 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' and 'price' is 450.
Output − Selects tuples from books where subject is 'database' and 'price' is 450 or those books published after 2010.
For example −
Selects and projects columns named as subject and author from the relation Books.
EXAMPLE-
Consider 2 relations "stu" and "stu_1" Where "Stu_id " is the primary key in the "stu" relation and foreign key in the "stu_1" relation.
Relation "stu"
11255324 Ajay ME
Rule 2. You can't change any of the ”Stu_id” in the “stu” relation since all the “Stu_id” are in use in the ”stu_1” relation. * Rule 3.* The values that you can enter in
the” Stu_id” field in the “stu_1” relation must be in the” Stu_id” field in the “stu” relation.
Rule 4 You can enter a null value in the "stu_1" relation if the records are unrelated.