Professional Documents
Culture Documents
Answer
Answer
(a) Draw the EER (extended ER) diagram for the above problem showing
all entities, attributes and relationship. Also identify multivalued and
derived attributes.
Answer : -
(b) Draw the appropriate tables and relationship among the tables for
the above diagram and normalize the tables up to 3NF.
Answer : -
Generalization
Generalization is like a bottom-up approach in which two or more entities of lower level
combine to form a higher level entity if they have some attributes in common.
Aggregation
(d) Identify weak entity sets in the above diagram if any. Show how will
you convert a weak entity set to a strong entity set? What is the need of
such task?
Answer : - weak entity set is an entity set that does not contain sufficient attributes to
uniquely identify its entities. In other words, a primary key does not exist for a weak
entity set.
In the above EER-Diagram exam_schedule representated as a weak entity, because no
Primary Key is present in this table.
exam_schedule (c_code, exam_date, exam_time)
A multivalued dependency consists of at least two attributes that are dependent on a third
attribute that's why it always requires at least three attributes.
(f) Create an XML schema for the grade card to be issued by the division
having details : student id, programme code, course id, grade, consumer
name, assignments marks, TEE marks and grade.
Answer : -
GradeCard.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.questionsolves.com"
xmlns="http://www.questionsolves.com"
elementFormDefault="qualified">
<xs:element name="GradeCard">
<xs:complexType>
<xs:sequence>
<xs:element name="StudentId" type="xs:integer"/>
<xs:element name="StudentName" type="xs:string"/>
<xs:element name="ProgrammeCode" type="xs:string"/>
<xs:element name="Course" maxOccurs="unbounded"/>
<xs:complexType>
<xs:sequence>
<xs:element name="CourseCode" type="xs:string"/>
<xs:element name="AssignmentMarks" type="xs:integer"/>
<xs:element name="TEEMarks" type="xs:integer"/>
<xs:element name="Grade" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
GradeCard.xml
<?xml version="1.0"?>
<GradeCard
xmlns="http://www.questionsolves.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.questionsolves.com
GradeCard.xsd">
<StudentId>105508022</StudentId>
<StudentName>Debabrata Panchadhyay</StudentName>
<ProgrammeCode>MCA</ProgrammeCode>
<Course>
<CourseCode>MCS-042</CourseCode>
<AssignmentMarks>90</AssignmentMarks>
<TEEMarks>68</TEEMarks>
<Grade>B</Grade>
</Course>
<Course>
<CourseCode>MCS-043</CourseCode>
<AssignmentMarks>85</AssignmentMarks>
<TEEMarks>42</TEEMarks>
<Grade>D</Grade>
</Course>
</GradeCard>
XML is self-describing
A given document contains not only the data, but also the necessary metadata. As a
result, an XML document can be searched or updated without requiring a static
definition of the schema. Relational models, on the other hand, require more static
schema definitions. All the rows of a table must have the same schema.
XML is hierarchical
A given document represents not only base information, but also information about
the relationship of data items to each other in the form of the hierarchy. Relational
models require all relationship information to be expressed either by primary key
or foreign key relationships or by representing that information in other relations.
XML is sequence-oriented order
For an XML document, the order in which data items are specified is assumed to be
the order of the data in the document. There is often no other way to specify order
within the document. For relational data, the order of the rows is not guaranteed
unless you specify an ORDER BY clause on one or more columns.
Other factors might influence your decision about which model to use. Some of those
factors are :
Query
SELECT * FROM department INNER JOIN employee ON
employee.dept_id=department.dept_id FOR XML AUTO, ELEMENTS;
Output :
<department>
<dept_id>102</dept_id>
<dept_name>HTML and Graphics</dept_name>
<employee>
<emp_id>E-0005</emp_id>
<emp_name>Subhadip Giri</emp_name>
<salary>45000</salary>
<dept_id>102</dept_id>
</employee>
</department>
<department>
<dept_id>105</dept_id>
<dept_name>DOT NET</dept_name>
<employee>
<emp_id>E-0020</emp_id>
<emp_name>Amit Das</emp_name>
<salary>65000</salary>
<dept_id>105</dept_id>
</employee>
<employee>
<emp_id>E-0085</emp_id>
<emp_name>Sohini Das</emp_name>
<salary>40000</salary>
<dept_id>105</dept_id>
</employee>
</department>
--Insert the xml data into our department table (dept_id, dept_name)
INSERT INTO department(dept_id, dept_name)
SELECT
Q4. What are views? What is their significance in DBMS? How are views
created in SQL? Explain the concept with the help of an example
pertaining to the design of University’s examination system (refer to Q1)
Answer : -
Syntax :
Q5. Discuss the algorithm and the related cost of performing Selection
operation.
Answer : - The selection operation can be performed in a number of ways. Let us discuss
the algorithms and the related cost of performing selection operations.
File Scan - Based on the filter condition, the file is traversed and the records are
fetched in this method. The following are the two basic files scan algorithms for
selection operation :
1. Linear search - This algorithm scans each file block and tests all records to
see whether they satisfy the selection condition.
Cost = [log2 BR] + [average number of tuples with the same value of the
relation / blocking factor (Number of tuples in a block) of the relation]
Index Scan - This method of selection uses indexes to traverse the record. The
search key should be indexed and should be used in the filter condition for an Index
scan to work.
1. Primary Key index with equality - This search retrieves a single record that
satisfies the corresponding equality condition. For example, SELECT * FROM
student WHERE enrolment_no = 105508022;
Cost = Height traversed in index to locate the block pointer + 1 (block of the
primary key is transferred for access).
2. Primary key index with comparison - In this method comparison operators
like <, <=, >, and >= are used to retrieved more than one record from the file.
This comparison operator is used on the primary key, on which index is also
created.
Cost = Number of block transfer to locate the value in index + Transferring all
the blocks of data satisfying that condition.
Disjunction - This is the reference to the conditions in the WHERE clause combined
with OR operator. This is even considered as queries with UNION operator.
For example,
or
Negation - It has not equal condition used in the WHERE clause. In most of the cases
it uses the linear search method to fetch the records. If the index is present on the
search key column then index is used search the records.
The most commonly used concurrency protocol is the timestamp based protocol. This
protocol uses either system time or logical counter as a timestamp.
Lock-based protocols manage the order between the conflicting pairs among transactions
at the time of execution, whereas timestamp-based protocols start working as soon as a
transaction is created.
These algorithms ensure that transactions commit in the order dictated by their
timestamps. An older transaction should commit before a younger transaction, since the
older transaction enters the system before the younger one.
Access Rule - When two transactions try to access the same data item
simultaneously, for conflicting operations, priority is given to the older transaction.
This causes the younger transaction to wait for the older transaction to commit
first.
Late Transaction Rule - If a younger transaction has written a data item, then an
older transaction is not allowed to read or write that data item. This rule prevents
the older transaction from committing after the younger transaction has already
committed.
Younger Transaction Rule - A younger transaction can read or write a data item
that has already been written by an older transaction.
Rule 1 - Given two transactions T1 and T2, if T1 is reading the data item which T2 is
writing, then T1’s execution phase cannot overlap with T2’s commit phase. T2 can
commit only after T1 has finished execution.
Rule 2 - Given two transactions T1 and T2, if T1 is writing the data item that T2 is
reading, then T1’s commit phase cannot overlap with T2’s execution phase. T2 can
start executing only after T1 has already committed.
Rule 3 - Given two transactions T1 and T2, if T1 is writing the data item which T2 is
also writing, then T1’s commit phase cannot overlap with T2’s commit phase. T2
can start to commit only after T1 has already committed.
For implementing timestamp ordering algorithms, each site has a scheduler that
maintains a separate queue for each transaction manager. During transaction, a
transaction manager sends a lock request to the site’s scheduler. The scheduler puts the
request to the corresponding queue in increasing timestamp order. Requests are
processed from the front of the queues in the order of their timestamps, i.e. the oldest
first.
Rule 1 - According to this rule, a transaction must be validated locally at all sites
when it executes. If a transaction is found to be invalid at any site, it is aborted.
Local validation guarantees that the transaction maintains serializability at the sites
where it has been executed. After a transaction passes local validation test, it is
globally validated.
Rule 2 - According to this rule, after a transaction passes local validation test, it
should be globally validated. Global validation ensures that if two conflicting
transactions run together at more than one site, they should commit in the same
relative order at all the sites they run together. This may require a transaction to
wait for the other conflicting transaction, after validation before commit. This
requirement makes the algorithm less optimistic since a transaction may not be
able to commit as soon as it is validated at a site.
In this example, the highest level shows the entire database. The levels below are file,
record, and fields.
In the 2-phase locking protocol, shared (S) and exclusive (X) lock modes are used, but
there are three additional lock modes with multiple granularity :
Intention-shared (IS) - It contains explicit locking at a lower level of the tree but
only with shared locks.
Intention-Exclusive (IX) - It contains explicit locking at a lower level with exclusive
or shared locks.
Shared & Intention-Exclusive (SIX) - In this lock, the node is locked in shared
mode, and some node is locked in exclusive mode by the same transaction.
IS IX S SIX X
IS true true true true false
IX true true false false false
S true false true false false
SIX true false false false false
X false false false false false
The multiple-granularity locking protocol uses the intention lock modes to ensure
serializability. It requires that a transaction Ti that attempts to lock a node must follow
these protocols :
Observe that in multiple-granularity, the locks are acquired in top-down order, and locks
must be released in bottom-up order.
If transaction T1 reads record Ra2 in file Fa, then transaction T1 needs to lock the
database, area A1 and file Fa in IX mode. Finally, it needs to lock Ra2 in S mode.
If transaction T2 modifies record Ra9 in file Fa, then it can do so after locking the
database, area A1 and file Fa in IX mode. Finally, it needs to lock the Ra9 in X mode.
If transaction T3 reads all the records in file Fa, then transaction T3 needs to lock the
database, and area A1 in IS mode. At last, it needs to lock Fa in S mode.
If transaction T4 reads the entire database, then T4 needs to lock the database in S
mode.
Note that transactions T1, T3 and T4 can access the database concurrently. Transaction T2
can execute concurrently with T1, but not with either T3 or T4.
Q9. What are the characteristics of multimedia & mobile databases?
Explain the design challenges of these database?
Answer : -
Multimedia Databases
Media data - This is the multimedia data that is stored in the database such as
images, videos, audios, animation etc.
Media format data - Information about the format of the media data after it goes
through the acquisition, processing, and encoding phases.
Media keyword data - This contains the keyword data related to the media in the
database. For an image the keyword data can be date and time of the image,
description of the image etc.
Media feature data - Content dependent data such as the distribution of colors,
kinds of texture and different shapes present in data.
Mobile Databases
Mobile computing devices (example - smartphones and PDAs) store and share data over a
mobile network, or a database which is actually stored by the mobile device. This could be
a list of contacts, price information, distance travelled, or any other information.
Many applications require the ability to download information from an information
repository and operate on this information even when out of range or disconnected. An
example of this is your contacts and calendar on the phone. In this scenario, a user would
require access to update information from files in the home directories on a server or
customer records from a database. This type of access and work load generated by such
users is different from the traditional workloads seen in client–server systems of today.
Mobile users must be able to work without a network connection due to poor or even non-
existent connections. A cache could be maintained to hold recently accessed data and
transactions so that they are not lost due to connection failure. Users might not require
access to truly live data, only recently modified data, and uploading of changing might be
deferred until reconnected.
Limited Resources - The CPU power and storage of mobile devices is continuously
increasing. However, they are far behind non-mobile systems such as servers on the
Internet. Due to the size of the database, limited CPU power and storage capacity,
mobile device need to perform simple operations on local data available in cache.
Limited storage capacity also makes it difficult to cache entire databases to a mobile
device.
Power Consumption - The most prominent limitation of mobile device is power.
These devices rely entirely on battery power. Combined with the compact size of
many mobile devices, this often means unusually expensive batteries must be used
to obtain the necessary battery life.
Disconnection - Weather, terrain, and the range from the nearest signal point can
all interfere with signal reception. Reception in tunnels, some buildings, and rural
areas is still poor. Interaction between a mobile device and a database is directly
affected by the device’s network connectivity. The two solutions approach to this
disconnection challenges are : 1) Prevent disconnections, 2) Cope with
disconnections. For mobile computers, allowing disconnections to happen and
recovering from them is the better solution for asynchronous operation caching
and reconciliation.
Insufficient Bandwidth - Mobile access is generally slower than direct cable
connections. Using technologies such as GPRS and EDGE, and more recently 3G
networks, bandwidth has been increased but still less compared to the wired
network. Asymmetry problem is faced when bandwidth in the downstream
direction is often much greater than bandwidth in the upstream direction.
Limited Storage - Due to mobility and portability, the sizes of memory and hard
drive are smaller than the ones in the wired network. The consequences of this are
less stored/cached/replicated data, fewer installed applications, and more
communication.
Q10. What is assertion rule mining? Write apriority algorithm for finding
frequency item set. Discuss it with suitable examples.
Answer : - Solve it Yourself
Q11. Draw a simple Use case and a class diagram for a university’s
examination system.
Answer : -