<author> <personname/> </author> <pubdate/> </info> <chapter xml:id="task1"> <title>A bibliography database
Preparations Download and unzip the above file exam.zip and import the resulting Exam folder as a Maven project into your IDE.
Description Consider a bibliography database as in your project's sample data file Schema/sampledata.xml: <bibliography ... > <publishers> <publisher id="springer"> <name>Springer</name> <city>Berlin / Germany</city> </publisher> <publisher id="addWesley"> <name>Addison-Wesley</name> <city>Reading, Massachusetts / USA</city> </publisher> </publishers> <book id="ab94" publisher="springer" year="1994"> <title>Infinite Dimensional Analysis</title> <author>Charalambos D. Aliprantis</author> <editor>Kim C. Border</editor> </book> <book id="goossens93" publisher="addWesley" year="1993"> <title>The LaTeX Companion</title> <editor>Michel Goossens</editor> <author>Frank Mittelbach</author> <author>Alexander Samarin</author> </book> <website id="bibtex" access="2018-07-15"> <uri>https://en.wikipedia.org/wiki/BibTeX</uri> <title>BiBTeX - Wikipedia</title> <!-- Optional: <author>...</author> --> </website> </bibliography> Data integrity rules: bibliography and publishers may be empty. Each publisher must have a (name, city) combination being unique within publishers. Hint: XML schema allows for multiple xs:field elements. The set of @id values of publisher entries must be unique within publishers. The set of @id values of book and website entries must be unique within bibliography. A book entry must have a title and at least one author or editor child. A book @publisher's attribute value must refer to an existing publisher @id attribute value. A book @year's attribute must be of integer value. A website must have both uri and title and may have author children. uri content must begin either with http:// or https://. Hint: Use http[s]?://.+. The @access date attribute value must be specified with respect to English locale. Hint: A useful standard schema type exists. Complete the schema implementation in Schema/bib.xsd. Junit execution of de.hdm_stuttgart.mi.sda1.test.ex1.ShowReachedPoints loads all unit tests based on files residing in your project's folder SchemaTest. In turn you receive your number of points reached so far including detailed hints about failed tests.
Tasks Implement the yet incomplete XML Schema file Schema/bib.xsd modeling all mentioned integrity rules: The folder SchemaTest contains sample files testing your schema for correctness. Executing de.hdm_stuttgart.mi.sda1.test.ex1.ShowReachedPoints as a Java application indicates which test documents in SchemaTest yet fail the expected outcome being either valid of invalid. You also get the number of points reached so far. Open all XML related files in Oxygenxml offering better schema support than IntelliJ. Don't touch the unit test defines in your project's SchemaTest folder: Your automated tests may end up throwing meaningless exceptions. Edit Schema/bib.xsd by small steps and always execute the tests: In case of spoiling the undo operation is your friend.
Project upload Hit »File« --> »Export to Zip File« in IDEA archiving your project as solution-1.zip. Then enter your ILIAS tab, hit choose selecting solution-1.zip and subsequently upload. Do not forget to advance to the next question to actually save the current question. Common pitfalls: Upload the right archive: Avoid choosing the original exam.zip skeleton. Watch out for solution_1.zip actually being visible in the examination system. You may upload multiple versions i.e. solution_2.zip etc.. Only your least upload will become subject to marking. Be careful: Check your input at examination end for completeness. Projects residing only on your local workstation cannot be recovered after exam termination.
Relational database HTML export
Preparation If you already started the first exercise just continue working on your project using IntelliJ. Otherwise read the first exercise regarding the skeleton project import. Configuring a Mysql type database connection in Intellij (»Views« --> »Tool Windows« --> »Database«) requires: Host: localhost Database: hdm User: hdmuser Password: XYZ
Description Consider two tables representing athletes and their corresponding 100 metre race competition results: Table Athlete id fullName 1 Jesse Owens 2 Tim Culver 3 Sid Gascoine 4 John Hooker 5 Brad Duncan . . Table Competition id athlete time badStart 1 1 10.23 0 2 2 11.55 0 3 3 11.94 0 4 4 10.02 0 5 5 10.84 0 6 2 10.02 0 7 3 10.49 0 8 2 9.35 1 Explanations and hints: Each Athlete has a name and a unique id. The id column in Competition defines the order of athlete's competition attempts. The Competition.athlete column refers to the corresponding Athlete.id value identifying the athlete in question. Athletes may appear multiple times in Competition referring to multiple competition attempts. All but the very last Competition sample records have a badStart value of 0 indicating a proper start. A badStart value different from 0 indicates a start failure. Note: Mysql allows for type boolean being an alias for type bit representing 0 and 1. Schema/schema.sql already contains INSERT statements corresponding to the above sample data.
Tasks Every task adds to points being reached. Create a suitable database schema prior to and corresponding to the already existing INSERT statements in Schema/schema.sql representing the informally mentioned constraints. Execute the INSERT statements both as proof of concept and with respect to subsequent tasks. Class de.hdm_stuttgart.mi.sda1.AllResults already references a fully configured JDBC connection. On execution you'll see a single html tag being created. Extend the underlying classes to create the subsequent HTML output derived from your Mysql database's content. Competition results shall be ordered first by ascending time and second by athlete's name. Red background rows indicate bad start attempts: <html> <head><title>Results</title></head> <body> <table> <tr> <th>Rank</th> <th>Name</th> <th>Time</th> </tr> <tr style="background: red;"> <td>1</td> <td>Tim Culver</td> <td>9.35</td> </tr> ... </table> </body> </html> . . Pseudo outline HTML representation, red background indicating bad starts not to be displayed for technical reasons, using bold style instead: Rank Name Time / seconds 1 Tim Culver 10.23 2 John Hooker 10.02 3 Tim Culver 10.02 4 Jesse Owens 10.23 5 Sid Gascoine 10.49 6 Brad Duncan 10.84 7 Tim Culver 11.55 8 Sid Gascoine 11.94 The SQL sample data is only intended for illustration purposes. Your application shall work accordingly when reading similar but different data sets. Use a Join. Create the »Rank« column values inside your Java application rather than using SQL. The previous table contains both duplicate athlete attempts and bad starts. We are looking for a »final result« table containing only the fastest and at the same time valid run of each athlete eliminating bad starts: <table> <tr> <th>Rank</th> <th>Name</th> <th>Time / seconds</th> </tr> <tr> <td>1</td> <td>John Hooker</td> <td>10.02</td> </tr> ... </table>... . . Pseudo outline representation: Rank Name Time / seconds 1 John Hooker 10.02 2 Tim Culver 10.02 3 Jesse Owens 10.23 4 Sid Gascoine 10.49 5 Brad Duncan 10.84 Create a suitable executable class de.hdm_stuttgart.mi.sda1.FinalResults. Rather than fiddling with minimum (best) time values in Java you may solve this problem on SQL level using SELECT ... GROUP BY in conjunction with the min() aggregate function choosing the least time of each athlete. Use a column name alias for renaming the aggregate column's name.
Solution upload Upload your project using the previous exercise. Enter either of the following two texts: I'm expecting points for my work on the current exercise. I did not work on this exercise. You may as well add other marking related comments.