Introduction to Relational Databases Some Preliminaries What Is a Database? “Organised Collection of Symbols” “To Be Inter

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Relational Databases Some Preliminaries What Is a Database? “Organised Collection of Symbols” “To Be Inter HACD.1: Introduction to Relational Databases 04/10/2010 Introduction to Relational Some Preliminaries Databases The theory taught in this part of the course was originally Hugh Darwen devised by Edgar F. Codd in 1969. His seminal paper (1970) was entitled A Relational Model of Data for Large Shared [email protected] Data Banks. www.dcs.warwick.ac.uk/~hugh We will use a language called Tutorial D for examples and exercises. CS252.HACD: Fundamentals of Relational Databases Section 1: Introduction We will use Rel, an implementation of Tutorial D, for our on- line work. 1 2 “Organised Collection of What Is a Database? Symbols” For example: An organised, machine-readable collection of symbols, to be interpreted as a true StudentIdName CourseId account of some enterprise. S1Anne C1 Machine-updatable, too … S1Anne C2 … so a database is also a collection of variables. S2Boris C1 S3Cindy C3 A database is typically available to a community of users, with possibly varying requirements. The symbols are organised into rows and columns, thus forming a table. One of the rows is different in kind from the others. 3 4 “To Be Interpreted as a True “Collection of Variables” Account” ENROLMENT StudentIdName CourseId For example (from the table just shown): S1Anne C1 S1Anne C2 StudentIdName CourseId S1Anne C1 S2Boris C1 S3 Cindy C3 Perhaps those green symbols, organised as they are with S4Devinder C1 respect to the blue ones, are to be understood to mean: ENROLMENT is a variable. Perhaps the table we saw earlier “Student S1, named Anne, is enrolled on course C1.” was once its value. If so, it (the variable) has been updated since then (the row for S4 has been added). 5 6 CS252: Fundamentals of Relational Databases 1 HACD.1: Introduction to Relational Databases 04/10/2010 What Is a Relational Database? “Relation” not equal to “Table” A database whose symbols are organised into a This table is different from the one we have just seen, collection of relations. Here is a relation, shown in but it represents the same relation: tabular form: Name StudentId CourseId Name CourseIdStudentId C1S4Devinder Anne C1S1 C3S3Cindy Anne C2S1 Anne S1 C1 Boris C1S2 Boris S2 C1 C3CindyS3 C2S1Anne Devinder C1S4 In other words, the relation represented does not Might be the value currently assigned to ENROLMENT, a depend on the order in which we place the rows or the relation variable (“relvar”). columns in the table. 7 8 Anatomy of a Relation What Is a DBMS? Name CourseIdStudentId A piece of software for managing databases Anne C1S1 and providing access to them. A DBMS responds to imperatives (“statements”) attribute name attribute values n-tuple, or tuple. given by application programs, custom-written This is a 3-tuple. or general-purpose, executing on behalf of users. The tuples constitute the body Imperatives are written in the database language of the relation. of the DBMS (e.g., SQL). Heading (a set of attributes) The number of The degree of this heading is 3, tuples in the body Responses include completion codes, messages and which is also the degree of the relation. is the cardinality of results of queries. the relation. 9 10 What Does a DBMS Do? Create and Destroy Variables In response to requests given by application programs: Creation (in Tutorial D): • creates and destroys variables VAR ENROLMENT BASE RELATION • takes note of integrity rules (constraints) { StudentId SID , • takes note of authorisations (who is allowed to do Name CHAR, what, to what) CourseId CID } • updates variables (honouring constraints and KEY { StudentId, CourseId } ; authorisations) • provides results of queries Destruction: • and more DROP VAR ENROLMENT ; Now, how does a relational DBMS do these things? … 11 12 CS252: Fundamentals of Relational Databases 2 HACD.1: Introduction to Relational Databases 04/10/2010 Take Note of Integrity Rules Take Note of Authorisations E.g., can’t have more than 20,000 enrolments altogether. In E.g. (perhaps – but not in Tutorial D): Tutorial D: PERMISSION U9_ENROLMENT FOR User9 CONSTRAINT MAX_ENROLMENTS TO READ ENROLMENT ; COUNT ( ENROLMENT ) <= 20000 ; PERMISSION U8_ENROLMENT FOR User8 And if a constraint ceases to be applicable: TO UPDATE ENROLMENT ; DROP CONSTRAINT MAX_ENROLMENTS ; Permissions sometimes need to be withdrawn: DROP PERMISSION U9_ENROLMENT ; 13 14 Updates Variables Provides Results of Queries E.g.: E.g.: Who is enrolled on course C1? DELETE ENROLMENT WHERE StudentId = (ENROLMENT WHERE CourseId = CID(‘C1’)) SID ( ‘S4’ ) ; { StudentId, Name } UPDATE ENROLMENT WHERE StudentId = The result is another relation! In tabular form: SID ( ‘S1’ ) Name := ‘Ann’ ; StudentId Name INSERT ENROLMENT S1 Anne RELATION { TUPLE { StudentId SID ( ‘S4’ ) , S2 Boris Name ‘Devinder’ , S4 Devinder CourseId CID ( ‘C1’ ) } } ; 15 16 EXERCISE IMPORTANT BIT OF ADMIN Consider this table: Are you: (a) an overseas student visiting for just one year, or A B A (b) doing a degree that is completely outside the CS 1 2 3 department? (In which case you should complete an 4 5 Unusual Option Form, obtainable from your dept secretary) 6 7 8 If so, on exit from this lecture: 9 9 ? 1 2 3 Write your name, ITS userid, and course code on the sheet of paper provided. Give three reasons why it cannot be representing a relation. Otherwise you won’t get access to the software needed for the Worksheets! 17 18 CS252: Fundamentals of Relational Databases 3.
Recommended publications
  • Using Relational Databases in the Engineering Repository Systems
    USING RELATIONAL DATABASES IN THE ENGINEERING REPOSITORY SYSTEMS Erki Eessaar Department of Informatics, Tallinn University of Technology, Raja 15,12618 Tallinn, Estonia Keywords: Relational data model, Object-relational data model, Repository, Metamodeling. Abstract: Repository system can be built on top of the database management system (DBMS). DBMSs that use relational data model are usually not considered powerful enough for this purpose. In this paper, we analyze these claims and conclude that they are caused by the shortages of SQL standard and inadequate implementations of the relational model in the current DBMSs. Problems that are presented in the paper make usage of the DBMSs in the repository systems more difficult. This paper also explains that relational system that follows the rules of the Third Manifesto is suitable for creating repository system and presents possible design alternatives. 1 INTRODUCTION technologies in one data model is ROSE (Hardwick & Spooner, 1989) that is experimental data "A repository is a shared database of information management system for the interactive engineering about the engineered artifacts." (Bernstein, 1998) applications. Bernstein (2003) envisions that object- These artifacts can be software engineering artifacts relational systems are good platform for the model like models and patterns. Repository system contains management systems. ORIENT (Zhang et al., 2001) a repository manager and a repository (database) and SFB-501 Reuse Repository (Mahnke & Ritter, (Bernstein, 1998). Bernstein (1998) explains that 2002) are examples of the repository systems that repository manager provides services for modeling, use a commercial ORDBMS. ORDBMS in this case retrieving, and managing objects in the repository is a system which uses a database language that and therefore must offer functions of the Database conforms to SQL:1999 or later standard.
    [Show full text]
  • Sixth Normal Form
    3 I January 2015 www.ijraset.com Volume 3 Issue I, January 2015 ISSN: 2321-9653 International Journal for Research in Applied Science & Engineering Technology (IJRASET) Sixth Normal Form Neha1, Sanjeev Kumar2 1M.Tech, 2Assistant Professor, Department of CSE, Shri Balwant College of Engineering &Technology, DCRUST University Abstract – Sixth Normal Form (6NF) is a term used in relational database theory by Christopher Date to describe databases which decompose relational variables to irreducible elements. While this form may be unimportant for non-temporal data, it is certainly important when maintaining data containing temporal variables of a point-in-time or interval nature. With the advent of Data Warehousing 2.0 (DW 2.0), there is now an increased emphasis on using fully-temporalized databases in the context of data warehousing, in particular with next generation approaches such as Anchor Modeling . In this paper, we will explore the concepts of temporal data, 6NF conceptual database models, and their relationship with DW 2.0. Further, we will also evaluate Anchor Modeling as a conceptual design method in which to capture temporal data. Using these concepts, we will indicate a path forward for evaluating a possible translation of 6NF-compliant data into an eXtensible Markup Language (XML) Schema for the purpose of describing and presenting such data to disparate systems in a structured format suitable for data exchange. Keywords :, 6NF,SQL,DKNF,XML,Semantic data change, Valid Time, Transaction Time, DFM I. INTRODUCTION Normalization is the process of restructuring the logical data model of a database to eliminate redundancy, organize data efficiently and reduce repeating data and to reduce the potential for anomalies during data operations.
    [Show full text]
  • Translating Data Between Xml Schema and 6Nf Conceptual Models
    Georgia Southern University Digital Commons@Georgia Southern Electronic Theses and Dissertations Graduate Studies, Jack N. Averitt College of Spring 2012 Translating Data Between Xml Schema and 6Nf Conceptual Models Curtis Maitland Knowles Follow this and additional works at: https://digitalcommons.georgiasouthern.edu/etd Recommended Citation Knowles, Curtis Maitland, "Translating Data Between Xml Schema and 6Nf Conceptual Models" (2012). Electronic Theses and Dissertations. 688. https://digitalcommons.georgiasouthern.edu/etd/688 This thesis (open access) is brought to you for free and open access by the Graduate Studies, Jack N. Averitt College of at Digital Commons@Georgia Southern. It has been accepted for inclusion in Electronic Theses and Dissertations by an authorized administrator of Digital Commons@Georgia Southern. For more information, please contact [email protected]. 1 TRANSLATING DATA BETWEEN XML SCHEMA AND 6NF CONCEPTUAL MODELS by CURTIS M. KNOWLES (Under the Direction of Vladan Jovanovic) ABSTRACT Sixth Normal Form (6NF) is a term used in relational database theory by Christopher Date to describe databases which decompose relational variables to irreducible elements. While this form may be unimportant for non-temporal data, it is certainly important for data containing temporal variables of a point-in-time or interval nature. With the advent of Data Warehousing 2.0 (DW 2.0), there is now an increased emphasis on using fully-temporalized databases in the context of data warehousing, in particular with approaches such as the Anchor Model and Data Vault. In this work, we will explore the concepts of temporal data, 6NF conceptual database models, and their relationship with DW 2.0. Further, we will evaluate the Anchor Model and Data Vault as design methods in which to capture temporal data.
    [Show full text]
  • A Mapping of SPARQL Onto Conventional SQL
    A Mapping of SPARQL Onto Conventional SQL Eric Prud'hommeaux, Alexandre Bertails World Wide Web Consortium (W3C) {eric,bertails}@w3.org http://www.w3.org/ Abstract. This paper documents a semantics for expressing relational data as an RDF graph [RDF] and an algebra for mapping SPARQL SELECT queries over that RDF to SQL queries over the original rela- tional data. The RDF graph, called the stem graph, is constructed from the relational structure and a URI identifier called a stem URI. The al- gebra specifies a function taking a stem URI, a relational schema and a SPARQL query over the corresponding stem graph, and emitting a re- lational query, which, when executed over the relational data, produces the same solutions at the SPARQL query executed over the stem graph. Relational databases exposed on the Semantic Web can be queried with SPARQL with the same performance as with SQL. Key words: Semantic Web, SPARQL, SQL, RDF 1 Introduction Motivations to bridge SPARQL and SQL abound: science, technology and busi- ness need to integrate more and more diverse data sources; the far majority of data that we expect machines to interpret are in relational databases; SQL fed- eration extensions like SchemaSQL [SSQL] don't place these databases in the more expressive Semantic Web; etc. These points have motivated many devel- opers to produce mapping tools, but robustness and performance have been a problem, in part because of a lack of a standard semantics for this mapping. In order to draw the desired investment in the Semantic Web, we need to match the performance of conventional relational databases.
    [Show full text]
  • To Be Is to Be a Value of a Variable by C. J. Date with Apologies To
    T o B e I s t o B e a Value of a Variable by C. J. Date with apologies to George Boolos and his book Logic, Logic, and Logic (I cribbed the title of this paper from an essay in that book) If we want things to stay as they are, things will have to change —Giuseppe di Lampedusa "Change" is scientific, "progress" is ethical; change is indubitable, whereas progress is a matter of controversy —Bertrand Russell July 17th, 2006 ABSTRACT In reference [1], two writers, referred to herein as Critics A and B, criticize The Third Manifesto for its support for relation variables and relational assignment. This paper is a response to that criticism. Readers are expected to be familiar with the following concepts and terminology: A relation variable (relvar for short) is a variable whose permitted values are relation values (relations for short). Relational assignment is an operation by which some relation r is assigned to some relvar R. Reference [14] explains these notions in detail, using a language called Tutorial D as a basis for examples. Why we want relvars Critic A's objections Critic B's objections Multiple assignment Database values and variables Concluding remarks Copyright © C. J. Date 2006 page 1 References WHY WE WANT RELVARS As noted in the abstract, the term relvar is short for relation variable. It was coined by Hugh Darwen and myself in reference [9], the first published version of The Third Manifesto; Codd's first papers on the relational model [3-4] used the term time-varying relation instead, but "time- varying relations" are just relvars by another name.
    [Show full text]
  • CS253:HACD.2 Temporal Data and the Relational Model Notes Keyed to Slides
    File: CS253-TDATRM-Notes.doc Printed at: 16:32 on Wednesday, 20 October, 2010 CS253:HACD.2 Temporal Data and The Relational Model Notes keyed to slides 1. Cover slide The chapter in Date first appeared in his 7th edition, as Chapter 22, but the chapter was quite heavily revised for the 8th edition. There is an unfortunate typographical error on page 744. In the first bulleted paragraph (“The expanded form ...”), delete the last three words, “defined as follows:”. 2. Temporal Data and The Relational Model In particular, none of the leading SQL vendors (IBM, Oracle, Microsoft, Sybase ...) have implemented SQL extensions to solve the problems we describe. There was significant interest for a time in the second half of the 1990s, when an incomplete working draft for an international standard for such extensions was produced by the SQL standards committee. However, the project was abandoned when support for XML documents in SQL databases became a higher priority to the industry than temporal extensions. (Some people question the industry’s priorities!) MighTyD In the academic year 2005-6 a team of computer science undergraduates at Warwick University, for their final-year project, made the beginnings of a prototype implementation of Tutorial D with some of the temporal extensions taught in CS253. They call their product MighTyD. Like Rel, it is written in Java. It is available for free download at http://sourceforge.net/projects/mightyd. If by any chance you might be interested in continuing the work on MighTyD, please arrange a meeting with me to discuss ideas. 3. The Book’s Aims Imagine, for example, a database from which nothing is ever deleted and in which every record is somehow timestamped to show the time at which it arrived and, if its information is no longer current, the time at which it was superseded or deleted.
    [Show full text]
  • Chapter 3 the Relational Database Model
    11e Database Systems Design, Implementation, and Management Coronel | Morris Chapter 3 The Relational Database Model ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Learning Objectives In this chapter, one will learn: That the relational database model offers a logical view of data About the relational model’s basic component: relations That relations are logical constructs composed of rows (tuples) and columns (attributes) That relations are implemented as tables in a relational DBMS ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 2 Learning Objectives In this chapter, one will learn: About relational database operators, the data dictionary, and the system catalog How data redundancy is handled in the relational database model Why indexing is important ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 3 A Logical View of Data Relational database model enables logical representation of the data and its relationships Logical simplicity yields simple and effective database design methodologies Facilitated by the creation of data relationships based on a logical construct called a relation ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 4 Table 3.1 - Characteristics of a Relational Table ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
    [Show full text]
  • Database Management Systems Ebooks for All Edition (
    Database Management Systems eBooks For All Edition (www.ebooks-for-all.com) PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sun, 20 Oct 2013 01:48:50 UTC Contents Articles Database 1 Database model 16 Database normalization 23 Database storage structures 31 Distributed database 33 Federated database system 36 Referential integrity 40 Relational algebra 41 Relational calculus 53 Relational database 53 Relational database management system 57 Relational model 59 Object-relational database 69 Transaction processing 72 Concepts 76 ACID 76 Create, read, update and delete 79 Null (SQL) 80 Candidate key 96 Foreign key 98 Unique key 102 Superkey 105 Surrogate key 107 Armstrong's axioms 111 Objects 113 Relation (database) 113 Table (database) 115 Column (database) 116 Row (database) 117 View (SQL) 118 Database transaction 120 Transaction log 123 Database trigger 124 Database index 130 Stored procedure 135 Cursor (databases) 138 Partition (database) 143 Components 145 Concurrency control 145 Data dictionary 152 Java Database Connectivity 154 XQuery API for Java 157 ODBC 163 Query language 169 Query optimization 170 Query plan 173 Functions 175 Database administration and automation 175 Replication (computing) 177 Database Products 183 Comparison of object database management systems 183 Comparison of object-relational database management systems 185 List of relational database management systems 187 Comparison of relational database management systems 190 Document-oriented database 213 Graph database 217 NoSQL 226 NewSQL 232 References Article Sources and Contributors 234 Image Sources, Licenses and Contributors 240 Article Licenses License 241 Database 1 Database A database is an organized collection of data.
    [Show full text]
  • 2006 Fall CS157A Final Exam Study Guide
    2006 Fall CS157A Final Exam Study Guide Prof. Sin-Min Lee Note: Please bring 882E scantron! The exam will be comprehensive. Test material will be drawn from the text book, lectures, assignments and any supplementary material provided in class. You should review the following: All the lecture notes All the assigned readings (if you don't have the text book, then the lecture notes will suffice) Three midterm exams Important Date Information Section 3 Wednesday, December 13 0715-0930 PREPARE FOR WRITING EXAMINATION 1. STUDY-- Read the material which the exam will cover. A. Formulate possible study questions, use any study questions made available to you. B. Arrange your material (Notes, Note cards) so that you can anticipate an answer to one or more of the study questions. 2. Know the exam conditions and be prepared to meet those conditions. (Since you most likely will have limited time, select and arrange those materials which will best help you present what you know about the subject and help you show that you can control that material. 3. Before writing the exam, read all the questions. Choose that question which comes closest to those you formulated on your own and which most closely relates to those materials you have studied, reviewed, and arranged. 4. While writing the exam-- A. Be sure to CLEARLY and CONCISELY and PRECISELY answer the question. B. Make sure the discussion subsequent to your answer follows clearly from your answer: Your topic sentences should relate back to your answer. Your topic sentences should be supported by CLEAR, SPECIFIC references to your materials (i.e., your sources).
    [Show full text]
  • Relational Databases and SQL
    Relational databases and SQL Matthew J. Graham CACR Methods of Computational Science Caltech, 29 January 2009 mat!ew graham relational model Proposed by E. F. Codd in 1969 An attribute is an ordered pair of attribute name and type (domain) name An attribute value is a specific valid value for the attribute type A tuple is an unordered set of attribute values identified by their names A relation is defined as an unordered set of n-tuples mat!ew graham databases A relation consists of a heading (a set of attributes) and a body (n-tuples) A relvar is a named variable of some specific relation type and is always associated with some relation of that type A relational database is a set of relvars and the result of any query is a relation A table is an accepted representation of a relation: attribute => column, tuple => row mat!ew graham structured query language Appeared in 1974 from IBM First standard published in 1986; most recent in 2006 SQL92 is taken to be default standard Different flavours: Microsoft/Sybase Transact-SQL MySQL MySQL Oracle PL/SQL PostgreSQL PL/pgSQL mat!ew graham create CREATE DATABASE databaseName CREATE TABLE tableName (name1 type1, name2 type2, . ) CREATE TABLE star (name varchar(20), ra float, dec float, vmag float) Data types: boolean, bit, tinyint, smallint, int, bigint; • real/float, double, decimal; • char, varchar, text, binary, blob, longblob; • date, time, datetime, timestamp • CREATE TABLE star (name varchar(20) not null, ra float default 0, ...) mat!ew graham keys CREATE TABLE star (name varchar(20), ra float, dec float, vmag float, CONSTRAINT PRIMARY KEY (name)) A primary key is a unique identifier for a row and is automatically not null CREATE TABLE star (name varchar(20), ..., stellarType varchar(8), CONSTRAINT stellarType_fk FOREIGN KEY (stellarType) REFERENCES stellarTypes(id)) A foreign key is a referential constraint between two tables identifying a column in one table that refers to a column in another table.
    [Show full text]
  • Missing Data in the Relational Model
    Virginia Commonwealth University VCU Scholars Compass Theses and Dissertations Graduate School 2013 Missing Data in the Relational Model Marion Morrissett Virginia Commonwealth University Follow this and additional works at: https://scholarscompass.vcu.edu/etd Part of the Engineering Commons © The Author Downloaded from https://scholarscompass.vcu.edu/etd/3004 This Dissertation is brought to you for free and open access by the Graduate School at VCU Scholars Compass. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of VCU Scholars Compass. For more information, please contact [email protected]. c Marion R. Morrissett, 2013 All Rights Reserved Dedication This research is dedicated to content, data with missing values that represent the always-complete real world. And to structure, the relational model created and developed by the scientists, researchers, teachers, and practitioners who populate my test case database. MISSING DATA IN THE RELATIONAL MODEL A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy at Virginia Commonwealth University. by MARION R. MORRISSETT Bachelor of Arts, University of Virginia, 1972 Mathematical Sciences Certificate in Computer Science, Virginia Commonwealth University, 1987 Master of Science, Virginia Commonwealth University, 1994 Doctor of Philosophy, Virginia Commonwealth University, 2013 Director: LORRAINE M. PARKER ASSOCIATE PROFESSOR, DEPARTMENT OF COMPUTER SCIENCE Virginia Commonwealth University Richmond, Virginia May, 2013 ii Acknowledgments Many people have provided help and support during this work. My friends and family listened to my dissertation status reports, the programmers among them heard the technical details and all were patient. John Cookson, Tom Nicholls, and Paul Bruggeman shared their experience with problems created and solved by computers.
    [Show full text]
  • The Relational Model: a Tutorial
    The Relational Model: a Tutorial Hugh Darwen This is an informal description of E.F. Codd’s model [2] that was originally drafted as part my contribution to a special edition of the IEEE Annals of the History of Computing devoted to the history of relational model. It turned out to be too long and its level of detail was not thought to be suited to my article, which was to serve as the introductory article to that edition. The terminology is that used in The Third Manifesto by Chris Date and myself. Our terminology is mostly the same as Codd’s but we made a few changes in an attempt to clear up some matters that had given rise to confusion over the years. The notation used in my examples is taken from Tutorial D [3,4], a language Chris Date and I devised as an example for teaching purposes. My description is in three main sections. First, in Definitions, I describe the objects that constitute a relational database. Then, in Relational Algebra, I describe the operators that are defined in the model for operating on those objects. Finally, Database Integrity covers the mechanism the model prescribes for maintaining consistency in a database. Differences between the current definition and Codd’s original are mentioned in footnotes. Definitions What’s a relation? Consider the sentence, “Student S1, named Anne, is enrolled on course C1”. Because it is the kind of sentence of which we can say, “That’s true”, or “That’s false”, it denotes a proposition. A predicate is a generalized form of a proposition in which some designators (such as S1, Anne, and C1) are replaced by symbols denoting parameters,1 as in “Student StudentId, named Name, is enrolled on course CourseId.” That sentence no longer denotes a proposition, but nevertheless it has the same declarative form as a proposition and thus denotes a predicate.
    [Show full text]