Introduction to modeling

Similar documents
Microsoft s new database modeling tool: Part 1

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Unit 5: Object-Role Modeling (ORM)

Relational Database Basics Review

Subtyping: conceptual and logical issues

Object-Role Modeling: an overview

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Database Design. Goal: specification of database schema Methodology: E-R Model is viewed as a set of

The Relational Data Model: Structure

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

The process of database development. Logical model: relational DBMS. Relation

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

Logical Schema Design: The Relational Data Model


Fundamentals of Database Design

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Database Design Methodology

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

UML Data Models From An ORM Perspective: Part 1

How To Manage Data In A Database System

IT2305 Database Systems I (Compulsory)

The Entity-Relationship Model

There are five fields or columns, with names and types as shown above.

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Entity-Relationship Model

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

3. Relational Model and Relational Algebra

Why & How: Business Data Modelling. It should be a requirement of the job that business analysts document process AND data requirements

A brief overview of developing a conceptual data model as the first step in creating a relational database.

Data Modeling Basics

Databases What the Specification Says

IT2304: Database Systems 1 (DBS 1)

Lecture 6. SQL, Logical DB Design

Normalization in Database Design

Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Database Design. Adrienne Watt. Port Moody

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Data Modeling. Database Systems: The Complete Book Ch ,

How To Write A Diagram

Once the schema has been designed, it can be implemented in the RDBMS.

AS LEVEL Computer Application Databases

The core theory of relational databases. Bibliography

XV. The Entity-Relationship Model

Modeling for Data and Business Rules

EECS 647: Introduction to Database Systems

Databases and BigData

Relational Database Concepts

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

IV. The (Extended) Entity-Relationship Model

Modern Systems Analysis and Design

Database Design Methodology

Database Design Process. Databases - Entity-Relationship Modelling. Requirements Analysis. Database Design

Conceptual Design Using the Entity-Relationship (ER) Model

Introduction to normalization. Introduction to normalization

Database Design and Database Programming with SQL - 5 Day In Class Event Day 1 Activity Start Time Length


Database Fundamentals: 1

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Lecture Notes INFORMATION RESOURCES

The Relational Model. Why Study the Relational Model?

Functional Dependency and Normalization for Relational Databases

Data Analysis 1. SET08104 Database Systems. Napier University

Exercise 1: Relational Model

The Relational Data Model and Relational Database Constraints

MCQs~Databases~Relational Model and Normalization

Normalization. Reduces the liklihood of anomolies

Overview RDBMS-ORDBMS- OODBMS

Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

SQL Server. 1. What is RDBMS?

Ontological Modeling: Part 6

Functional Dependencies and Normalization

PL/SQL Overview. Basic Structure and Syntax of PL/SQL

Database Design Patterns. Winter Lecture 24

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

Lecture 12: Entity Relationship Modelling

A Metamodel for Master Data

AVOIDANCE OF CYCLICAL REFERENCE OF FOREIGN KEYS IN DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL

How To Understand And Solve Algebraic Equations

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model

Objectives of SQL. Terminology for Relational Model. Introduction to SQL

Introduction to Databases

2. Basic Relational Data Model

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

Database IST400/600. Jian Qin. A collection of data? A computer system? Everything you collected for your group project?

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Review: Participation Constraints

Entity Relationship Diagram

Fundamentals of Database System

Optimizing Performance. Training Division New Delhi

Transcription:

Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition (ISBN: 978-0-12-373568-3), published by Morgan Kaufmann Publishers. 1

Where are we? # Title Date 1 Introduction 07.10.2013 2 ORM modeling 21.10.2013 3 Relational modeling 04.11.2013 4 ER modeling 18.11.2013 5 OO modeling 02.12.2013 6 Process modeling 16.12.2013 7 Service modeling 13.01.2014 8 Exam 27.01.2014 2

Relational model Data Model Set of concepts to describe the structure of a database Relational Model The database can be regarded as a collection of tables Key concepts: Relation: A mathematical concept that can be interpreted as a table of values Relational Database: A collection of relations null indicates that no value is stored in that position 3

Terminology Domain: An set of atomic values. Atomic means that items can not themselves be sets Attribute: A name of a role played by a domain (column name) If A is an attribute, we write dom(a) = D to express that A is a role played by the domain D Relational schema R(A1,A2,,An): A named set of attributes R = {A1,A2,,An} where R is the relation name n is the arity of the relationship Instance of a relational schema R(A1,A2,,An): A set {t1,t2,,tm} ("rows") where each t k is a n-tuple of values from the domain of A1,A2,,An Relation: A relational schema with an associated instance 4

Example Relation schema Relation name attribute Employee empnr salary tax 001 2000 300 002 2300 500 003 3000 550 instances Horizontal layout notation: the table name precedes a parenthesized list of column names, separated by commas: Employee (empnr, salary, tax ) Tuppel 5

Remarks Tuples order in relations is arbitrarily The order of values within a tuple is not arbitrary In one relations there cannot be two identical tuples A domain can be finite or infinite Two attributes in a relational schema can have the same domain, but not the same name 6

Uniqueness constraints on relational columns In horizontal layout, uniqueness constraints on relational columns are shown by underlining. Each unique column, or unique column combination, provides a candidate key for identifying rows in a table. A key is a minimal set of uniquely constrained attributes, i.e. if an attribute is removed from a compound key, the remaining attributes are not spanned by a uniqueness constraint. If there is only one candidate key, this is automatically the primary key, e.g. Employee (empnr, salary, tax) Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 7

Uniqueness constraints on relational columns If more than one candidate key exists, one of these must be selected as the primary key. The others are then called alternate keys or secondary keys. Primary keys are doubly underlined if alternate keys exist, e.g. Employee (empnr, empname, deptcode, salary, tax) A column that does not allow null values is said to be mandatory (A column that does allow null values is said to be optional. Optional columns are enclosed in square brackets, e.g. Employee (empnr, salary, [tax]) Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 8

Mapping ORM models 1 2000 Employee (.nr) 2 2300 has paid 1 500 Salary (E U R:) Tax (E U R:) => Employee (empnr, salary, [tax]) 1 2000 500 2 2300? Relational model often requires different facts about the same object to be stored in different tables Mandatory role constraints are captured by making their columns mandatory in their table, and running a subset constraint from other tables (if any) that contain facts about that object type Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 9

Mapping ORM models has Salary (E U R:) Employee (empnr, salary, [tax]) Employee (.nr) paid works in Project (.Id) Tax (E U R:) => WorksIn (empnr, project) empnr in the WorksIn table is a foreign key 10

Integrity rules Entity integrity rule: primary keys contain no nulls (i.e., each column in a primary key is a mandatory column for its table). Referential integrity rule: each non-null value of a foreign key must match the value of some primary key Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 11

Relational schema representations Relational schema in horizontal layout and some vertical layouts: Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 12

Relational schema representations Relational schema in SQL: Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 13

Relational Mapping Procedure Rmap Several different relational designs may be possible for a given conceptual schema But the resulting relational design should be correct, efficient, and clear A high priority is placed on simplifying the enforcement of constraints at update time Avoid redundancy, but this can lead to more tables in the design For efficiency, number of tables should be kept down to an acceptable limit Rmap procedure guarantees a redundancy-free relational design and includes strategies to restrict the number of tables Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 14

Rmap basic rules Typically each row of a relational table stores one or more elementary facts Avoiding redundancy in tables: ensure that each fact type maps to only one table in such a way that its instances appear only once Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 15

Rmap basic rules Two basic rules: 1. Each fact type with a compound, internal uniqueness constraint maps to a separate table by itself, keyed on the uniqueness constraint 2. Fact types with functional roles (i.e. roles that have a simple uniqueness constraint) attached to the same object type are grouped into the same table, keyed on the object type s identifier Material on this slide based on Ch 11.2 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 16

Rmap - Mapping 1:1 Associations When no additional functional roles: When additional functional roles: Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 17

Rmap - Mapping 1:1 Associations Procedure: Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 18

Rmap Mapping External Uniqueness Constraints Composite primary identifier, and functional fact type: Composite primary identifier and nonfunctional fact type: Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 19

Rmap Mapping External Uniqueness Constraints Composite secondary identifier and functional fact type: External uniqueness constraint involving an m:n fact type: Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 20

Rmap Mapping Objectified Associations Initially treat the objectified association as a black box (i.e. remove its identification scheme) Group fact types in the usual way Unpack the black box into its component attributes Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 21

Rmap Mapping Subtypes Subtyping mapping: Absorption: absorb the subtypes back into the (top) supertype (giving qualified optional roles), group the fact types as usual, and then add the subtyping constraints as textual qualifications Separation: separate tables for facts with subtype specific functional roles Partition: may be used when the subtypes form a partition of their supertype Subtype constraints on functional roles map to qualified optionals: Nonfunctional fact type of subtypes map to separate tables: Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 22

Basic Rmap procedure Material on this slide based on Ch 11.3 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition 23

Resources Chapter 11 in Halpin, T. & Morgan, T. 2008, Information Modeling and Relational Databases, Second Edition (ISBN: 978-0-12-373568-3), published by Morgan Kaufmann Publishers. 24

Next lecture # Title Date 1 Introduction 07.10.2013 2 ORM modeling 21.10.2013 3 Relational modeling 04.11.2013 4 ER modeling 18.11.2013 5 OO modeling 02.12.2013 6 Process modeling 16.12.2013 7 Service modeling 13.01.2014 8 Exam 27.01.2014 25

Questions? 26