Chapter 3- RelModel (8-26) - The Relational Model Database...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. “Legacy systems” in older models Database Management Systems, R. Ramakrishnan and J. Gehrke 2 E.G., IBM’s IMS Competitor in the early 90s: object-oriented model A synthesis: object-relational model Oracle, DB2 XML Relational Database: Definitions Relational database : a set of relations Relation: made up of two parts: Schema : specifies name of relation, plus name and type of each column Database Management Systems, R. Ramakrishnan and J. Gehrke 3 type of each column. E.G. Students( sid : string, name : string, login : string, age : integer, gpa : real). Instance : a table , with rows and columns. #Rows = cardinality , #fields = degree / arity. Can think of a relation as a set of rows or tuples (i.e., all rows are distinct).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example Instance of Students Relation sid name login age gpa 53666 Jones jones@cs 18 3.4 53688 Smith smith@eecs 18 3.2 Database Management Systems, R. Ramakrishnan and J. Gehrke 4 53650 Smith smith@math 19 3.8 Cardinality = 3, degree = 5, all rows distinct Do all columns in a relation instance have to be distinct? Logical DB Design: ER to Relational Entity sets to tables. Database Management Systems, R. Ramakrishnan and J. Gehrke 5 CREATE TABLE Employees (ssn CHAR(11), name CHAR(20), lot INTEGER, PRIMARY KEY (ssn) ) Employees ssn name lot Example Instance ssn name lot Employees Database Management Systems, R. Ramakrishnan and J. Gehrke 6 0983763423 John 10 9384392483 Jane 10 3743923483 Jill 20
Background image of page 2
Integrity Constraints (ICs) IC: condition that must be true for any instance of the database – Domain constraints Database Management Systems, R. Ramakrishnan and J. Gehrke 7 – Key constraints – Foreign key constraints (later) A legal instance of a relation is one that satisfies all specified ICs. DBMS should not allow illegal instances Avoids data entry errors too! Primary Key Constraints A set of fields is a superkey for a relation if : 1. No two distinct tuples can have same values in all fields A set of fields is a key if: 1 The set of fields is a superkey Database Management Systems, R. Ramakrishnan and J. Gehrke 8 1. 2. No proper subset of the set of fields is a superkey If there’s >1 key for a relation, one of the keys is chosen (by DBA) to be the primary key . E.g.,
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

Chapter 3- RelModel (8-26) - The Relational Model Database...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online