Conceptual Database Modeling

Similar documents
course: Database Systems (NDBI025) SS2017/18

Relational Model. Course A7B36DBS: Database Systems. Lecture 02: Martin Svoboda Irena Holubová Tomáš Skopal

Conceptual Modeling in ER and UML

Relational Model. Courses B0B36DBS, A4B33DS, A7B36DBS: Database Systems. Lecture 02: Martin Svoboda

Fundamentals of. Database Systems. Shamkant B. Navathe. College of Computing Georgia Institute of Technology PEARSON.

Introduction to Data Management. Lecture #2 (Big Picture, Cont.) Instructor: Chen Li

Chapter 2. Database Design. Database Systems p. 25/540

Database Systems. Sven Helmer. Database Systems p. 1/567

Relational Model. Courses B0B36DBS, A7B36DBS: Database Systems. Practical Class 03: Martin Svoboda

CSC 355 Database Systems

DATABASE MANAGEMENT SYSTEMS. UNIT I Introduction to Database Systems

doc. RNDr. Tomáš Skopal, Ph.D. Mgr. Martin Nečaský, Ph.D. RNDr. Michal Kopecký, Ph.D.

Introduction to Data Management. Lecture #2 (Big Picture, Cont.)

FUNDAMENTALS OF. Database S wctpmc. Shamkant B. Navathe College of Computing Georgia Institute of Technology. Addison-Wesley


Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

CS 146 Database Systems

Systems:;-'./'--'.; r. Ramez Elmasri Department of Computer Science and Engineering The University of Texas at Arlington

Course Outline Faculty of Computing and Information Technology

CSE 132A. Database Systems Principles

DB Basic Concepts. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Introduction to Data Management. Lecture #2 Intro II & Data Models I

Fundarnentals of. Sharnkant B. Navathe College of Computing Georgia Institute of Technology

DATABASTEKNIK - 1DL116

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

II. Data Models. Importance of Data Models. Entity Set (and its attributes) Data Modeling and Data Models. Data Model Basic Building Blocks

Relational Database Systems Part 01. Karine Reis Ferreira

COURSE OUTLINE. School of Engineering Technology and Applied Science

Data about data is database Select correct option: True False Partially True None of the Above

Chapter 1: Introduction

Overview of Database Design Process. Data Modeling Using the Entity- Relationship (ER) Model. Two main activities:

Database Applications (15-415)

Working with Data. L1 Introduction to Database & SQL

Database Design. IIO30100 Tietokantojen suunnittelu. Michal Zabovsky. Presentation overview

Fundamentals of Database Systems V7. Course Outline. Fundamentals of Database Systems V Jul 2018

COMP Instructor: Dimitris Papadias WWW page:

SQL: DML and Advanced Constructs Insert, Update, Delete, View, Index, Procedure, Transaction, Trigger

The Relational Model

Practical Database Design Methodology and Use of UML Diagrams Design & Analysis of Database Systems

Database Management System. Fundamental Database Concepts

Review The Big Picture

Database Design with Entity Relationship Model

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

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

CS/INFO 330 Entity-Relationship Modeling. Announcements. Goals of This Lecture. Mirek Riedewald

Informatics 1: Data & Analysis

What is Data? ANSI definition: Volatile vs. persistent data. Data. Our concern is primarily with persistent data

What is Data? Volatile vs. persistent data Our concern is primarily with persistent data

Database Management Systems MIT Introduction By S. Sabraz Nawaz

DATABASE DESIGN I - 1DL300

Unit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

SYED AMMAL ENGINEERING COLLEGE

Chapter Outline. Note 1. Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

Database Technology Introduction. Heiko Paulheim

Objectives of logical design... Transforming the ERD diagram into relations. Relational database components. Mapping a composite attribute

Department of Information Technology B.E/B.Tech : CSE/IT Regulation: 2013 Sub. Code / Sub. Name : CS6302 Database Management Systems

Data Modeling Using the Entity-Relationship (ER) Model

Data, Information, and Databases

What is database? Types and Examples

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

FUNDAMENTALS OF SEVENTH EDITION

Chapter 2: ER-Diagrams. Content: Learn how to draw ER diagrams Useful to model a database

High Level Database Models

Unit I. By Prof.Sushila Aghav MIT

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

UNIT I. Introduction

Evolution of Database Systems

CMPT 354 Database Systems I

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 1-1

Database Architectures

VALLIAMMAI ENGINEERING COLLEGE

Model Driven Engineering (MDE)

Requirement Analysis & Conceptual Database Design

Database Applications (15-415)

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL. 1 Powered by POeT Solvers Limited

Goals for Today. CS 133: Databases. Final Exam: Logistics. Why Use a DBMS? Brief overview of course. Course evaluations

Introduction. Example Databases

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Conceptual Design with ER Model

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Chapter 1. Introduction of Database (from ElMasri&Navathe and my editing)

Introduction: Databases and. Database Users

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

COWLEY COLLEGE & Area Vocational Technical School

Database Design Process

DATABASE MANAGEMENT SYSTEM

CMSC 424 Database design Lecture 3: Entity-Relationship Model. Book: Chap. 1 and 6. Mihai Pop

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

Chapter 8: Enhanced ER Model

Unified Modeling Language (UML)

CS 405G: Introduction to Database Systems

Specific Objectives Contents Teaching Hours 4 the basic concepts 1.1 Concepts of Relational Databases

COURSE OUTLINE. IST 253 Database Concept 3 Course Number Course Title Credits

Databases and Database Management Systems

Enhanced Entity-Relationship (EER) Modeling

1. Analytical queries on the dimensionally modeled database can be significantly simpler to create than on the equivalent nondimensional database.

Transcription:

Course A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling Martin Svoboda Irena Holubová Tomáš Skopal Faculty of Electrical Engineering, Czech Technical University in Prague

Course Plan What is this course about? Relational database management systems (RDBMS) Data modeling and database design techniques SQL data definition and manipulation language Formal query languages for the relational model Basics of physical implementation and transactions It will also slightly introduce you to Database applications Multimedia, XML, NoSQL and other databases But it is not about Data mining, data warehouses, OLAP, cloud computing, A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 2

Course Plan Plan of lectures Conceptual database modeling (ER, UML, OCL) Logical database models (relational model) SQL (DDL, DML,, SQL/XML) Relational algebra and relational calculus Database design (integrity constraints, normal forms, ) Database structures (files, index structures, ) Transactions (scheduling, locking protocols, ) Database architectures and models A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 3

Course Plan Plan of practical classes ER and UML conceptual modeling Transformation of ER / UML to the relational model SQL data definition and updates SQL querying and views Relational algebra and calculus Functional dependencies and keys Algorithms of decomposition and synthesis A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 4

Organizational Stuff See the web page of the lecture: http://www.ksi.mff.cuni.cz/~svoboda/courses/2015-1-a7b36dbs/ Practical classes Structure, attendance, assignments, points, activity, credits Lectures Examination, points, grades A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 5

Outline Introduction to database systems What is a database? Basic terminology Conceptual database modeling ER Entity-Relationship Model UML Unified Modeling Language OCL Object Constraint Language A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 7

Database Systems

Basic Terminology Database (DB) Logically ordered collection of related data instances Self-describing, meta-data stored together with data Data + schema + integrity constraints Database management system (DBMS) General software system for access to a database Provides mechanisms to ensure security, reliability, concurrency, integrity of stored data, A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 9

Brief History Database models and systems Network and hierarchical databases Relational databases Object and object-relational databases XML databases NoSQL databases Key-value stores, document-oriented, graph databases, Stream, active, deductive, spatial, temporal, probabilistic, real-time, in-memory, embedded, Still evolving area with plenty of challenges A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 10

Brief History Why so many different database systems? Different contexts OLTP, OLAP, Cloud computing, Big data, Different requirements Performance, scalability, consistency, availability, Different architectures Centralized, distributed, federated, Different forms of data Relations, objects, graphs, Semi-structured, unstructured data, texts, Multimedia, web A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 11

Motivation for Databases Why database systems? Data sharing and reusability Consistency, correctness, Elimination of redundancies Concurrency, isolation, transactions, Unified interface and languages Data definition and manipulation Information security User authentication, access authorization, Administration and maintenance Replication, backup, recovery, migration, tuning, A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 12

Database Modeling Process of database design One vague sentence at the beginning a fully working system at the end Understanding and modeling the reality Organizing the acquired information Balancing the identified requirements Creating a suitable database schema Who are stakeholders? Stakeholder is any person which is relevant for your application E.g. application user, investor, owner, domain expert, etc. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 13

Basic Terminology Model = modeling language Set of constructs you can use to express something UML model = {class, attribute, association} Relational model = {relational schema, attribute} Schema = modeling language expression Instance of a model Relational schema = {Person(name, email)} Diagram = schema visualization A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 14

Layers of Database Modeling Conceptual layer Models a part of the reality (problem domain) relevant for a database application, i.e. identifies and describes real-world entities and relationships between them Conceptual models such as ER or UML Logical layer Specifies how conceptual components are represented in database structures Logical models such as relational, object-relational, graph, Physical layer Specifies how logical database structures are implemented in a specific technical environment Data files, index structures (e.g. B + trees), etc. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 15

Conceptual Database Modeling

Conceptual Database Modeling Conceptual modeling Process of creating a conceptual schema of a given problem domain In a selected modeling language And on the basis of given requirements Multiple conceptual schemas are actually created Each schema describes the given database application(s) from a different point of view Even different conceptual models may be needed We focus only on conceptual data viewpoint A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 17

Conceptual Modeling Process Analyze requirements Identify types of entities Identify types of relationships Identify characteristics Model identified types Choose modeling language Create conceptual schema Create schema diagram Iteratively adapt your schema to requirements changing over time A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 18

Requirement Analysis (Step 1) Step 1 of conceptual modeling Start with requirements of different stakeholders Usually expressed in a natural language Meetings, discussions, inquiries, Identify important types of real-world entities, their characteristics, types of relationships between them, and their characteristics and deal with ambiguities A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 19

Identification of Entities (Step 1.1) Example Try to identify all types of entities: Our environment consists of persons which may have other persons as their colleagues. A person can also be a member of several research teams. And, they can work on various research projects. A team consists of persons which mutually cooperate. Each team has a leader who must be an academic professor (assistant, associate or full). A team acts as an individual entity which can cooperate with other teams. Usually, it is formally part of an official institution, e.g., a university department. A project consists of persons working on a project but only as research team members. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 20

Identification of Entities (Step 1.1) Example Our environment consists of persons which may have other persons as their colleagues. A person can also be a member of several research teams. And, they can work on various research projects. A team consists of persons which mutually cooperate. Each team has a leader who must be an academic professor (assistant, associate or full). A team acts as an individual entity which can cooperate with other teams. Usually, it is formally part of an official institution, e.g., a university department. A project consists of persons working on a project but only as research team members. Identified entity types Person Team Project Professor Assistant Professor Associate Professor Full Professor Institution Department A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 21

Identification of Relationships (Step 1.2) Example Try to identify all types of relationships: Our environment consists of persons which may have other persons as their colleagues. A person can also be a member of several research teams. And, they can work on various research projects. A team consists of persons which mutually cooperate. Each team has a leader who must be an academic professor (assistant, associate or full). A team acts as an individual entity which can cooperate with other teams. Usually, it is formally part of an official institution, e.g., a university department. A project consists of persons working on a project but only as research team members. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 22

Identification of Relationships (Step 1.2) Example Our environment consists of persons which may have other persons as their colleagues. A person can also be a member of several research teams. And, they (person) can work on various research projects. A team consists of persons which mutually cooperate. Each team has a leader who must be an academic professor (assistant, associate or full). A team acts as an individual entity which can cooperate with other teams. Usually, it (team) is formally part of an official institution, e.g., a university department. A project consists of persons working on a project but only as research team members. Relationship types Person is colleague of Person Person is member of Team Person works on Project Team consists of Person Team has leader Professor Team cooperates with Team Team is part of Institution Project consists of Person who is a member of Team A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 23

Identification of Characteristics (Step 1.3) Example Try to identify characteristics of persons: Each person has a name and is identified by a personal number. A person can be called to their phone numbers. We need to know at least one phone number. We also need to send them emails. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 24

Identification of Characteristics (Step 1.3) Example Each person has a name and is identified by a personal number. A person can be called to their phone numbers. We need to know at least one phone number. We also need to send them emails. Person characteristics Personal number Name One or more phone numbers Email A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 25

Identification of Characteristics (Step 1.3) Example Try to identify characteristics of memberships: We need to know when a person became a member of a project and when they finished their membership. A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 26

Identification of Characteristics (Step 1.3) Example We need to know when a person became a member of a project and when they finished their membership. Identified membership characteristics From To A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 27

Schema Creation (Step 2) Step 2 of conceptual modeling Model identified types using a suitable conceptual data model (i.e., create conceptual data schema) and visualize it as a diagram You can use various tools for modeling, so-called Case Tools, e.g., Commercial: Enterprise Architect, IBM Rational Rose, Academic: exolutio A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 28

Modeling Language Selection (Step 2.1) Which model should we choose? There are several available languages, each associated with a well-established visualization in diagrams We will focus on Unified Modeling Language (UML) class diagrams Entity-Relationship model (ER) There are also others Object Constraints Language (OCL) Object-Role Model (ORM) Web Ontology Language (OWL) Predicate Logic, Description Logic (DL) A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 29

Conceptual Schema Creation (Step 2.2) How to create a schema in a given language? Express identified types of entities, relationships and their characteristics with constructs offered by the selected conceptual modeling language UML: classes, associations, attributes ER: entity types, relationship types, attributes A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 30

Entity-Relationship Model (ER) Unified Modeling Language (UML)

ER and UML Modeling Languages ER Not standardized, various notations and extensions (e.g., ISA hierarchy) UML Family of models such as class diagrams, use case diagrams, state diagrams, Note that Standardized by the OMG (Object Management Group) http://www.omg.org/spec/uml/ ER is more oriented to data design, UML to code design Both ER and UML are used in practice, but UML has become more popular recently ER constructs were incorporated to new versions of UML as well A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 32

Types of Entities Type of real-world entities Persons, research teams and research projects. class How to model types of entiti... Team Person Proj ect Class Name UML Entity type Name ER A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 33

Characteristics of Entities Attributes of a type of real-world entities A person is characterized by their personal number, name, optional email address and one or more phone numbers. class How to model charac... Person - personnumber - email [0..1] - phone [1..n] UML Attribute of a class Name and cardinality ER Attribute of an entity type Name and cardinality A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 34

Types of Relationships Type of a relationship between two real-world entities A team has one or more members, a person can be a member of zero or more teams. A team has class exactly How to model one types leader, of relation... a person can be a leader of zero or more teams. Person - personnumber +has_member 1..* member +has_leader 1 leader +is_member_of Team - url +leads UML Binary association: name and two participants with names and cardinalities ER Binary relationship type: name and two participants with cardinalities A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 35

Cardinalities in Relationships Relationship member Relationship leader class How to model types of relation... Person - personnumber +has_leader 1 XRG Martin Nečaský XRG Martin Nečaský +has_member 1..* member leader SIRET Tomáš Skopal SIRET Tomáš Skopal +is_member_of Team +leads Jaroslav Pokorný INTLIB Jaroslav Pokorný - url Josef Novák Josef Novák A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 36

Characteristics of Relationships Attributes of a type of relationship between real-world entities A person is a team member within a given time interval class How to model characteristics o... Person - personnumber +has_member 1..* +is_member_of Member - from - to Team - url UML Attribute of a binary association class Name and cardinality ER Attribute of a relationship type Name and cardinality A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 37

Generalization / Specialization Type of entities which is a specialization of another type Each person has a personal number and name. A professor is a person which also has one or more phones and can lead teams. A student is a person which also has a date of study beginning. class Generalizations Team leader member 1..* Person - personnumber 1 Professor - phone [1..*] Student - studiesfrom UML Generalization: specific association with no name, roles and cardinalities ER ISA hierarchy: specific relationship with no name and cardinalities A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 38

Generalization / Specialization Note that Entity type can be as a source for multiple hierarchies Each entity type can have at most one generalization Additional constraints Covering constraint Each entity must be of at least one specific type I.e. each Person is a Professor or Student (or both) Overlap constraint Each entity must be of at most one specific type I.e. there is no Student that would be a Professor at the same time A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 39

Composite Attributes Structured characteristics of real-world entity types A person has one or two addresses comprising of a street, city and country. class Composite attri... Person - personnumber 1 1..2 Address - street - city - country No specific construct Auxiliary class UML ER Composite attribute: name, cardinality and sub-attributes A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 40

Recursive Relationships Type of a relationship between entities of the same type A person has zero or more colleagues. class Recursiv e associatio... colleague +is_colleague_of Person - personname +has_colleague UML Normal association with the same participants ER Normal relationship type with the same participants A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 41

N-ary Relationships Type of a relationship between more than just two entities A person works on a project but only as a team member. class Nary associations Person - personnumber worker Project (0,n) (1,n) 1..* - projectnumber (0,*) 0..1 Team UML N-ary association Similar to a binary association but with three or more participants ER N-ary relationship type Similar to a binary relationship type but with three or more participants A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 42

N-ary Relationships Note that N-ary relationships can also have attributes UML allows us to use more expressive cardinalities E.g. a given combination of a particular person and project is related to zero or more teams through the given association class Nary associations Person - personnumber worker Project (0,n) (1,n) 1..* - projectnumber (0,*) 0..1 Team A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 43

N-ary Relationships Can n-ary relationships be replaced with binary? Which projects does Jaroslav Pokorný work on as a member of the SIRET research group? I.e. what is the difference between the following? class Nary associations class Nary associations Person - personnumber worker 1..* Project - projectnumber Person - personnumber member 1..* worker Project - projectnumber 0..1 Team Team A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 44

N-ary Relationships Can n-ary relationships be replaced with binary? Which projects does Jaroslav Pokorný work on as a member of the SIRET research group? I.e. what is the difference between the following? Martin Nečaský GraphDB Martin Nečaský GraphDB XRG XRG Tomáš Skopal LINK Tomáš Skopal LINK SIRET SIRET Jaroslav Pokorný P3S Jaroslav Pokorný P3S A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 45

N-ary Relationships Can n-ary relationships be replaced with binary? Yes, but in a different way N-ary association = class + separate binary association for each of the original participants class Nary associations class Nary associations Person - personnumber Person - personnumber worker 0..1 1..* Project - projectnumber = Worker 0..1 1..* Project - projectnumber Team Team A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 46

Identifiers Full identification of real-world entities A person is identified either by their personal number or by a combination of their first name and surname. N/A UML Attribute or a group of attributes marked as an identifier ER A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 47

Identifiers Partial identification of real-world entities A team is identified by a combination of its name and a name of its institution. abbreviation N/A UML ER Attribute or a group of attributes marked as a partial identifier A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 48

Identifiers Note that Each entity type must always be identifiable At least by a set of all its attributes if not specified explicitly Partial identifiers create identification dependencies Only (1,1) cardinality is allowed (makes a sense)! Entity types Strong entity type has at least one (full) identifier Weak entity type has no (full) identifier, and so at least one partial identifier is both existentially and identification dependent A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 49

Data Types Data type of attributes A person has a personal number which is an integer and name, email and phone which are all strings. class Data types Person - personnumber: int : string - email: string - phone: string UML Attribute of a class may have a data type assigned ER Attribute of entity type may have a data type assigned Note that Set of available data types is not specified strictly Data types are actually not very important at the conceptual layer A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 50

Complete Sample UML Diagram class Velký příklad Proj ect - projectnumber - startyear worker 1..* +has_colleague Person - personnumber - email [0..1] +has_member 1..* +is_colleague_of Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee Member - from - to Institution - number - www +employer +belongs_to 1 +is_member_of 0..1 Team - url +cooperates_with +leads - title - from - to leader Position A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 51

Object Constraint Language (OCL)

Object Constraint Language OCL Language for formal specification of advanced integrity constraints Part of a UML standard http://www.omg.org/spec/ocl/ Motivation Cardinalities are not enough! Supports invariants, derived values, method preconditions and post-conditions, etc. We shortly focus on invariants A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 53

OCL Example 1 Each project must start after year 1990. context p : Project inv p.startyear > 1990 class Velký příklad Project - projectnumber - startyear worker 1..* +has_colleague Person - personnumber - email [0..1] +has_member 1..* +is_colleague_of Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee Member - from - to Institution - number - www +employer +belongs_to 1 +is_member_of 0..1 Team - url +cooperates_with +leads Position - title - from - to leader A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 54

OCL Example 2 Each team with more than 10 members must have a project and people working on the project. context Team inv self.has_member->size() > 10 implies class Velký příklad self.worker->size() > 0 Project - projectnumber - startyear worker 1..* +has_colleague Person - personnumber - email [0..1] +has_member 1..* +is_colleague_of Member - from - to Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee +is_member_of leader Institution - number - www +employer +belongs_to 1 0..1 Team - url +cooperates_with +leads Position - title - from - to A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 55

OCL Example 3 A person can work on a project only when they are a member of a team which solves the project. context Person inv self.is_member_of->includesall(self.worker.team) class Velký příklad +has_colleague +is_colleague_of Project - projectnumber - startyear worker 1..* Person - personnumber - email [0..1] +has_member 1..* Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee Member - from - to +is_member_of leader Institution - number - www +employer +belongs_to 1 0..1 Team - url +cooperates_with +leads Position - title - from - to A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 56

OCL Example 4 A person is identified by their personal number. context p1, p2 : Person inv p1.personnumber = p2.personnumber implies p1 = p2 class Velký příklad +has_colleague +is_colleague_of Project - projectnumber - startyear worker 1..* Person - personnumber - email [0..1] +has_member 1..* Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee Member - from - to +is_member_of leader Institution - number - www +employer +belongs_to 1 0..1 Team - url +cooperates_with +leads Position - title - from - to A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 57

OCL Example 5 A team leader must be an employee of the institution of the team. context t : Team inv t.belongs_to.employee->exists(p p = t.has_leader) class Velký příklad +has_colleague +is_colleague_of Project - projectnumber - startyear worker 1..* Person - personnumber - email [0..1] +has_member 1..* Professor - phone [1..*] - www - email - dblp +has_leader 1 +employee Member - from - to +is_member_of leader Institution - number - www +employer +belongs_to 1 0..1 Team - url +cooperates_with +leads Position - title - from - to A7B36DBS: Database Systems Lecture 01: Conceptual Database Modeling 1. 10. 2015 58