Relational Schemas and Predicate Logic: Notation.

Slides:



Advertisements
Similar presentations
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
Advertisements

Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Conceptual Design using the Entity-Relationship Model
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Chapter 3 : Relational Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Book Chapter 3 (part 2 ) From ER to Relational Model.
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
The Entity-Relationship (ER) Model
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Comp3300/fall021 The Entity-Relationship Model Chapter 2 What are the steps in designing a database ? Why is the ER model used to create an initial design?
The Entity-Relationship Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
CSC 411/511: DBMS Design 1 1 Dr. Nan WangCSC411_L3_Relational Model 1 The Relational Model (Chapter 3)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
D ATABASE S YSTEMS I A DMIN S TUFF. 2 Mid-term exam Tuesday, Oct 2:30pm Room 3005 (usual room) Closed book No cheating, blah blah No class on Oct.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.) –What are the entities.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.
Conceptual Design Using the Entity-Relationship (ER) Model
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
ISOM MIS710 Module 1a Data and Process Modeling Arijit Sengupta.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
1 The Relational Model Chapter 3. 2 Why Study the Relational Model?  Most widely used model.  Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3 Modified by Donghui Zhang.
1 The Relational Model Chapter 3. 2 Why Study the Relational Model?  Most widely used model  Vendors: IBM, Informix, Microsoft, Oracle, Sybase  Recent.
1 The Entity-Relationship Model Chapter 6. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Entity-Relationship Model Ch. 3
1 The Relational Model Chapter 3. 2 Why Study the Relational Model?  Most widely used model.  Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc.
ICS 321 Spring 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/7/20111Lipyeow.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
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.
The Relational Model1 ER-to-Relational Mapping and Views.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 Conceptual Design using the Entity- Relationship Model.
CMPT 258 Database Systems The Relationship Model PartII (Chapter 3)
Lecture 3 Book Chapter 3 (part 2 ) From ER to Relational.
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
The Relational Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY.
ICS 421 Spring 2010 Relational Model & Normal Forms Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/19/20101Lipyeow.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
ENTITY- RELATIONSHIP MODELLING 1 All rights reserved by
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
COP Introduction to Database Structures
CAS CS 460/660 Data Base Design Entity/Relationship Model
COP Introduction to Database Structures
MODELS OF DATABASE AND DATABASE DESIGN
Translation of ER-diagram into Relational Schema
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship (ER) Model
Presentation transcript:

Relational Schemas and Predicate Logic: Notation

Relations Let E1,..,En be sets of entities or objects (we may have Ei = Ej). The Cartesian product E1 x … x En is the set of tuples of the form (e1,..,en) where ei is in set Ei. A relation R on E1,..,En is a subset of the Cartesian product E1 x … x En. We say that n is the arity of the relation. Note that a relation may be unary.

Relational Schemas A schema specifies a finite set of relations R1,..Rn with additional structure: Each column/field in a relation gets a name (can also just use position) and a domain. A subset of fields is identified as the key. The non-key fields are often called (descriptive) attributes. The values of the attributes are determined by the values of the key field. Common Notation –Student(Name:string,GPA:numeric,Age:integer) –Registered(Name:string,Course:string,grade:nume ric)

ER Model: Entities Entity: Real-world object distinguishable from other objects. An entity is described (in DB) using a set of attributes. Entity Set: A collection of similar entities. E.g., all employees. – All entities in an entity set have the same set of attributes. – Each entity set has a key. – Each attribute has a domain. – A key defines the values of attributes---the attributes are functions of the keys. Employees ssn name lot

ER Model: Relationships Relationship: Association among two or more entities. E.g., Attishoo works in Pharmacy department. Relationship Set: Collection of similar relationships. – An n-ary relationship set R relates n entity sets E1... En; each relationship in R involves entities e1,..., en Same entity set could participate in different relationship sets, or in different “roles” in same set. lot dname budget did since name Works_In DepartmentsEmployees ssn Reports_To lot name Employees subor- dinate super- visor ssn

Notes on ER relationships Note that relationships can have descriptive attributes too. The values of the descriptive attributes are determined once we have identified the entities involved: grade(Joe,CMPT354). The fields that identify the entities involved are callled foreign key pointers.

Relational Instance and Finite Models A relational instance is a relational schema + set of tuples specified for each relation. The list of relations (with tuples specified, but without field names and key constraints) is called a finite model in logic.

Graphical Visualization A graph on set S is a binary symmetic relation over S x S. If the relation instance contains only one binary symmetric relation, it can be visualized as a graph whose edges and nodes are annotated with the values of descriptive attributes. Classic social network analysis considers only the graph structure, not the attributes.

Translating Schemas Into Logic: no functions Each relation of arity n  predicate symbol with n arguments. E.g., “A student with GPA 3.0 is younger than 40”  Student(S,G,A) AND G = 3.0  A < 40. Pros: –Simple Translation. –Simple logic. Cons: –Loses information about key fields. –Not always natural to read.

Translating Schemas Into Logic: Functions Introduce one function symbol for each descriptive attribute. The arguments are the key fields. E.g., Age(S), grade(S,C). Also: S.age,Registered.grade. E.g., “A student with GPA 3.0 is younger than 40”  GPA(S) = 3.0  Age(S) < 40. Pros: –Keeps information about keys and foreign keys. –Natural to read. Cons: a bit more complex mathematically.

Formal definitions in logic Use the function-free formulation, with predicate symbols R1,..,Rn. The language contains a set of constants and variables. A term is a constant or a variable. An atom is: –a predicate symbol with the required numbers of terms, e.g. Student(N,G,40), Student(Jack,3.0,40). –A comparison of terms, e.g. X > 3, X = Y, 5 > 1. A literal is an atom or a negated atom.

Clauses A clause is a set of literals. The negated literals are called the body, the positive ones the head. A clause is often written in implication form: b1 AND b2  h1. Also h1 :- b1,b2. A clause with a single positive literal is a Horn clause.