Introduction to Relational Databases

Slides:



Advertisements
Similar presentations
Relational Algebra Part II
Advertisements

1 Introduction to Relational Databases Hugh Darwen CS252.HACD: Fundamentals of Relational Databases.
1 Constraints and Updating Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section 7: Constraints.
1 Relational Algebra, Part III, and Other Operators Hugh Darwen CS252.HACD: Fundamentals of Relational.
1 Fundamentals of Relational Databases Hugh Darwen CS252.HACD: Relational Database Theory (focussing.
1 Relational Algebra, Principles and Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases.
1 Values, Types, Variables, Operators Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section.
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
1 Constraints, Triggers and Active Databases Chapter 9.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
The Relational Model. Introduction Introduced by Ted Codd at IBM Research in 1970 The relational model represents data in the form of table. Main concept.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
Chapter 3 An Introduction to Relational Databases.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
Chapter 6 Relations. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.6-2 Topics in this Chapter Tuples Relation Types Relation Values Relation.
Security and Integrity
Chapter 6 Relations. Topics in this Chapter Tuples Relation Types Relation Values Relation Variables SQL Facilities.
The Relational Model These slides are based on the slides of your text book.
Chapter 3 An Introduction to Relational Databases.
Introduction to Database Systems
Page 1 Topic 4 Relational Databases CPS510 Database Systems Abdolreza Abhari School of Computer Science Ryerson University.
1 Copyright © 2004, Oracle. All rights reserved. Introduction.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
Assignment 1 Uploaded to course website Due next Tuesday, Sep 1, at 11:59pm.
Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Chapter 1. Getting Started IST 210: Organization of Data IST2101.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Chapter 3 An Introduction to Relational Databases.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Fundamental of Database Systems
Database System Implementation CSE 507
CompSci 280 S Introduction to Software Development
COP Introduction to Database Structures
Databases We are particularly interested in relational databases
Chapter 6 - Database Implementation and Use
Foreign Keys Local and Global Constraints Triggers
STRUCTURE OF PRESENTATION :
STRUCTURE OF PRESENTATION :
Information Systems Database Management
STRUCTURE OF PRESENTATION :
Translation of ER-diagram into Relational Schema
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Introduction lecture1.
Accounting System Design
Database.
The Relational Model Relational Data Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Advanced SQL: Views & Triggers
CMPT 354: Database System I
Accounting System Design
CSC 453 Database Technologies
SQL-1 Week 8-9.
CS3220 Web and Internet Programming SQL and MySQL
A Very Brief Introduction to Relational Databases
SQL – Constraints & Triggers
Lectures 2: Introduction to SQL 1
CS3220 Web and Internet Programming SQL and MySQL
DATABASE Purpose of database
STRUCTURE OF PRESENTATION :
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
CSC 453 Database Technologies
Database 2.
CS 405G: Introduction to Database Systems
Presentation transcript:

Introduction to Relational Databases HACD.1: Introduction to Relational Databases 08/12/2018 Introduction to Relational Databases Fundamentals of Relational Databases Section 1: Introduction CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 Some Preliminaries The theory taught in this part of the course was originally devised by Edgar F. Codd in 1969. His seminal paper (1970) was entitled A Relational Model of Data for Large Shared Data Banks. We will use a language called Tutorial D for examples and exercises. We will use Rel, an implementation of Tutorial D, for our on-line work. CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 What Is a Database? An organised, machine-readable collection of symbols, to be interpreted as a true account of some enterprise. Machine-updatable, too … … so a database is also a collection of variables. A database is typically available to a community of users, with possibly varying requirements. CS252: Fundamentals of Relational Databases

“Organised Collection of Symbols” HACD.1: Introduction to Relational Databases 08/12/2018 “Organised Collection of Symbols” For example: StudentId Name CourseId S1 Anne C1 C2 S2 Boris S3 Cindy C3 The symbols are organised into rows and columns, thus forming a table. One of the rows is different in kind from the others. CS252: Fundamentals of Relational Databases

“To Be Interpreted as a True Account” HACD.1: Introduction to Relational Databases 08/12/2018 “To Be Interpreted as a True Account” For example (from the table just shown): StudentId Name CourseId S1 Anne C1 Perhaps those green symbols, organised as they are with respect to the blue ones, are to be understood to mean: “Student S1, named Anne, is enrolled on course C1.” CS252: Fundamentals of Relational Databases

“Collection of Variables” HACD.1: Introduction to Relational Databases 08/12/2018 “Collection of Variables” ENROLMENT StudentId Name CourseId S1 Anne C1 C2 S2 Boris S3 Cindy C3 S4 Devinder ENROLMENT is a variable. Perhaps the table we saw earlier was once its value. If so, it (the variable) has been updated since then (the row for S4 has been added). CS252: Fundamentals of Relational Databases

What Is a Relational Database? HACD.1: Introduction to Relational Databases 08/12/2018 What Is a Relational Database? A database whose symbols are organised into a collection of relations. Here is a relation, shown in tabular form: StudentId Name CourseId S1 Anne C1 C2 S2 Boris S3 Cindy C3 S4 Devinder Might be the value currently assigned to ENROLMENT, a relation variable (“relvar”). CS252: Fundamentals of Relational Databases

“Relation” not equal to “Table” HACD.1: Introduction to Relational Databases 08/12/2018 “Relation” not equal to “Table” This table is different from the one we have just seen, but it represents the same relation: Name StudentId CourseId Devinder S4 C1 Cindy S3 C3 Anne S1 Boris S2 C2 In other words, the relation represented does not depend on the order in which we place the rows or the columns in the table. CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 Anatomy of a Relation StudentId Name CourseId S1 Anne C1 attribute name attribute values n-tuple, or tuple. This is a 3-tuple. The tuples constitute the body of the relation. The number of tuples in the body is the cardinality of the relation. Heading (a set of attributes) The degree of this heading is 3, which is also the degree of the relation. CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 What Is a DBMS? A piece of software for managing databases and providing access to them. A DBMS responds to imperatives (“statements”) given by application programs, custom-written or general-purpose, executing on behalf of users. Imperatives are written in the database language of the DBMS (e.g., SQL). Responses include completion codes, messages and results of queries. CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 What Does a DBMS Do? In response to requests given by application programs: creates and destroys variables takes note of integrity rules (constraints) takes note of authorisations (who is allowed to do what, to what) updates variables (honouring constraints and authorisations) provides results of queries and more Now, how does a relational DBMS do these things? … CS252: Fundamentals of Relational Databases

Create and Destroy Variables HACD.1: Introduction to Relational Databases 08/12/2018 Create and Destroy Variables Creation (in Tutorial D): VAR ENROLMENT BASE RELATION { StudentId SID , Name CHAR, CourseId CID } KEY { StudentId, CourseId } ; Destruction: DROP VAR ENROLMENT ; CS252: Fundamentals of Relational Databases

Take Note of Integrity Rules HACD.1: Introduction to Relational Databases 08/12/2018 Take Note of Integrity Rules E.g., can’t have more than 20,000 enrolments altogether. In Tutorial D: CONSTRAINT MAX_ENROLMENTS COUNT ( ENROLMENT ) <= 20000 ; And if a constraint ceases to be applicable: DROP CONSTRAINT MAX_ENROLMENTS ; CS252: Fundamentals of Relational Databases

Take Note of Authorisations HACD.1: Introduction to Relational Databases 08/12/2018 Take Note of Authorisations E.g. (perhaps – but not in Tutorial D): PERMISSION U9_ENROLMENT FOR User9 TO READ ENROLMENT ; PERMISSION U8_ENROLMENT FOR User8 TO UPDATE ENROLMENT ; Permissions sometimes need to be withdrawn: DROP PERMISSION U9_ENROLMENT ; CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 Updates Variables E.g.: DELETE ENROLMENT WHERE StudentId = SID ( ‘S4’ ) ; UPDATE ENROLMENT WHERE StudentId = SID ( ‘S1’ ) Name := ‘Ann’ ; INSERT ENROLMENT RELATION { TUPLE { StudentId SID ( ‘S4’ ) , Name ‘Devinder’ , CourseId CID ( ‘C1’ ) } } ; CS252: Fundamentals of Relational Databases

Provides Results of Queries HACD.1: Introduction to Relational Databases 08/12/2018 Provides Results of Queries E.g.: Who is enrolled on course C1? (ENROLMENT WHERE CourseId = CID(‘C1’)) { StudentId, Name } The result is another relation! In tabular form: StudentId Name S1 Anne S2 Boris S4 Devinder CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 EXERCISE Consider this table: A B 1 2 3 4 5 6 7 8 9 ? Give three reasons why it cannot be representing a relation. CS252: Fundamentals of Relational Databases

HACD.1: Introduction to Relational Databases 08/12/2018 IMPORTANT BIT OF ADMIN Are you: an overseas student visiting for just one year, or doing a degree that is completely outside the CS department? (In which case you should complete an Unusual Option Form, obtainable from your dept secretary) If so, on exit from this lecture: Write your name, ITS userid, and course code on the sheet of paper provided. Otherwise you won’t get access to the software needed for the Worksheets! CS252: Fundamentals of Relational Databases