Assignment: XML | Database Management System (DBMS) - Software Development PDF Download

Multiple Choice Questions (MCQs)

Q.1. Which of the following is true about XML in DBMS?
(a)
XML is a relational database management system.
(b) XML stands for Extensible Markup Language.
(c) XML is used for writing computer programs.
(d) XML is not compatible with web technologies.

Ans. (b)

Q.2. What does DTD stand for in XML?
(a)
Document Type Definition
(b) Data Transfer Description
(c) Database Transaction Declaration
(d) Dynamic Text Display

Ans. (a)

Q.3. Which of the following is not a valid XML tag?
(a) 
<book>
(b) <123>
(c) <first_name>
(d) <item_1>

Ans. (b)

Q.4. In XML, what does the attribute do?
(a)
Specifies the data type of an element.
(b) Defines a unique identifier for an element.
(c) Provides additional information about an element.
(d) Allows nested elements within an element.

Ans. (c)

Q.5. Which query language is used to retrieve data from XML in a DBMS?
(a) 
SQL
(b) XML-RPC
(c) XPath
(d) JSON

Ans. (c)

HOTS (Higher Order Thinking Skills)

Q.1. Explain the concept of XML in the context of a DBMS.

XML (Extensible Markup Language) is a markup language that allows users to define their own tags and structure for representing data. In the context of a DBMS, XML is used to store and exchange structured information between different systems. It provides a flexible and self-describing format for representing data, making it easier to integrate heterogeneous systems.

Q.2. Discuss the advantages and disadvantages of using XML in a DBMS.

Advantages of using XML in a DBMS:

  • Flexibility: XML allows the definition of custom tags and structure, making it adaptable to different data formats.
  • Self-describing: XML documents contain both the data and its structure, making it easier to understand and process the information.
  • Platform independence: XML can be used across different platforms and operating systems.
  • Interoperability: XML enables data exchange between different systems and applications.

Disadvantages of using XML in a DBMS:

  • Overhead: XML documents can be larger in size compared to other data formats, leading to increased storage and processing requirements.
  • Complexity: XML syntax and concepts can be complex, requiring additional effort to create and process XML documents.
  • Performance: Processing and querying XML documents can be slower compared to traditional relational databases.
  • Lack of standardization: XML allows flexibility in defining structure and tags, which can lead to inconsistencies and difficulties in data integration.

Q.3. How can XML be used to represent hierarchical data in a DBMS? Give an example.

XML represents hierarchical data through nested elements. Each nested element represents a parent-child relationship. For example, consider a company with departments and employees.
The XML representation could be as follows:

<company>

  <department>

    <name>Marketing</name>

    <employee>

      <name>John Doe</name>

      <position>Marketing Manager</position>

    </employee>

    <employee>

      <name>Jane Smith</name>

      <position>Marketing Assistant</position>

    </employee>

  </department>

  <department>

    <name>Finance</name>

    <employee>

      <name>David Johnson</name>

      <position>Finance Manager</position>

    </employee>

    <employee>

      <name>Emily Brown</name>

      <position>Accountant</position>

    </employee>

  </department>

</company>

Q.4. What is the role of DTD in XML? How does it ensure data integrity?

DTD (Document Type Definition) is used to define the structure, elements, and data types for an XML document. It ensures data integrity by specifying the allowed elements, their order, and the data types for attributes and values. DTD acts as a contract or blueprint for the XML document, validating its structure against the defined rules. If the XML document doesn't comply with the DTD, it is considered invalid.

Q.5. Compare and contrast XML with JSON in terms of their usage in DBMS.

XML and JSON are both popular formats for representing structured data. However, they have some differences:

  • Syntax: XML uses tags and angle brackets (<>) to define elements, while JSON uses braces ({}) and square brackets ([]).
  • Readability: XML tends to be more verbose and has a higher overhead due to its tag-based structure, while JSON is more concise and easier to read for humans.
  • Data types: XML supports a wider range of data types, including text, numbers, dates, and booleans. JSON has a limited set of data types, primarily strings, numbers, booleans, and null.
  • Parsing and processing: XML requires an XML parser to process the data, while JSON can be easily parsed using built-in functions in many programming languages.
  • Usage: XML has been widely used in various industries and has been the standard for a long time, especially in areas like data exchange and web services. JSON gained popularity with the rise of web APIs and is often used in web development and JavaScript-based applications.

Fill in the blanks

1. In XML, the opening and closing tags must be __________.

balanced

2. __________ defines the structure, elements, and data types for an XML document.

Document Type Definition

3. XML allows the use of __________ to store metadata about the data.

attributes

4. XPath is a query language used to __________ XML documents.

traverse

5. XML provides a __________ way to represent data that is self-describing.

self-describing

True/False

1. XML is a markup language used to describe data. 

True

2. XML is a replacement for HTML in web development.

False

3. The opening and closing tags in XML must be the same.

True

4. XML data can be easily queried and manipulated using XPath.

True

5. DTD is optional in XML and not necessary for defining the structure of the document. 

False

Hands-On Questions

Q.1. Create an XML document to represent a bookstore with two books. Each book should have attributes for title, author, and price.

XML document representing a bookstore with two books:

<bookstore>

  <book title="Book 1" author="Author 1" price="10" />

  <book title="Book 2" author="Author 2" price="15" />

</bookstore>

Q.2. Write an XPath expression to select all the book elements with a price greater than $20 from the XML document given below:

<bookstore>

  <book>

    <title>Book 1</title>

    <author>Author 1</author>

    <price>15</price>

  </book>

  <book>

    <title>Book 2</title>

    <author>Author 2</author>

    <price>25</price>

  </book>

  <book>

    <title>Book 3</title>

    <author>Author 3</author>

    <price>30</price>

  </book>

</bookstore>

XPath expression to select book elements with a price greater than $20:

/bookstore/book[price > 20]

Q.3. Explain the concept of well-formedness in XML and provide an example of a well-formed XML document.

Well-formedness in XML refers to the correctness of the XML document's syntax and structure. A well-formed XML document must adhere to the following rules:

  • The opening and closing tags must be balanced and properly nested.
  • Attribute values must be enclosed in quotes.
  • Reserved characters like '<' and '&' must be properly escaped.
  • Empty elements should be self-closing.

Example of a well-formed XML document:

<bookstore>

  <book>

    <title>Book 1</title>

    <author>Author 1</author>

    <price>10</price>

  </book>

  <book>

    <title>Book 2</title>

    <author>Author 2</author>

    <price>15</price>

  </book>

</bookstore>

Q.4. Discuss the concept of XML namespaces and how they are used in XML documents.

XML namespaces are used to avoid naming conflicts when multiple XML vocabularies are combined in a single document or when integrating XML with other technologies. Namespaces allow elements and attributes to be uniquely identified by associating them with a specific namespace URI (Uniform Resource Identifier). By using namespaces, elements and attributes with the same local name can coexist without conflicts.

Q.5. Write a DTD declaration to define the structure of an XML document for a student database. The database should include elements for student ID, name, age, and grade.

DTD declaration for a student database XML document:

<!DOCTYPE student_database [

  <!ELEMENT student_database (student*)>

  <!ELEMENT student (id, name, age, grade)>

  <!ELEMENT id (#PCDATA)>

  <!ELEMENT name (#PCDATA)>

  <!ELEMENT age (#PCDATA)>

  <!ELEMENT grade (#PCDATA)>

]>

This DTD declaration defines a student database containing multiple student elements. Each student element should have child elements for id, name, age, and grade, each represented as PCDATA (Parsed Character Data). The '*' symbol after the 'student' element indicates that multiple student elements are allowed in the database.

The document Assignment: XML | Database Management System (DBMS) - Software Development is a part of the Software Development Course Database Management System (DBMS).
All you need of Software Development at this link: Software Development
75 videos|44 docs

Top Courses for Software Development

75 videos|44 docs
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Exam

,

Free

,

practice quizzes

,

Semester Notes

,

Viva Questions

,

Summary

,

Previous Year Questions with Solutions

,

ppt

,

Sample Paper

,

shortcuts and tricks

,

Important questions

,

past year papers

,

Assignment: XML | Database Management System (DBMS) - Software Development

,

video lectures

,

study material

,

Extra Questions

,

pdf

,

Objective type Questions

,

Assignment: XML | Database Management System (DBMS) - Software Development

,

Assignment: XML | Database Management System (DBMS) - Software Development

,

MCQs

,

mock tests for examination

;