Library_database_relations.xhtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. h t t :: / / t /
  4. h t t :: // // t //
  5. h ttttt ttttt ppppp sssss // // y y sssss ttttt //
  6. hhhh t t p p s // // y y s t //
  7. h hh t t ppppp sssss // // yyyyy sssss t //
  8. h h t t p s :: / / y .. s t .. /
  9. h h t t p sssss :: / / yyyyy .. sssss t .. /
  10. <https://y.st./>
  11. Copyright © 2017 Alex Yst <mailto:copyright@y.st>
  12. This program is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program. If not, see <https://www.gnu.org./licenses/>.
  22. -->
  23. <!DOCTYPE html>
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <base href="https://y.st./en/coursework/CS2203/Library_database_relations.xhtml" />
  27. <title>Library database relations &lt;https://y.st./en/coursework/CS2203/Library_database_relations.xhtml&gt;</title>
  28. <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
  29. <link rel="stylesheet" type="text/css" href="/link/basic.css" />
  30. <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
  31. <script type="text/javascript" src="/script/javascript.js" />
  32. <meta name="viewport" content="width=device-width" />
  33. </head>
  34. <body>
  35. <nav>
  36. <p>
  37. <a href="/en/">Home</a> |
  38. <a href="/en/a/about.xhtml">About</a> |
  39. <a href="/en/a/contact.xhtml">Contact</a> |
  40. <a href="/a/canary.txt">Canary</a> |
  41. <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
  42. <a href="/en/opinion/">Opinions</a> |
  43. <a href="/en/coursework/">Coursework</a> |
  44. <a href="/en/law/">Law</a> |
  45. <a href="/en/a/links.xhtml">Links</a> |
  46. <a href="/en/coursework/CS2203/Library_database_relations.xhtml.asc">{this page}.asc</a>
  47. </p>
  48. <hr/>
  49. <p>
  50. <a href="/en/coursework/BUS1101/" title="Principles of Business Management">BUS 1101</a> |
  51. <span class="hyperlink_unavailable" title="Basic Accounting">BUS 1102</span> |
  52. <span class="hyperlink_unavailable" title="Principles of Marketing">BUS 2201</span> |
  53. <span class="hyperlink_unavailable" title="Multinational Management">BUS 2207</span> |
  54. <span class="hyperlink_unavailable" title="Business and Society">BUS 3306</span> |
  55. <a href="/en/coursework/CS1101/" title="Programming Fundamentals">CS 1101</a> |
  56. <a href="/en/coursework/CS1102/" title="Programming 1">CS 1102</a> |
  57. <a href="/en/coursework/CS1103/" title="Programming 2">CS 1103</a> |
  58. <span class="hyperlink_unavailable" title="Computer Systems">CS 1104</span> |
  59. <a href="/en/coursework/CS2203/" title="Databases 1">CS 2203</a> |
  60. <span class="hyperlink_unavailable" title="Communications and Networking">CS 2204</span> |
  61. <a href="/en/coursework/CS2205/" title="Web Programming 1">CS 2205</a> |
  62. <a href="/en/coursework/CS2301/" title="Operating Systems 1">CS 2301</a> |
  63. <span class="hyperlink_unavailable" title="Software Engineering 1">CS 2401</span> |
  64. <span class="hyperlink_unavailable" title="Data Structures">CS 3303</span> |
  65. <span class="hyperlink_unavailable" title="Analysis of Algorithms">CS 3304</span> |
  66. <span class="hyperlink_unavailable" title="Web Programming 2">CS 3305</span> |
  67. <span class="hyperlink_unavailable" title="Databases 2">CS 3306</span> |
  68. <span class="hyperlink_unavailable" title="Operating Systems 2">CS 3307</span> |
  69. <span class="hyperlink_unavailable" title="Information Retrieval">CS 3308</span> |
  70. <span class="hyperlink_unavailable" title="Comparative Programming Languages">CS 4402</span> |
  71. <span class="hyperlink_unavailable" title="Software Engineering 2">CS 4403</span> |
  72. <span class="hyperlink_unavailable" title="Advanced Networking and Data Security">CS 4404</span> |
  73. <span class="hyperlink_unavailable" title="Mobile Applications">CS 4405</span> |
  74. <span class="hyperlink_unavailable" title="Computer Graphics">CS 4406</span> |
  75. <span class="hyperlink_unavailable" title="Data Mining and Machine Learning">CS 4407</span> |
  76. <span class="hyperlink_unavailable" title="Artificial Intelligence">CS 4408</span> |
  77. <span class="hyperlink_unavailable" title="English Composition 2">ENGL 1102</span> |
  78. <span class="hyperlink_unavailable" title="World Literature">ENGL 1405</span> |
  79. <span class="hyperlink_unavailable" title="Introduction to Environmental Science">ENVS 1301</span> |
  80. <a href="/en/coursework/HIST1421/" title="Greek and Roman Civilization">HIST 1421</a> |
  81. <span class="hyperlink_unavailable" title="College Algebra">MATH 1201</span> |
  82. <span class="hyperlink_unavailable" title="Calculus">MATH 1211</span> |
  83. <span class="hyperlink_unavailable" title="Introduction to Statistics">MATH 1280</span> |
  84. <span class="hyperlink_unavailable" title="Discrete Mathematics">MATH 1302</span> |
  85. <span class="hyperlink_unavailable" title="Introduction to Philosophy">PHIL 1402</span> |
  86. <a href="/en/coursework/PHIL1404/" title="Ethics and Social Responsibility">PHIL 1404</a> |
  87. <a href="/en/coursework/POLS1503/" title="Globalization">POLS 1503</a> |
  88. <span class="hyperlink_unavailable" title="Introduction to Psychology">PSYC 1504</span> |
  89. <a href="/en/coursework/UNIV1001/" title="Online Education Strategies">UNIV 1001</a>
  90. </p>
  91. <hr/>
  92. <p>
  93. <a href="/en/coursework/CS2203/Library_database_relations.xhtml" title="Library database relations">Unit 1</a> |
  94. <a href="/en/coursework/CS2203/Library_database_relations~_continued.xhtml" title="Library database relations, continued">Unit 2</a> |
  95. <a href="/en/coursework/CS2203/Library_database_relation_diagram.xhtml" title="Library database relation diagram">Unit 3</a> |
  96. <a href="/en/coursework/CS2203/Library_database_normalisation.xhtml" title="Library database normalisation">Unit 4</a> |
  97. <a href="/en/coursework/CS2203/Library_database_SQL.xhtml" title="Library database SQL">Unit 5</a> |
  98. <a href="/en/coursework/CS2203/Library_database_SQL~_continued.xhtml" title="Library database SQL, continued">Unit 6</a> |
  99. <a href="/en/coursework/CS2203/Library_database_SQL_select.xhtml" title="Library database SQL select">Unit 7</a>
  100. </p>
  101. <hr/>
  102. </nav>
  103. <header>
  104. <h1>Library database relations</h1>
  105. <p>Written in <span title="Databases 1">CS 2203</span> of <a href="http://www.uopeople.edu/">University of the People</a>, finalised on 2017-06-21</p>
  106. </header>
  107. <h2><code>Book</code>:</h2>
  108. <p>
  109. The <code>Book</code> relation will include the following attributes in its tuples:
  110. </p>
  111. <ul>
  112. <li>
  113. <code>id</code> (integer, unique, primary key, auto-increment, not null, candidate key)
  114. </li>
  115. <li>
  116. <code>title</code> (string, not null)
  117. </li>
  118. <li>
  119. <code>author</code> (string, not null)
  120. </li>
  121. <li>
  122. <code>isbn</code> (string, not null)
  123. </li>
  124. <li>
  125. <code>publication_date</code> (string, not null)
  126. </li>
  127. <li>
  128. <code>cost</code> (float, not null)
  129. </li>
  130. </ul>
  131. <p>
  132. This relation has a relation degree of six.
  133. </p>
  134. <p>
  135. <code>id</code> will be the primary key, and will auto-increment as books are added.
  136. This attribute will be an integer.
  137. It&apos;s <strong>*extremely*</strong> tempting to use the <code>isbn</code> attribute as the primary key, but there could be multiple copies of the same book in the library&apos;s collection.
  138. If there are multiple copies of any book, no field will be unique unless we add this artificial key.
  139. </p>
  140. <p>
  141. <code>title</code> will be a string.
  142. Obviously, it&apos;ll be the title of the book.
  143. <code>author</code> too will be a string, the author of the book.
  144. This will be in &quot;{given name} {surname}&quot; format, <strong>*not*</strong> &quot;{surname}, {given name}&quot; format.
  145. The proper format of an <abbr title="International Standard Book Number">ISBN</abbr> includes three hyphens, so to accommodate this, the <code>isbn</code> attribute is a string, not an integer.
  146. <code>publication_date</code> is the date of the book&apos;s publication in the <code>*international standard format*</code>, which happens to be big endian.
  147. That is to say, if the book were published today, the <code>publication_date</code> would be set to <code>2017-06-21</code>, not something goofy such as <code>06-21-2017</code>.
  148. This field is a string to accommodate use of hyphens as well.
  149. The cost of the book wil be stored in the <code>cost</code> attribute.
  150. This field is a floating-point decimal to allow for partial currency units.
  151. In the United States, dollars would be the whole units and cents would be represented by hundredths of units.
  152. As this is a floating-point decimal and not a string, a currency sign such as a dollar sign is not included.
  153. </p>
  154. <h2><code>Borrower</code>:</h2>
  155. <p>
  156. The <code>Borrower</code> relation will have the following attributes in its tuples:
  157. </p>
  158. <ul>
  159. <li>
  160. <code>card_number</code> (integer, unique, primary key, not null, candidate key)
  161. </li>
  162. <li>
  163. <code>name</code> (string, not null)
  164. </li>
  165. <li>
  166. <code>address</code> (string, not null)
  167. </li>
  168. <li>
  169. <code>postal_code</code> (integer, not null)
  170. </li>
  171. <li>
  172. <code>telephone_number</code> (string)
  173. </li>
  174. <li>
  175. <code>join_date</code> (string, not null)
  176. </li>
  177. </ul>
  178. <p>
  179. This relation has a relation degree of seven.
  180. </p>
  181. <p>
  182. <code>card_number</code> will be an integer set to the cardholder&apos;s library card number.
  183. These numbers will likely not be sequential, but they will be unique.
  184. This field will be used as the primary key.
  185. <code>name</code> will be a string attribute used to store the cardholder&apos;s name.
  186. <code>address</code> will store their postal address as a string, excluding the postal code.
  187. <code>postal_code</code> will be an integer storing the postal code of each cardholder.
  188. <code>telephone_number</code> will be used to store the cardholder&apos;s telephone number.
  189. Not everyone has telephone service though.
  190. To allow for this, the <code>telephone_number</code> attribute can be null, unlike other attributes of these relations.
  191. <code>join_date</code> will be a string, using the international, standard date format.
  192. </p>
  193. <h2><code>BookLended</code>:</h2>
  194. <p>
  195. The tuples of the <code>BookLended</code> relation will have these attributes:
  196. </p>
  197. <ul>
  198. <li>
  199. <code>book</code> (integer, unique, primary key, foreign key, not null, candidate key)
  200. </li>
  201. <li>
  202. <code>checked_out</code> (string, not null)
  203. </li>
  204. <li>
  205. <code>due_back</code> (string, not null)
  206. </li>
  207. <li>
  208. <code>borrower</code> (integer, foreign key, not null)
  209. </li>
  210. <li>
  211. <code>librarian</code> (integer, foreign key, not null)
  212. </li>
  213. </ul>
  214. <p>
  215. This relation has a relation degree of five.
  216. </p>
  217. <p>
  218. The <code>book</code> attribute is a foreign key representing a book that is currently checked out.
  219. It&apos;s an integer that matched the <code>id</code> of a book in the <code>Books</code> relation.
  220. Because a book cannot be checked out by two people at once, the <code>book</code> also serves as the primary key of the <code>BookLended</code> relation.
  221. <code>checked_out</code> and <code>due_back</code> are the dates the book was checked out and will be due back, respectively.
  222. As before, the international, standard, big-endian format is used here.
  223. <code>borrower</code> is an integer that acts as a foreign key to the <code>Borrower</code> relation.
  224. This represents the cardholder that currently has the book in their possession.
  225. The <code>librarian</code> attribute is an integer and a foreign key representing the <abbr title="identification">ID</abbr> number of the librarian that checked out the book.
  226. </p>
  227. <h2><code>Librarian</code>:</h2>
  228. <p>
  229. The attributes of the <code>Librarian</code> relation are as follows:
  230. </p>
  231. <ul>
  232. <li>
  233. <code>id</code> (integer, unique, primary key, not null, candidate key)
  234. </li>
  235. <li>
  236. <code>name</code> (string, not null)
  237. </li>
  238. <li>
  239. <code>extension</code> (integer, unique, alternate key, not null, candidate key)
  240. </li>
  241. </ul>
  242. <p>
  243. This relation has a relation degree of three.
  244. </p>
  245. <p>
  246. The primary key of this relation is the librarians&apos; <abbr title="identification">ID</abbr> numbers, stored as the <code>id</code> property.
  247. However, as each librarian has their own extension, the <code>extension</code> field both stores that extension and acts as an alternate key.
  248. While our borrowers may not all have telephone numbers, all of our librarians are reachable by telephone, so this attribute cannot be null.
  249. This is because we&apos;re using the library&apos;s internal telephone setup, not relying on the librarians to be subscribed to telephone service.
  250. The librarian&apos;s name is stored using the <code>name</code> key.
  251. </p>
  252. <hr/>
  253. <p>
  254. Copyright © 2017 Alex Yst;
  255. You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
  256. If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
  257. My address is in the source comments near the top of this document.
  258. This license also applies to embedded content such as images.
  259. For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
  260. </p>
  261. <p>
  262. <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
  263. This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fcoursework%2FCS2203%2FLibrary_database_relations.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fcoursework%2FCS2203%2FLibrary_database_relations.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
  264. </p>
  265. </body>
  266. </html>