Topic Database Modelling S McKeever Advanced Databases 1.

Slides:



Advertisements
Similar presentations
Entity-Relationship (ER) Modeling
Advertisements

BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Topic Denormalisation S McKeever Advanced Databases 1.
Chapter 6 Methodology Conceptual Databases Design Transparencies © Pearson Education Limited 1995, 2005.
Methodology Logical Database Design for the Relational Model
Methodology Conceptual Database Design
Modeling & Designing the Database
LOGICAL DATABASE DESIGN
Transforming Data Models into Database Designs
APPENDIX C DESIGNING DATABASES
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Logical Database Design Nazife Dimililer. II - Logical Database Design Two stages –Building and validating local logical model –Building and validating.
Entity-Relationship Design
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
Chapters 17 & 18 Physical Database Design Methodology.
Business Process Modeling
DATA MODELING AND DATABASE DESIGN
CHAPTER 2. FUNDAMENTAL OF ENTITY RELATIONSHIP (ER)
Chapter 16 Methodology - Conceptual Database Design.
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
Methodology - Conceptual Database Design Transparencies
Software School of Hunan University Database Systems Design Part III Section 5 Design Methodology.
Methodology Conceptual Databases Design
Relational DB Components
9/14/2012ISC329 Isabelle Bichindaritz1 Database System Life Cycle.
1 Chapter 15 Methodology Conceptual Databases Design Transparencies Last Updated: April 2011 By M. Arief
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Methodology - Conceptual Database Design. 2 Design Methodology u Structured approach that uses procedures, techniques, tools, and documentation aids to.
1/26/2004TCSS545A Isabelle Bichindaritz1 Database Management Systems Design Methodology.
Methodology: Conceptual Databases Design
DATABASE MGMT SYSTEM (BCS 1423) Chapter 5: Methodology – Conceptual Database Design.
Team Dosen UMN Database Design Connolly Book Chapter
Conceptual Database Design
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Chapter 8 Methodology - Conceptual Database Design Chapter 15 in Textbook.
Methodology - Conceptual Database Design
CIS 210 Systems Analysis and Development Week 6 Part II Designing Databases,
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
Part4 Methodology of Database Design Chapter 07- Overview of Conceptual Database Design Lu Wei College of Software and Microelectronics Northwestern Polytechnical.
Relational Theory and Design
Information Access Mgt09/12/971 Entity-Relationship Design Information Level Design.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Modelling Methodologies Chapter 16, 17, 18. Modeling Methodologies2 Database Design Physical DB design Logical DB design Conceptual DB design Hardware.
1 Database Systems Entity Relationship (E-R) Modeling.
B. Information Technology (Hons.) CMPB245: Database Design Physical Design.
DBMS ER model-2 Week 6-7.
Entity Relationship Diagram (ERD). Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
April 20022/CS/3X1 Database Design Design method John Wordsworth Department of Computer Science The University of Reading Room.
Database Design Chapters 17 and 18.
Methodology Conceptual Databases Design
Chapter 4: Logical Database Design and the Relational Model
Methodology Conceptual Database Design
Translation of ER-diagram into Relational Schema
Entity-Relationship Model and Diagrams (continued)
ERD’s REVIEW DBS201.
Conceptual Database Design
MIS2502: Data Analytics Relational Data Modeling
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Design Chapters 17 and 18.
COMP 208/214/215/216 – Lecture 7 Documenting Design.
Methodology Conceptual Databases Design
Presentation transcript:

Topic Database Modelling S McKeever Advanced Databases 1

3 phases of database design S McKeeverAdvanced Databases 2 (1) Conceptual(2) Logical(3) Physical Need a systematic approach to designing and building the dB

Phase 1: Conceptual database design S McKeeverAdvanced Databases 3 –Step 1.1 Identify entity types –Step 1.2 Identify relationship types –Step 1.3 Identify and associate attributes with entity or relationship types –Step 1.4 Determine attribute domains –Step 1.5 Determine candidate, primary, and alternate key attributes –Step 1.6 Consider use of enhanced modeling concepts (optional step) –Step 1.7 Check model for redundancy –Step 1.8 Validate conceptual model against user transactions –Step 1.9 Review conceptual data model with user Step 1: Build conceptual data model

Phase 2: Logical database design S McKeeverAdvanced Databases 4 –Step 2.1 Derive relations for logical data model –Step 2.2 Validate relations using normalization –Step 2.3 Validate relations against user transactions –Step 2.4 Define integrity constraints –Step 2.5 Review logical data model with user –Step 2.6 Merge logical data models into global model (optional step) –Step 2.7 Check for future growth Step 2: Build and validate Logical database design

Phase 3: Physical database design S McKeeverAdvanced Databases 5 Step 3.1 Design base relations Step 3.2 Design representation of derived data Step 3.3 Design general constraints Step 3 Translate logical data model for target DBMS Step 4 Design file organizations and indexes Step 4.1 Analyze transactions Step 4.2 Choose file organization Step 4.3 Choose indexes Step 4.4 Estimate disk space requirements

Phase 3: Physical database design (continued) S McKeeverAdvanced Databases 6 Step 5 Design user views Step 6 Design security mechanisms Step 7 Consider the introduction of controlled redundancy Step 8 Monitor and tune the operational system

Our focus… S McKeeverAdvanced Databases 7 Will concentrate on the techniques for producing the Entity Relationship Diagram (ERD) This is the typical design diagram for explaining The entities Their attributes Their relationships Key output from Conceptual data modelling Greater detail as logical and physical design progresses,…

Entities S McKeeverAdvanced Databases 8 Entity = “thing” “An entity is a business object that represents a group, or category of data.” Like a database table

S McKeever 9 Entities diagramatically Customer branches (a customer can be in more than One branch) Customer entity

S McKeeverAdvanced Databases 10 CustIDCustNameCustAddrCredit_LimCurr_Bal Dunn0001Dunnes Stores Main Street, Dublin £1000£15.45 CustIDBranIDBranNameBranAddrCredit_LimCurr_Bal Dunn0001RATH0001RathminesDublin 6£200£0.40 Dunn0001JERV0001Jervis St.Dublin 2£300£6.05 Dunn0001DAWS000 1 Dawson St. Dublin 2£300£6.00 Dunn0001WICK0001Wicklow £200£3.00 Entities as table - with data Customer Customer branches

S McKeeverAdvanced Databases 11 The DB is recording information about your customers and their branches These are examples of real-world entities An entity is any “object” about which we wish to store information in the DB (table) Entities are linked together by relationships CustID, BranAddr, etc. are data items or fields or attributes So what does that mean ?

S McKeeverAdvanced Databases 12 To set up that table in SQL... Create table Customer ( CustID char(10) NOT NULL, CustName char(50), CustAddr char(100), Credit_Lim number(10), Debtor_Bal number(10) ); select * from Customer where CustID = “Dunn0001”

Attributes S McKeeverAdvanced Databases 13 Attributes = “ways to describe the thing” “An attribute is a sub-group of information within an entity.” Like a database field Shown as list under the entity name

Keys S McKeeverAdvanced Databases 14 CustIDCustNameCustAddrCredit_LimCurr_Bal Dunn0001Dunnes Stores Main Street, Dublin £1000£15.45 Customer Primary key = uniquely identifies EACH row What’s the primary key here?

S McKeeverAdvanced Databases 15 What’s the primary key here? (can be composite.. More than one field CustIDBranIDBranNameBranAddrCredit_LimCurr_Bal Dunn0001RATH0001RathminesDublin 6£200£0.40 Dunn0001JERV0001Jervis St.Dublin 2£300£6.05 Dunn0001DAWS000 1 Dawson St. Dublin 2£300£6.00 Dunn0001WICK0001Wicklow £200£3.00 Customer branches

Keys S McKeeverAdvanced Databases 16 Foreign key = A column(s) one a table that matches the primary key on another table. CustIDCustNameCustAddrCredit_LimCurr_Bal Dunn0001Dunnes Stores Main Street, Dublin £1000£15.45 CustIDBranIDBranNameBranAddrCredit_LimCurr_Bal Dunn0001RATH0001RathminesDublin 6£200£0.40 Dunn0001JERV0001Jervis St.Dublin 2£300£6.05 Dunn0001DAWS000 1 Dawson St. Dublin 2£300£6.00 Dunn0001WICK0001Wicklow £200£3.00

S McKeeverAdvanced Databases 17 CustIDCustNameCustAddrCredit_LimCurr_Bal Dunn0001Dunnes Stores Main Street, Dublin £1000£15.45 CustIDBranIDBranNameBranAddrCredit_LimCurr_Bal Dunn0001RATH0001RathminesDublin 6£200£0.40 Dunn0001JERV0001Jervis St.Dublin 2£300£6.05 Dunn0001DAWS000 1 Dawson St. Dublin 2£300£6.00 Dunn0001WICK0001Wicklow £200£3.00 Keys Foreign keys – enforce referential integrity What happens if I (try) to delete customer DUNN001 from the customer table? X

What does each key mean? S McKeeverAdvanced Databases 18 Primary key = uniquely identifies EACH row e.g. student ID – everyone has a different one + Alternate key – could have been a primary key but isn’t. e.g. student ID (PK) and PPS ID (AK) = Candidate keys: The primary key and the alternative keys. A ny column or a combination of columns that can qualify as unique key in database. e.g. student ID and PPS number Foreign key = A column(s) one a table that matches the primary key on another table. E.g. student_school (on student table, links to table contains schools)

Entity attribute display in data models S McKeeverAdvanced Databases 19

Entities and tables S McKeeverAdvanced Databases 20 The words “Entities “ and “tables” are sometimes used interchangeably. But they’re not quite the same thing….

S McKeeverAdvanced Databases 21 Relationships between entities To start defining relationships between entities, first describe the way that they are connected in real life Let’s go back to the ERD in the quiz There are four faculties in the college: science, applied arts, built environment, business. Each student is registered on a programme within a faculty. Programmes consist of a set of modules, with some module offered on more than one programme. A student on a programme has to register for the compulsory modules on tphe programme and also take a number of optional modules. All modules have a unique module ID, and an associated credit waiting (ECTS).

S McKeeverAdvanced Databases 22 Need to be able to say “how many” of the entities Are participating in the relationship 1:1? One to one 1:M? One to many N:M? Many to many Relationships between entities

Sample Entity Relationship Diagram – book store S McKeeverAdvanced Databases 23 Note: The attributes are listed The data types of the attributes are listed What stage of the design is this? Conceptual, logical or physical? Imagine you’ve drawn this ERD What was the business description of the data requirements given in the first place?

Book store ERD S McKeeverAdvanced Databases 24 Imagine you’ve drawn this ERD What was the business description of the data requirements given in the first place? Some thing like – Need to store information about the book titles that we sell, In our bookstore, we store information about authors, the titles that they write. An author can write many titles. If the author has died they will have an obituary. The bookstore has many ongoing sales promotions that include many titles We categorise our titles along the usual lines – popular fiction, crime, health and so on We also store information about our publishers and who the main sales contact is in the publisher

Relationships between entities S McKeeverAdvanced Databases 25 When two entities are “related”.. There should be a word to describe this relationship e.g. EntitiesRelationship staff, branches Staff manage bank branches student, modules student attends classes newspaper, rentalProperties newspapers advertise rentalProperties You need to understand this “word” in order to figure out the information needed to define the relationship for the ERD On an ERD, need to know how many of each entity takes part in the relationship – question both entities about “how many”? e.g. For the Staff manages bank branches relationship Staff can manage how many branches at most?? A staff person can manage one branch Staff must manage how many branches at min? A staff person can have no branch to manage

Relationship cardinality S McKeeverAdvanced Databases 26 “eh…What’s the cardinality of your mobile phone spend in euro each week? Relationship cardinality is about assigning the 1:1, 1:n etc etc “Can” and “Must” get you there..

Maximum Cardinality S McKeeverAdvanced Databases 27 Can….

The 3 types of maximum cardinality S McKeeverAdvanced Databases 28 One to one 1:1 An employee can be assigned one computer One to many 1:n A mother can have many children Many to many m:nAn order can have many product and vv How can you tell the difference between 1:m and m:n e.g. Student and module entities. What’s the maximum cardinality?

Minimum cardinality S McKeeverAdvanced Databases 29 Must…

Minimal cardinality S McKeeverAdvanced Databases 30 An employee must be assigned ? computer A mother must have ? children An order must have ? product What’s the minimum cardinality* for our examples? * zero (optional) or one (must have at least one)

S McKeeverAdvanced Databases 31 Minimal cardinality An employee must be assigned ? Computer Ans: Depends on the rule of the individual company. Probably zero A mother must have ? children ans: Definitely zero (optional!) An order can have ? Products ans: must have at least one What’s the minimum cardinality* for our examples? * zero (optional) or one (must have at least one)

Maximum and minimum cardinality S McKeeverAdvanced Databases 32 Now we know how to get the maximum (can) and minimum – But it has to be done BOTH ways to complete the relationship. We only did ONE direction A computer can be assigned to one employee A child can have one mother A product can be on many orders Maximum cardinality A computer must be assigned to one employee -No A child must have a mother? YES A product must be on an order? NO Minimim cardinality

Maximum and minimum cardinality S McKeeverAdvanced Databases 33 Once Maximum and Minimum cardinality has been figures out Between the entities – then they can be notated in whatever design Tool you’re using

Just for reference - Data modelling notation: Erwin S McKeeverAdvanced Databases 34 Max Min Max Note: Solid line ____ versus Dashed line ---- in Erwin = identifying versus non identifying relationship between two entities

Create relationships: n:m relationships – intersection table S McKeeverAdvanced Databases 35

Drawing the ERD with what you’ve learnt so far… S McKeeverAdvanced Databases 36 Read the specification and make sure your understand it Figure out what your entities are e.g. sales, book title, authors Figure out which ones are related (don’t worry yet about the cardinality – helps to put the word in (e.g. “has”) Figure out the attributes of each entity Identify the primary key for each entity Any foreign keys? Identify the cardinality of the relationship

Exercise S McKeeverAdvanced Databases 37 A furniture company needs to develop a database to store information about its customers and sales Customer details need to be captured, such as name, address. The company wants to be able to report on what their sales – what each customer bought (i.e. what furniture items). They would also like to know what the items are. Try and sketch out the entities involved.

S McKeeverAdvanced Databases 38 S McKeeverAdvanced Databases 38 EMPLOYEE supervises is supervised by Recursive relationships

For reference.. Summary of Erwin symbols S McKeeverAdvanced Databases 39

Summary of Erwin symbols (cont.) S McKeeverAdvanced Databases 40

Some examples S McKeeverAdvanced Databases 41 Note.. The symbols right beside the entity tell you how many of “it” can and must apply to the other entity. How many companies can and must an employee belong to? (note: sometimes I I shown, sometimes I

Some examples (continued) S McKeeverAdvanced Databases 42

Some examples (continued) S McKeeverAdvanced Databases 43