Library_database_relations~_continued.xhtml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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~_continued.xhtml" />
  27. <title>Library database relations, continued &lt;https://y.st./en/coursework/CS2203/Library_database_relations~_continued.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~_continued.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, continued</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. <p>
  108. The entity integrity constraints are simple.
  109. First, every relation must have a primary key.
  110. This primary key must not be null and must be unique to each tuple.
  111. Semantic and domain constraints in the form of data types are listed in the lists below.
  112. With a more-complex language, we could also add constraints that, for example, required that the <abbr title="International Standard Book Number">ISBN</abbr> check sum be accurate and that the telephone number be in an acceptable format.
  113. Null and unique constraints are in the lists below as well.
  114. Remember that the telephone number of a librarian cannot be null, because the librarians are using the library&apos;s internal extension system, not their own telephones.
  115. However, a member might have a null telephone number because they might not have telephone service.
  116. </p>
  117. <p>
  118. The only foreign keys in the database are in the borrowed books relation.
  119. The borrower of a book cannot be null.
  120. If an attempt is made to remove a borrower from the database, it will be rejected if that borrower has any books checked out.
  121. The books must be turned in or removed from the library database before the member can be removed.
  122. If a book is removed from the database and it&apos;s checked out, it&apos;s tuple in the lent books table is removed by cascade too.
  123. A librarian may quit or be fired.
  124. In that case, they may be removed from the database.
  125. For keeping records straight, we should wait to remove the librarian until after any books they lent are brought back.
  126. However, we don&apos;t have to wait if we don&apos;t want to.
  127. If a librarian is removed, any books they lent out will have their librarian field nullified.
  128. </p>
  129. <h2><code>Book</code>:</h2>
  130. <p>
  131. The <code>Book</code> relation will include the following attributes in its tuples:
  132. </p>
  133. <ul>
  134. <li>
  135. <code>id</code> (integer, unique, primary key, auto-increment, not null, candidate key)
  136. </li>
  137. <li>
  138. <code>title</code> (string, not null)
  139. </li>
  140. <li>
  141. <code>author</code> (string, not null)
  142. </li>
  143. <li>
  144. <code>isbn</code> (string, not null)
  145. </li>
  146. <li>
  147. <code>publication_date</code> (string, not null)
  148. </li>
  149. <li>
  150. <code>cost</code> (float, not null)
  151. </li>
  152. </ul>
  153. <h2><code>Borrower</code>:</h2>
  154. <p>
  155. The <code>Borrower</code> relation will have the following attributes in its tuples:
  156. </p>
  157. <ul>
  158. <li>
  159. <code>card_number</code> (integer, unique, primary key, not null, candidate key)
  160. </li>
  161. <li>
  162. <code>name</code> (string, not null)
  163. </li>
  164. <li>
  165. <code>address</code> (string, not null)
  166. </li>
  167. <li>
  168. <code>postal_code</code> (integer, not null)
  169. </li>
  170. <li>
  171. <code>telephone_number</code> (string)
  172. </li>
  173. <li>
  174. <code>join_date</code> (string, not null)
  175. </li>
  176. </ul>
  177. <h2><code>BookLended</code>:</h2>
  178. <p>
  179. The tuples of the <code>BookLended</code> relation will have these attributes:
  180. </p>
  181. <ul>
  182. <li>
  183. <code>book</code> (integer, unique, primary key, foreign key, not null, candidate key)
  184. </li>
  185. <li>
  186. <code>checked_out</code> (string, not null)
  187. </li>
  188. <li>
  189. <code>due_back</code> (string, not null)
  190. </li>
  191. <li>
  192. <code>borrower</code> (integer, foreign key, not null)
  193. </li>
  194. <li>
  195. <code>librarian</code> (integer, foreign key)
  196. </li>
  197. </ul>
  198. <h2><code>Librarian</code>:</h2>
  199. <p>
  200. The attributes of the <code>Librarian</code> relation are as follows:
  201. </p>
  202. <ul>
  203. <li>
  204. <code>id</code> (integer, unique, primary key, not null, candidate key)
  205. </li>
  206. <li>
  207. <code>name</code> (string, not null)
  208. </li>
  209. <li>
  210. <code>extension</code> (integer, unique, alternate key, not null, candidate key)
  211. </li>
  212. </ul>
  213. <hr/>
  214. <p>
  215. Copyright © 2017 Alex Yst;
  216. 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>.
  217. If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
  218. My address is in the source comments near the top of this document.
  219. This license also applies to embedded content such as images.
  220. For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
  221. </p>
  222. <p>
  223. <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
  224. This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fcoursework%2FCS2203%2FLibrary_database_relations%7E_continued.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%7E_continued.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
  225. </p>
  226. </body>
  227. </html>