<<

2.1.1. Overview Lifecycle 2 Conceptual Design 2.1 -> Text 2.2 Modeling languages Requirement analysis

-> 2.1.1 Overview Conceptual Design 2.1.2 Requirement Analysis (case study) 2.2.1 Basic Modeling Primitives 2.2.2 Modeling Languages: UML and CREATE TABLE Studentin (SID INTEGER PRIMARY KEY, -> Database schema VName CHAR(20) Name CHAR(30)CREATE NOT NULL,TABLE Kurs Entity-Relationship Model (ERM) Logical Schema Design Email Char(40));(KID CHAR(10) PRIMARY KEY, Name CHAR(40) NOT NULL, Dauer INTEGER); CREATE TABLE Order 2.2.3 Conceptual DB design: basics ODate DATE soldBy INTEGER FOREIGN KEY REFEREBCES Peronal(PID) 2.2.4 From to Models CID INTEGER FOREIGN KEY REFERENCES Customer (CID)); Physical Schema Design -> Access paths

References: Kemper / Eickler chap 2, Elmasri / Navathe chap. 3 Administration Garcia-Molina / Ullmann / Widom: chap. 2 © HS-2009 Redesign 02-DBS-Conceptual-2

Database Design:Terminology 2.1.2 Requirement Analysis Most important: talk with your customers! Def.: The process of defining the overall of a database, Tasks during RA: i.e. the schema, on different layers of abstraction. ƒ Identify essential "real world" information (e.g. Design levels: Conceptual, logical, physical interviews) ƒ Remove redundant, unimportant details Includes "Analysis" and "Design" from SE ƒ Clarify unclear natural language statements DB Modeling: defining the "static model" using formal or visual languages ƒ Fill remaining gaps in discussions ƒ Distinguish data and operations DB SE Requirements Requirements Conceptual modeling Analysis Requirement analysis & Conceptual Design aims at Logical modeling Design focusing thoughts and discussions ! Physical modeling Implementation

© HS-2009 02-DBS-Conceptual-3 © HS-2009 02-DBS-Conceptual-4

Example: Geo-DB Requirement Analysis

The database we develop will contain data about countries, cities, ƒ Clarify unclear statements organizations and geographical facts. In the first step, countries, cities, • what is a country? regions (like "Bundesländer" or geographical regions), and continents Political unit: compare Korea vs South /North Korea are to be represented in the DB. ƒ Fill gap • Cities are located in regions. What if In the requirements analysis it has to be clarified, what kind of a country does not have regions? information is supposed to be represented, not how it should be → region is country itself represented! • Can a region belong to different countries? No, but there may be regions with the same name in different countries • Can a country belong to different continents? Yes. ƒ Distinguish data from operations First step: filter essential information , ignore unim- • Gross National Product per inhabitant: calculate portant details • "It happens that countries are united" .... Note: importance of some piece of information depends on the application

© HS-2009 02-DBS-Conceptual-5 © HS-2009 02-DBS-Conceptual-6

1 2.2.1 Basic modeling primitives requirements Conceptual modeling ƒ What is the right language for "modeling reality"? ƒ Distinguish between types (classes) and individual facts (metadata vs data) ƒ Which language primitives ? ƒ The name of this woman is Kunz with first name Tamara. ƒ As opposed to: Anƒ old problem of philosophy: how to describe the ƒ A person is identified by first name, last name and birth date. world in an appropriate, comprehensible way?

ƒ Describe reality on a type level One of the answers were logic languages. They allow to express more than we (currently) want to: ƒ Use a graphical language in order to get an overall facts and rules. impression of the domain modeled. e.g.: human(Plato) , ∀x (human(x) ⇒ mortal(x)

© HS-2009 02-DBS-Conceptual-7 © HS-2009 02-DBS-Conceptual-8

Basic modeling primitives Basic modeling primitives

Modeling the "Real World" Issues ƒ Design choices Entity (type) City Country attribute or entity? something which exists, has a name continent: attribute of country or separate entity?

ƒ City Country Attribute There is never exactly one way of modeling reality. ƒ property of an entity populat name name GNP Many good designs, much more bad designs. populat Relationship Country Continent connects two or more entities ƒ Identification name name inhabit encom_ area ƒ e.g. name obviously identifies continents but not cities passes population? "Non sunt multiplicanda entia praeter necessitatem" ƒ Identifying attributes needed at all? William van Ockham, English philosopher, 13th century (Principle of Economy, Law of Parsimony) © HS-2009 02-DBS-Conceptual-9 © HS-2009 02-DBS-Conceptual-10

2.2.2 Modeling notations and languages Graphical modeling languages

Entity-Relationship-Model (ERM) Unified modeling language (UML) ƒ data-oriented: static modeling of data ƒ 1976 introduced by P.P. Chen Modeling of data and operations ƒ (Peter P. Chen: The Entity-Relationship Model - Toward a Unified View of Data. ACM TODS 1(1): 9-36, 1976, see Reader) Traditional graphical notation with squares, bullets and diamond ƒ Object oriented flavor e.g: each object (entity) has identity - a unique pointer ERM: entities having the same type and the same attribute values are indistinguishable Student Name FName ƒ Attributes may be constructed (lists, sets, arrays,…) Matr-Nr Title attend ƒ Relationships are directed (uni- or bidirectional) Email ERM: always bidirectional LID Lecture hours

© HS-2009 02-DBS-Conceptual-11 © HS-2009 02-DBS-Conceptual-12

2 UML versus ERM 2.2.3 Conceptual Design: Basics

UML Entities & attributes attend Called association Student Lecture in UML, may be Matr-Nr LID directed Name Title FName Hours entity name {Email} assignRoom(R r) attribute list register(Lect x) Operations on data No methods … multivalued attribute {} example: first name for entity Person ERM Student Name FName Matr-Nr attend Title Email LID Lecture We basically use hours simplified UML notation

© HS-2009 02-DBS-Conceptual-13 © HS-2009 02-DBS-Conceptual-14

Basics Conceptual Design: Basics

Identifying attributes Relationships ƒ "Axiom" of Relational DB: Two individual entities can always be distinguished relates_to by the values of some of its attribute(s), together called the key … … Person Key attributes are <> name <>birthDate ƒ Always have a name underlined firstName Note: one single attribute may not {phones} ƒ No direction or annotated by be identifying for an entity. <> ƒ May have attributes Example: buys ƒ No identifying attributes Customer Product << something>> : UML Stereotype, allows to extend UML – here primary key attributes quantity Alternative notation: underline all PK attributes (which we use)

© HS-2009 02-DBS-Conceptual-15 © HS-2009 02-DBS-Conceptual-16

Modeling basics Conceptual Design: UML

Weak entity Notation ! UML-Terminology ƒ Class = entity type (UML: attribute = field) account accTransaction has ƒ Object = entity accNumber s_number name day ƒ Association = relationship acc_type value //+ or - balance … ƒ NO keys: objects are identified by unique address … ƒ Relationship may have a direction Example: account statement identified by "number" and "acc_number" which is not attribute of 'statement' entity (!) relates_to Def:: A weak entity is an entity identified by some of its attributes and the relationship to another entity . … … …

© HS-2009 02-DBS-Conceptual-17 © HS-2009 02-DBS-Conceptual-18

3 Conceptual Design: Basics Conceptual Design: Basics

Notation Recursive relationships ƒ Sometimes attributes are omitted superior ƒ order of relationship role? Employee Employee Employee

PK pid name belongs_to first_name superior Country Continent UML-Notation position encompasses salary

Roles: particularly useful in recursive relations Role names Used in ERM boss rents and UML Employee child Customer DVD Person renter rental object to distinguish

the roles of has superior

entities in a parent

role names relationship subordinate basically for © HS-2009 02-DBS-Conceptual-19 © HS-2009 02-DBS-Conceptual-20 documentation

Conceptual Design: Basics 2.2.3 From requirements to models

Multiple relationships Text to conceptual model ƒ The only step which cannot be automated ƒ Requirements as "cleaned" text ƒ conceptual database design There may be no, one or many relationships Rough guideline: correspondence between… between entity types ƒ entities - nouns Every city has... ƒ relationships and verbs capital_of Country City ...is located in country (exactly one !) lays_in ƒ attributes and adjectives or phrases like “has a..”, “is...a” ...has a GNP (but also: .. has a capital)

© HS-2009 02-DBS-Conceptual-21 © HS-2009 02-DBS-Conceptual-22

Conceptual Design: case study Summary

• Conceptual modeling: the art of structuring the data of an application domain Region belongs-to • Basis: careful requirement analysis r_id: String name: String • Simple, powerful base constructs: population: Numb entities, attributes, relationships

is_neighbor position ∈ {N,W,S,E,Z..} • Visual (graphical) language encompass Continent Country • E-R modeling language and UML related name: String

capitalOf ƒ E-R language simpler name: String area: Numb L_ID: String ƒ More appropriate for modeling of data population: Numb area: Numb ƒ many dialects locatedIn GNP: Numb area: ƒ Compatibility to UML makes sense numb City ƒ Some differences, e.g. no keys in UML name: String capital population: Numb longitude: Numb © HS-2009 latitude:02-DBS-Conceptual-23 Numb © HS-2009 02-DBS-Conceptual-24

4