CS 5200 Introduction to Database Management Assignment #5

This assignment uses the following XML document for all of the problems:

<edmx:Edmx Version="1.0"
  xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"
  xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
 <edmx:DataServices DataServiceVersion="4.0">
  <edm:Schema Namespace="University">
   <edm:EntityType Name="Student">
    <edm:Key>
     <edm:PropertyRef Name="sid"/>
    </edm:Key>
    <edm:Property Name="major" Type="Edm.String" Nullable="true"/>
    <edm:Property Name="name" Type="Edm.String" Nullable="false"/>
    <edm:Property Name="matriculated" Type="Edm.DateTime" Nullable="true"/>
    <edm:Property Name="sid" Type="Edm.String" Nullable="false"/>
    <edm:Property Name="college" Type="Edm.String" Nullable="false"/>
    <edm:NavigationProperty Name="takes" Relationship="University.takes" FromRole="University.Student" ToRole="University.Section"/>
   </edm:EntityType>
   <edm:EntityType Name="Section">
    <edm:Key>
     <edm:PropertyRef Name="number"/>
    </edm:Key>
    <edm:Property Name="number" Type="Edm.String" Nullable="false"/>
    <edm:NavigationProperty Name="course" Relationship="University.course" FromRole="University.Section" ToRole="University.Course"/>
   </edm:EntityType>
   <edm:EntityType Name="Course">
    <edm:Key>
     <edm:PropertyRef Name="code"/>
    </edm:Key>
    <edm:Property Name="code" Type="Edm.String" Nullable="false"/>
    <edm:Property Name="title" Type="Edm.String" Nullable="false"/>
   </edm:EntityType>
   <edm:EntityContainer Name="University">
    <edm:EntitySet Name="Students" EntityType="University.Student"/>
    <edm:EntitySet Name="Sections" EntityType="University.Section"/>
    <edm:EntitySet Name="Courses" EntityType="University.Course"/>
   </edm:EntityContainer>
  </edm:Schema>
 </edmx:DataServices>
</edmx:Edmx>

In the first two problems of this assignment, the XML document above is the CSDL schema for an OData endpoint at:

  http://tubful.well.edu/registrar

In the other problems of this assignment, the XML document above is just an XML document.

  1. Specify an OData Version 4.0 query to find the following information: Find the courses that are being taken by "Mary".

    http://tubful.well.edu/registrar/Students?$filter=name eq 'Mary'&$expand=takes($expand=course)
    

  2. Specify an OData Version 4.0 query to find the following information: Find the names of all students who are in the "Engineering" college and who are taking the "Databases" course.

    http://tubful.well.edu/registrar/Students?$select=name&$filter=college eq 'Engineering'&$expand=takes($expand=course($filter=title eq 'Databases'))
    

    The following is not correct since the course navigation property is not specified to be single-valued:

    http://tubful.well.edu/registrar/Students?$select=name&$filter=college eq 'Engineering'&$expand=takes($filter=course/title eq 'Databases')
    

  3. Specify an XPath 2.0 query that will retrieve the following information from the XML document above: Get all entity types that have a nullable property named "college".

    There are many solutions. Here is one:

    //edm:EntityType[edm:Property[@Nullable='true'][@Name='college']]
    

    The following is not correct because it assumes that an edm:Property element can only occur within an edm:EntityType element:

    //edm:Property[@Nullable='true'][@Name='college']/..
    

  4. Specify an XPath 2.0 query that will retrieve the following information from the XML document above: Get the name of the key of every entity type with a recursive navigation property. A navigation property is recursive if it associates a type with the same type.

    //edm:EntityType[edm:NavigationProperty[@FromRole=@ToRole]]/edm:Key/edm:PropertyRef/@Name
    

For scoring see the rubric.