Presentation is loading. Please wait.

Presentation is loading. Please wait.

Information Modelling Entity Relationship Modeling.

Similar presentations


Presentation on theme: "Information Modelling Entity Relationship Modeling."— Presentation transcript:

1 Information Modelling Entity Relationship Modeling

2 Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated into the database design process. To describe how ERD components affect database design and implementation.

3 What is Conceptual Database Design? Process of describing the data, relationships between the data, relationships between the data, and the constraints on the data. After analysis - Gather all the essential data required and understand how the data are related The focus is on the data, rather than on the processes.

4 Gathering Information for Conceptual Data Modeling Two perspectives Top-down Data model is derived from an intimate understanding of the business. Bottom-up Data model is derived by reviewing specifications and business documents.

5 Person, place, object, event or concept about which data is to be maintained named property or characteristic of an entity Association between the instances of one or more entity types Represents a set or collection of objects in the real world that share the same properties Chen Notation EntityNameVerb Phrase AttributeName

6 Crow’s Foot Notation EntityName Entity Attribute EntityName List of Attributes Relationship Verb phrase Acceptable

7 Sample Entity Relationship Diagram (ERD) Rich Picture Root Definition Conceptual Model Cognitive Map SSM Multiview SODA Soft Methodology

8  Persons: agency, contractor, customer, department, division, employee, instructor, student, supplier.  Places: sales region, building, room, branch office, campus.  Objects: book, machine, part, product, raw material, software license, software package, tool, vehicle model, vehicle.  Events: application, award, cancellation, class, flight, invoice, order, registration, renewal, requisition, reservation, sale, trip.  Concepts: account, block of time, bond, course, fund, qualification, stock. Name of Entity Data Modeling Concepts: Entity An entity is a class of persons, places, objects, events, or concepts about which we need to capture and store data.

9 Guidelines for naming and defining entity types: An entity type name is a singular noun An entity type should be descriptive and specific An entity name should be concise Event entity types should be named for the result of the event, not the activity or process of the event. attributes: An attribute name is a noun. An attribute name should be unique To make an attribute name unique and clear, each attribute name should follow a standard format Similar attributes of different entity types should use similar but distinguishing names. 9

10  Betty Arnold  John Taylor  Lisa Simmons  Bill Macy  Heather Leath  Tim Wrench Data Modeling Concepts: Entity An entity instance is a single occurrence of an entity. Example: instances of the entity STUDENT may include

11 Data Modeling Concepts: Attributes An attribute is a descriptive property or characteristic of an entity. Synonyms include element, property, and field. A compound attribute is one that actually consists of other attributes

12 Data Modeling Concepts: Domains The data type for an attribute defines what type of data can be stored in that attribute. The domain of an attribute defines what values an attribute can legitimately take on. The default value for an attribute is the value that will be recorded if not specified by the user.

13 Data Modeling Concepts: Identification A key is an attribute, or a group of attributes, that assumes a unique value for each entity instance. A group of attributes that uniquely identifies an instance of an entity is called a concatenated key. A candidate key is a “candidate to become the primary key” of instances of an entity. A primary key is that candidate key that will most commonly be used to uniquely identify a single entity instance. Any candidate key that is not selected to become the primary key is called an alternate key.

14 Data Modeling Concepts: Identification Keys & Subsetting Criteria

15 Data Modeling Concepts: Relationships A relationship is a natural business association that exists between one or more entities. The relationship may represent an event that links the entities or merely a logical affinity that exists between the entities.

16 Degree of Relationships Degree: number of entity types that participate in a relationship Three cases Unary: between two instances of one entity type Binary: between the instances of two entity types Ternary: among the instances of three entity types

17 Data Modeling Concepts: Degree The degree of a relationship is the number of entities that participate in the relationship. A recursive relationship is a relationship that exists between different instances of the same entity

18 Data Modeling Concepts: Degree Relationships may exist between more than two entities and are called N-ary relationships. The example ERD depicts a ternary relationship.

19 Data Modeling Concepts: Degree An associative entity is an entity that inherits its primary key from more than one other entity (called parents). Each part of that concatenated key points to one and only one instance of each of the connecting entities.

20 Cardinality and Connectivity Relationships can be classified as either one – to – one one – to – many many – to –many Cardinality : minimum and maximum number of instances of Entity B that can (or must be) associated with each instance of entity A. Connectivity

21 bidirectional Data Modeling Concepts: Cardinality Cardinality defines the minimum and maximum number of occurrences of one entity that may be related to a single occurrence of the other entity. Because all relationships are bidirectional, cardinality must be defined in both directions for every relationship.

22 Cardinality and Connectivity ProfessorClass teaches A professor teaches class OR A class is taught by professor How Many?? ProfessorClass teaches

23 Cardinality and Connectivity ProfessorClass teaches ProfessorClass teaches 1M Connectivity (1,1) (1,4) Cardinality

24 Connectivity Chen Model 1 to represent one. M to represent many Crow’s Foot many One One or many 1 M Mandatory one, means (1,1) Optional? – we’ll see after this

25 Binary Relationships 1:M relationship Relational modeling ideal Should be the norm in any relational database design The 1: M relationship between PAINTER and PAINTING

26 The Implemented 1:M relationship between PAINTER and PAINTING

27 Binary Relationships 1:1 relationship Should be rare in any relational database design A single entity instance in one entity class is related to a single entity instance in another entity class Could indicate that two entities actually belong in the same table

28 The 1:1 Relationship Between PROFESSOR and DEPARTMENT

29 The Implemented 1:1 Relationship Between PROFESSOR and DEPARTMENT

30 Binary Relationships M:N relationships Must be avoided because they lead to data redundancies. Can be implemented by breaking it up to produce a set of 1:M relationships Can avoid problems inherent to M:N relationship by creating a composite entity or bridge entity This will be used to link the tables that were originally related in a M:N relationship The composite entity structure includes-as foreign keys-at least the primary keys of the tables that are to be linked.

31 The M:N Relationship Between STUDENT and CLASS This CANNOT be implemented as shown next….. Bowser Smithson Accounting 1 (ACCT-211) Intro to Microcomputing (CIS-220) Intro to Statistics (QM-261)

32 The tables have many redundancies!! + CLASS_CODE CLASS_CODE + STU_NUM

33 Changing the M:N relationship to TWO 1:M relationships

34 Converting the M:N relationship into TWO 1:M relationships Foreign keys reference the primary keys in the other tables of which it has a relationship with The database designer has 2 main options to define a composite table’s primary key: either use the combination of those foreign keys or create a new primary key.

35 Mandatory vs. Optional Cardinalities Specifies whether an instance must exist or can be absent in the relationship LecturerClass handles A Lecturer may handle zero or many classes. A class is handled by one and only one Lecturer. Optional Mandatory (0,N)(1,1) LecturerClass (0,N)(1,1) handles 1 M

36 Data Modeling Concepts: Foreign Keys A foreign key is a primary key of one entity that is contributed to (duplicated in) another entity to identify instances of a relationship.

37 Data Modeling Concepts: Foreign Keys Nonidentifying relationships are those in which each of the participating entities has its own independent primary key, In other words, none of the primary key attributes is shared. Identifying relationships are those in which the parent entity contributes its primary key to become part of the primary key of the child entity.

38 Data Modeling Concepts: Foreign Keys

39 A nonspecific relationship (or many-to-many relationship) is one in which many instances of one entity are associated with many instances of another entity. Nonspecific relationships must be resolved. Most nonspecific relationships can be resolved by introducing an associative entity. Data Modeling Concepts: Foreign Keys

40 Resolving Nonspecific Relationships (continued)

41

42 Data Modeling Concepts: Generalization Generalization is a technique wherein the attributes that are common to several types of an entity are grouped into their own entity, called a supertype. An entity supertype is an entity whose instances store attributes that are common to one or more entity subtypes. An entity subtype is an entity whose instances inherit some common attributes from an entity supertype and then add other attributes that are unique to an instance of the subtype.

43 Entity NameBusiness Definition agreementA contract whereby a member agrees to purchase a certain number of products within a certain time. After fulfilling that agreement, the member becomes eligible for bonus credits that are redeemable for free or discounted products. memberAn active member of one or more clubs. Note: A target system objective is to re-enroll inactive members as opposed to deleting them. member orderAn order generated for a member as part of a monthly promotion, or an order initiated by a member. Note: The current system only supports orders generated from promotions; however, customer initiated orders have been given a high priority as an added option in the proposed system. transactionA business event to which the Member Services System must respond. productAn inventoried product available for promotion and sale to members. Note: System improvement objectives include (1) compatibility with new bar code system being developed for the warehouse, and (2) adaptability to a rapidly changing mix of products. promotionA monthly or quarterly event whereby special product offerings are made available to members. Entity Discovery for SoundStage

44 The Context Data Model MEMBER ORDER MEMBER TRANSACTION PRODUCT AGREEMENTPROMOTION responds to places binds is a has conducted generates features sells

45 The Key-based Data Model

46 The Key-based Data Model With Generalization AUDIO TITLE Primary Key Product-Number [PK1] [FK] VIDEO TITLE Primary Key Product-Number [PK1] [FK] GAME TITLE Primary Key Product-Number [PK1] [FK] TITLE Primary Key Product-Number [PK1] [FK] MERCHANDISE Primary Key Product-Number [PK1] [FK] TRANSACTION Primary Key Transaction-Reference-Number [PK1] MEMBER ORDERED PRODUCT Primary Key Order-Number [PK1] [FK] Product-Number [PK2] [FK] PROMOTION TITLE Primary Key Promotion-Number [PK1] [FK] Product-Number [PK2] [FK] MEMBER ORDER Primary Key Order-Number [PK1] MEMBER Primary Key Member-Number [PK1] PRODUCT Primary Key Product-Number [PK1] AGREEMENT Primary Key Agreement-Number [PK1] PROMOTION Primary Key Promotion-Number [PK1] is featured as features sold as sells places binds is a has conducted responds to is a generates

47 The Fully-Attributed Data Model

48 Data Analysis & Normalization Data analysis is a process that prepares a data model for implementation as a simple, nonredundant, flexible, and adaptable database. The specific technique is called normalization. Normalization is a data analysis technique that organizes data attributes such that they are grouped to form nonredundant, stable, flexible, and adaptive entities.

49 Normalization: 1NF, 2NF, 3NF An entity is in first normal form (1NF) if there are no attributes that can have more than one value for a single instance of the entity. Any attributes that can have multiple values actually describe a separate entity, possibly an entity and relationship. An entity is in second normal form (2NF) if it is already in 1NF and if the values of all nonprimary key attributes are dependent on the full primary key—not just part of it. Any nonkey attributes that are dependent on only part of the primary key should be moved to any entity where that partial key is actually the full key. This may require creating a new entity and relationship on the model. An entity is in third normal form (3NF) if it is already in 2NF and if the values of its nonprimary key attributes are not dependent on any other non-primary key attributes. Any nonkey attributes that are dependent on other nonkey attributes must be moved or deleted. Again, new entities and relationships may have to be added to the data model.

50 1NF: فاكتور فروش شماره فاكتور : كليد اصلي تاريخ فاكتور كد مشتري نام مشتري كالاي 1 تعداد كالاي 1 قيمت واحد كالاي 1... كالاي n تعداد كالاي n قيمت واحد كالاي n 50 فاكتور فروش شماره فاكتور : كليد اصلي تاريخ فاكتور كد مشتري نام مشتري اقلام فاكتور فروش شماره فاكتور : كليد اصلي شماره كالا : كليد تعداد قيمت

51 2NF 51 اقلام فاكتور فروش شماره فاكتور : كليد اصلي شماره كالا : كليد تعداد قيمت اقلام فاكتور فروش شماره فاكتور : كليد اصلي شماره كالا : كليد كالا شماره كالا تعداد قيمت

52 3NF 52 فاكتور فروش شماره فاكتور : كليد اصلي تاريخ فاكتور كد مشتري نام مشتري فاكتور فروش شماره فاكتور : كليد اصلي تاريخ فاكتور كد مشتري : كليد خارجي مشتري كد مشتري : كليد اصلي نام مشتري

53 1NF empnoempnamedepnodepnameCoursenocoursena me rating 123J Smith21SystemsS2SSADMPoor 123J Smith21SystemsS3D BASEAverage 123J Smith21SystemsS5Data analysis Good 137D Brown23Operatio ns D1JCLGood 137D Brown23Operatio ns D9CobolGood 154I Patel21SystemsS2SSADMAverage 53 empnoempnamedepnodepname 123J Smith21Systems 137D Brown23Operations 154I Patel21Systems empnoCoursenocoursenamerating 123S2SSADMPoor 123S3D BASEAverage 123S5Data analysis Good 137D1JCLGood 137D9CobolGood 154S2SSADMAverage

54 2NF 54 empnoCoursenocoursenamerating 123S2SSADMPoor 123S3D BASEAverage 123S5Data analysisGood 137D1JCLGood 137D9CobolGood 154S2SSADMAverage empnoCoursenorating 123S2Poor 123S3Average 123S5Good 137D1Good 137D9Good 154S2Average Coursenocoursename S2SSADM S3D BASE S5Data analysis D1JCL D9Cobol

55 3NF 55 empnoempnamedepnodepname 123J Smith21Systems 137D Brown23Operations 154I Patel21Systems empnoempnamedepno 123J Smith21 137D Brown23 154I Patel21 depnodepname 21Systems 23Operations

56 Data-to-Location-CRUD Matrix

57 How to Evaluate a Data Model? A good data model has the following: Accuracy and completeness Non redundancy Enforcement of business rules Data Reusability Stability and Flexibility Communication Effectiveness Simplicity


Download ppt "Information Modelling Entity Relationship Modeling."

Similar presentations


Ads by Google