Commit 2e398fba authored by Dr. Martin Goik's avatar Dr. Martin Goik

Content part of lectures.xml

parent b0869e53
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" xml:id="sda1_exam_2019_summer" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:trans="http://docbook.org/ns/transclusion"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<info>
<title/>
<author>
<personname/>
</author>
<pubdate/>
</info>
<section xml:id="sda1_exam_2020_summer_task1">
<title>Lecture examinations</title>
<section xml:id="sda1_exam_2020_summer_aufgabe1_prepare">
<title>Preparations</title>
<para>Download and unzip the above file <filename>exam.zip</filename>.
Then:</para>
<orderedlist>
<listitem>
<para>Import the resulting <filename>Exam</filename> Project into
your <productname>IDEA</productname> IDE by choosing »File --&gt;
Open...« subsequently selecting the
<filename>Exam/pom.xml</filename> file.</para>
</listitem>
<listitem>
<para>Also import <filename>Exam</filename> into your
<productname>Oxygenxml</productname> IDE using »Project« --&gt;
»Open Project« subsequently selecting the
<filename>Exam/sda1.xpr</filename> file.</para>
</listitem>
</orderedlist>
</section>
<section xml:id="sda1_exam_2020_summer_aufgabe1_descr">
<title>Description</title>
<caution>
<para>IntelliJ IDEA is partly broken with respect to XML Schema
flagging the subsequent instance as invalid: Use
<productname>Oxygenxml</productname> instead!</para>
</caution>
<para>Consider a company's departments, employees and projects:</para>
<programlisting language="xml">&lt;company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="company.xsd" &gt;
&lt;departments&gt;
&lt;department&gt;
&lt;name&gt;Headquarter&lt;/name&gt;
&lt;member nickname = "jb"&gt;Jim Beam&lt;/member&gt;
&lt;department&gt; &lt;!-- Sub department of »Headquarter« --&gt;
&lt;name&gt;GUI Development&lt;/name&gt;
&lt;member nickname="eg"&gt;Eve Gardener&lt;/member&gt;
&lt;member nickname="pt"&gt;Pete Townsend&lt;/member&gt;
&lt;/department&gt;
&lt;department&gt; &lt;!-- Another sub department of »Headquarter« --&gt;
&lt;name&gt;Database Development&lt;/name&gt;
&lt;member nickname="ls"&gt;Laura Stern&lt;/member&gt;
&lt;/department&gt;
&lt;department&gt;
&lt;name&gt;New stuff&lt;/name&gt;
&lt;!-- No members yet --&gt;
&lt;/department&gt;
&lt;/department&gt;
&lt;/departments&gt;
&lt;projects&gt;
&lt;project slug="GUIGen" visibility="public"&gt;
&lt;name&gt;GUI Generator&lt;/name&gt;
&lt;developers&gt;
&lt;developer member="eg" role="manager"/&gt;
&lt;developer member="jb" role="guest"/&gt;
&lt;/developers&gt;
&lt;/project&gt;
&lt;project slug="dbSchemaGen" visibility="internal"&gt;
&lt;name&gt;Database Schema Generator&lt;/name&gt;
&lt;developers&gt;
&lt;developer member="pt" role="developer"/&gt;
&lt;/developers&gt;
&lt;/project&gt;
&lt;project slug="aBook" visibility="private"&gt;
&lt;name&gt;Address Book&lt;/name&gt;
&lt;developers&gt;
&lt;developer member="jb" role="manager"/&gt;
&lt;/developers&gt;
&lt;/project&gt;
&lt;/projects&gt;
&lt;/company&gt;</programlisting>
<para>The following data integrity rules shall apply:</para>
<orderedlist>
<listitem>
<para>A <tag class="starttag">company</tag> database contains <tag
class="starttag">departments</tag> and <tag
class="starttag">projects</tag>.</para>
</listitem>
<listitem>
<para><tag class="starttag">departments</tag> have an arbitrary
number of <tag class="starttag">department</tag> children.</para>
</listitem>
<listitem>
<para><tag class="starttag">department</tag> entries consist of a
<tag class="starttag">name</tag>, an arbitrary number of <tag
class="starttag">member</tag> children followed by an arbitrary
number of sub- <tag class="starttag">department</tag> entries
allowing for nested departments. <tag class="starttag">name</tag>
must be unique among all departments.</para>
</listitem>
<listitem>
<para>Each <tag class="starttag">member</tag> has got a <tag
class="attribute">@nickname</tag> attribute being unique among all
departments.</para>
</listitem>
<listitem>
<para><tag class="starttag">projects</tag> consists of an arbitrary
number of <tag class="starttag">project</tag> entries.</para>
</listitem>
<listitem>
<para>Each <tag class="starttag">project</tag> has got</para>
<itemizedlist>
<listitem>
<para>a <tag class="starttag">name</tag></para>
</listitem>
<listitem>
<para>a <tag class="starttag">developers</tag> child</para>
</listitem>
<listitem>
<para>a required <tag class="attribute">@slug</tag> attribute
carrying a shortened project's name of minimum length 5 not
containing whitespace characters. The <tag
class="attribute">@slug</tag> attribute values are unique among
all projects.</para>
</listitem>
<listitem>
<para>a required <tag class="attribute">@visibility</tag>
attribute</para>
</listitem>
<listitem>
<para>having exactly one value from {<code>"public"</code>,
<code>"internal"</code>, <code>"private"</code>}.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Each <tag class="starttag">developers</tag> child contains an
arbitrary set of <tag class="starttag">developer</tag>
entries.</para>
</listitem>
<listitem>
<para>Each <tag class="starttag">developer</tag> has got two
mandatory attributes:</para>
<orderedlist>
<listitem>
<para><tag class="attribute">@member</tag> referencing a
corresponding <tag class="starttag">member nickname="..."</tag>
entry.</para>
</listitem>
<listitem>
<para><tag class="attribute">@role</tag> having exactly one
value from {<code>"manager"</code>, <code>"guest"</code>,
<code>"developer"</code>}.</para>
</listitem>
</orderedlist>
<para>Within the same <tag class="starttag">developers</tag> parent
element all <tag class="attribute">@member</tag> attribute values
are unique. Each <tag class="attribute">@member</tag> value
references a corresponding <tag class="starttag">member
nickname="..."</tag> element.</para>
</listitem>
</orderedlist>
</section>
<section xml:id="sda1_exam_2020_summer_aufgabe1_task">
<title>Tasks</title>
<para>Complete your schema's implementation in
<filename>Schema/company.xsd</filename> using the
<productname>Oxygenxml</productname> IDE. Hints:</para>
<orderedlist>
<listitem>
<para><productname>Junit</productname> execution of
<classname>de.hdm_stuttgart.mi.sda1.test.ex1.SchemaTest</classname>
from within IntelliJ executes all unit tests based on files residing
in your project's folder <filename>SchemaTest</filename>. Some of
these files e.g.
<filename>SchemaTest/0105invalid_missingDepartments.xml</filename>
contain comment hints regarding expected errors with respect to the
intended <filename>Schema/company.xsd</filename>:</para>
<programlisting language="xml"> ... &lt;!-- &lt;departments/&gt; is missing --&gt;...</programlisting>
<para>Clicking on file names within test failure reports will open
e.g.
<filename>SchemaTest/0105invalid_missingDepartments.xml</filename>
in <productname>IDEA</productname>. However opening the same file in
<productname>Oxygenxml</productname> manually may save time due to
better <abbrev>XML</abbrev> support. IDEA' s schema support is
partly broken.</para>
</listitem>
<listitem>
<para><emphasis role="red">Never</emphasis> touch your project's
unit tests in the <filename>SchemaTest</filename> folder: The
automated tests may end up throwing meaningless exceptions.</para>
</listitem>
<listitem>
<para>Edit <filename>Schema/company.xsd</filename> only by small
steps executing the tests immediately. Schema changes may cause
already working tests to fail again. In case of spoiling your schema
<quote>undo</quote> is your friend.</para>
</listitem>
</orderedlist>
<tip>
<itemizedlist>
<listitem>
<para>XPath uses the dot (.) for selecting an element's content
e.g. "<emphasis role="red">food</emphasis>" in <tag
class="starttag">cat</tag><emphasis role="red">food</emphasis><tag
class="endtag">cat</tag> .</para>
</listitem>
<listitem>
<para>The <link
xlink:href="https://freedocs.mi.hdm-stuttgart.de/__slidesda1_xmlschema_chap_Xmlschema.html#/sda1_xmlschema_fig_textContentAttribute">Text
content and attributes</link> slide is your friend.</para>
</listitem>
<listitem>
<para>Consider the list of <link
xlink:href="https://www.w3schools.com/xml/schema_dtypes_numeric.asp">predefined
data types</link> near the page's bottom.</para>
</listitem>
<listitem>
<para>Use <tag class="starttag">xs:selector
xpath=".//department/member"</tag> for constructing <tag
class="starttag">xs:key ...</tag> constraints on nested <tag
class="starttag">department</tag> elements.</para>
</listitem>
<listitem>
<para>Prefer <abbrev>XSD</abbrev> standard types rather than
defining own types by restriction.</para>
</listitem>
<listitem>
<para><link
xlink:href="https://www.w3schools.com/xml/schema_facets.asp">XSD
Restrictions/Facets</link> may be helpful.</para>
</listitem>
</itemizedlist>
</tip>
</section>
<section version="5.1" xml:id="sda1_exam_2020_summer_uploadFirst">
<title>Project upload</title>
<para>Export your project by hitting »File« --&gt; »Export to Zip File«
in IDEA creating an <abbrev>e.g.</abbrev>
<filename>solution-1.zip</filename> file. Then enter your
<productname>ILIAS</productname> browser, hit the <quote>choose
file</quote> button selecting <filename>solution-1.zip</filename> and
subsequently click <quote>upload</quote>. Do not forget to advance to
the next question hitting the »save+next« button for <emphasis
role="bold">actually saving your upload</emphasis>. Common
pitfalls:</para>
<itemizedlist>
<listitem>
<para>Do not select the wrong archive! In particular avoid choosing
the original <filename>exam.zip</filename> skeleton.</para>
</listitem>
<listitem>
<para>After uploading and hitting »save+next« check for
<filename>solution_1.zip</filename> being visible in the examination
system.</para>
</listitem>
<listitem>
<para>You may upload multiple versions i.e.
<filename>solution_2.zip</filename> etc. . Only your least uploaded
archive will become subject to marking.</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="sda1_exam_2020_summer_examCaveats">
<title>Caveats</title>
<itemizedlist>
<listitem>
<para>When approaching examination ending time check your input for
completeness.</para>
</listitem>
<listitem>
<para>Projects residing just on your local workstation cannot be
recovered after exam termination.</para>
</listitem>
</itemizedlist>
</section>
</section>
<section xml:id="sda1_exam_2020_summer_task2">
<title>Relational representation of <tag class="starttag">company</tag>
document instances</title>
<section xml:id="sda1_exam_2020_summer_task2_prepare">
<title>Preparation</title>
<para>If you already started the first task just continue working on
your project using IntelliJ. Otherwise read the first task regarding the
skeleton project import.</para>
<para>Hint: A global database connection is configured on IDEA
level.</para>
</section>
<section xml:id="sda1_exam_2020_summer_task2_descr">
<title>Description / tasks</title>
<para>Extend the relational schema skeleton
<filename>Schema/schema.sq</filename>l preparing your RDBMS to import
<tag class="starttag">company</tag> instances.</para>
<para>Note the pre-existing table <code>Company</code>: Add required
tables reflecting the integrity constraints from the first task.</para>
<para>Use CHECK(...) constraints where appropriate.</para>
</section>
<section version="5.1" xml:id="sda1_exam_2020_summer_uploadFollow">
<title>Solution upload</title>
<para>Upload your project using the previous task. Then enter «I'm
expecting points for my work on the current task» into the text field
below on this page.</para>
</section>
</section>
<section xml:id="sda1_exam_2020_summer_task3">
<title>Import XML instances into RDBMS</title>
<section xml:id="sda1_exam_2020_summer_task3_prepare">
<title>Preparation</title>
<para>If you already started the first task just continue working on
your project using IntelliJ. Otherwise read the first task regarding the
skeleton project import.</para>
</section>
<section xml:id="sda1_exam_2020_summer_task3_descr">
<title>Description</title>
<para>Write a Java application reading <tag
class="starttag">company</tag> document instances and writing <tag
class="starttag">department</tag> elements among with their hierarchical
structure and <tag class="starttag">member</tag> entries to a relational
database. Do not consider <tag class="starttag">project</tag> related
data at all. Hints:</para>
<itemizedlist>
<listitem>
<para><package>de.hdm_stuttgart.mi.sda1</package>.<classname>Company2Rdbms</classname>
contains <abbrev>JDBC</abbrev> related connection parameters and
boilerplate code.</para>
</listitem>
<listitem>
<para>Upon invocation class
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Driver</classname>
instantiates
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Company2Rdbms</classname>
thereby:</para>
<itemizedlist>
<listitem>
<para>Reading and parsing
<filename>Schema/sampledata.xml</filename>.</para>
</listitem>
<listitem>
<para>Open a database connection to your local PostgreSQL
server.</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</section>
<section xml:id="sda1_exam_2020_summer_task3_tasks">
<title>Tasks</title>
<para>Pre- create your database schema from your last task's
<filename>Schema/schema.sql</filename> using the IDE prior to running
your application. Implement the subsequently mentioned features. Each
section adds points to your marking. Using <link
xlink:href="https://klausur.mi.hdm-stuttgart.de/doc/openjdk-11-doc/api/java.sql/java/sql/PreparedStatement.html">PreparedStatement</link>
instances should be preferred. Idea:</para>
<orderedlist>
<listitem>
<para>Get all top level <tag class="starttag">department</tag>
entries first.</para>
</listitem>
<listitem>
<para>From each top level <tag class="starttag">department</tag>
recurse to <tag class="starttag">department</tag> children actually
using <abbrev>JDBC</abbrev> to insert your data.</para>
</listitem>
<listitem>
<para>Allow for multiple invocations: Import conflicts
(<acronym>i.e.</acronym> duplicate lectures or marks) should create
informal warnings but your application should try to continue
anyway.</para>
</listitem>
</orderedlist>
</section>
<section xml:id="sda1_exam_2020_summer_task3_hints">
<title>Hints</title>
<itemizedlist>
<listitem>
<para>Executing
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Driver</classname>
calls
<package>de.hdm_stuttgart.mi.sda1</package>.<classname>Company2Rdbms</classname>.<methodname>execute()</methodname>
already containing both your XML instance's root element and a
database connection handle.</para>
</listitem>
<listitem>
<para>Even if your application just fills in <abbrev>e.g.</abbrev>
(only top level) <tag class="starttag">department</tag> values
excluding <tag class="starttag">member</tag> data you'll receive
points. Also partly meaningful but not fully working code may
contribute.</para>
</listitem>
</itemizedlist>
</section>
<section version="5.1" xml:id="sda1_exam_2020_summer_task3_upload">
<title>Solution upload</title>
<para>Upload your project using the first task. Enter either of the
following two texts below:</para>
<itemizedlist>
<listitem>
<para>I'm expecting points for my work on the current task.</para>
</listitem>
<listitem>
<para>I did not work on this task.</para>
</listitem>
</itemizedlist>
<para>You may as well add other marking related comments.</para>
</section>
</section>
</section>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment