Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.

Similar presentations


Presentation on theme: "ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah."— Presentation transcript:

1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah | | | | A | ext:2561 | | CHAPTER 4 Entity Relationship (E-R) Modeling (ERD)

2 4.0 Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (ER) Model 4.2 Developing An E-R Diagram 4.3 Database Design Challenges Chapter 4: Entity Relationship (E-R) Modeling

3 Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept 3 A model is description or analogy used to visualize something that cannot be directly observed.

4 Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept 4 Relatively simple representations of complex real world data structures Represents: – data structures and their characteristics – relation and constraints Can be physical or abstract: – car, student = physical – subject, register= abstract Used by database designer as: – communications tools to communicate and understanding between a client and the database designer, which the database to be develop.

5 Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept 5 The importance of data modeling: Data –constitute the most basic information units employed by a system Application –is created to manage data and to transform data to information View –different people views the same data differently based on their understanding Model –helps different user to have the holistic view of the same data

6 Chapter 4: Entity Relationship (E-R) Modeling Basic Modeling Concept 6 2. Conceptual level 3. Internal level Physical data organization 1. External level View 1View 2View n Conceptual Schema Internal Schema Database User n User 2 User 1 … Conceptual Model External Model Internal Model Physical Model -designer’s view -h/w independent -s/w independent -DBMS’s view -h/w independent -s/w dependent -h/w dependent -s/w dependent -user’s view ERD Three Level ANSI-SPARC Architecture

7 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model 7 Based on the set theory and the relational theory, it is used as tools to: –translate different views of data among managers, users and programmers to fit into a common work –define data processing and constraints to help meet the different views –help implement the database –considered as a stage in a database design preceding the relational database modeling –gives data structures representation of: *what information have to be stored *the relationships between informational elements and constraint on the data structure *relationship

8 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model 8 ER model forms the basis of an ER diagram (ERD) ERD represents conceptual database as viewed by end user ERDs depict database’s main components: –Entities –Attributes –Relationships

9 9 Entity Refers to entity set and not to single entity occurrence Corresponds to table and not to row in relational environment In both Chen and Crow’s Foot models, entity is represented by rectangle containing entity’s name Entity name, a noun, is usually written in capital letters

10 10 Attribute Characteristics of entities Property that explains about entity Correspondents to fields of a table Primary key are underline with a straight line Foreign key are underline with dotted line or an * Chen Model attributes are represented by ovals and are connected to entity rectangle with a line each oval contains the name of attribute it represents Crow’s Foot Model attributes are written in attribute box below entity rectangle

11 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model 11 The Attributes of the STUDENT entity: Chen & Crow’s Foot

12 Chapter 4: Entity Relationship (E-R) Modeling 4.1 The Entity Relationship (E-R) Model: Relationship 12 Relationship Associates between entities Logical interaction among the entities in a relational database Operate in both directions Chen Model Crow’s Foot Model

13 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram 13 Development of ER model is an Iterative Process that involved: Step1: General narrative of organizational operations developed Step2: Basic E-R Model graphically depicted and reviewed Step3: Modifications made to incorporate newly discovered ER components Repeat process: Until designers and users agree on complete E-R Diagram

14 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Model Components 14 ENTITYVariations of entity: i.Weak ii.Recursive iii.Composite iv.Supertype/Subtype ATTRIBUTETypes of attribute: i.Simple attributes ii.Composite attributes iii.Multivalued attributes iv.Derived attributes RELATIONSHIPRelationship can be describes by: i.Degree of the relationship ii.Connectivity of the relationship iii.Cardinality of the relationship iv.Participation

15 15 Entity Corresponds to table and not to row in relational environment Represented by rectangle containing entity’s name Entity name, a noun, is usually written in capital letters Examlpe: Entity STUDENT with attributes

16 16 Variations of Entity: i.Weak Entity ii.Recursive Entity iii.Composite Entity iv.Entity Supertype and Subtype

17 17 Variations of Entity: i.Weak Entity – Existence-dependent – Primary key partially or totally derived from parent entity in relationship – Database designer determines whether an entity is weak based on business rules

18 18

19 19

20 20 Variations of Entity: ii.Recursive Entity Entity set that have relationship with the same entity set Example: EMPLOYEE entity employeeNOemployeeNAMEemployeeSPOUSE 111Ali Ah Chong 333Bazil 444Sheriz111 employeeNOemployeeNAMEemployeeMANAGER 111Ali Ah Chong333 Bazil Sheriz EMPLOYEE employeeNO employeeNAME married 11 employeeSPOUSE EMPLOYEE employeeNO employeeNAME manage 11 employeeMANAGER

21 Variations of Entity: iii.Composite Entity Originally a relationship between 2 entities that involved in M:N relationship Composite entity takes its primary key from both entities that it bridges Example: enroll studentIDstudentNAME courseIDcourseNAME ITS232Database CSC318IP CSC203OS STUDENT studentID studentNAME enroll M grade COURSE courseID courseNAME N studentIDcourseIDgrade ITS232A CSC318B CSC203B ITS232A- STUDENTSTUDENT_COURSE / ENROLL COURSE

22 22 Variations of Entity: iv.Entity Supertype & Subtype Parent-Child relationship Supertype  contains the shared attributes  an entity type that include distinct subclasses that required to be presented in data model  parent Subtype  contains the unique attributes  an entity type that has a distinct role and also a member of supertype  child

23 23 Variations of Entity: iv.Entity Supertype & Subtype Example: Superype ( EMPLOYEE ) Subtype ( Engineer & Full-Time )

24 24 Variations of Entity: iv.Entity Supertype & Subtype Have two types of relationship: DisjointOverlapping Unique subtype Non-overlapping: subtypes can be one of the types Overlapping: Subtypes can be either one or both of the subtypes Indicate with: GGs

25 25 Variations of Entity: iv.Entity Supertype & Subtype Example: Disjoint & Overlap Overlap Disjoint G Gs

26 26 Variations of Entity: iv.Entity Supertype & Subtype Example: Disjoint

27 27 Variations of Entity: iv.Entity Supertype & Subtype Example: Disjoint & Overlap

28 28 Attributes Represented by ovals that are connected to entity with a line Oval contains of attribute (field) it represents PK are underlined with straight line FK are underlined with doted line or * Example: Entity STUDENT with attributes name, course, studentID, address, STUDENT studentID name course address

29 29 Attributes types: i.Simple Attributes ii.Composite Attributes iii.Multivalued Attributes iv.Derived Attributes

30 30 Attributes types: i.Simple Attributes An attribute composed of single component with an independent existence Cannot be subdivided into smaller components Example: gender, martial statues STUDENT studentID phoneNO age gender name address addressTOWN addressPOSTCODE addressNO Simple Attributes

31 31 Attributes types: ii.Composite Attributes An attribute composed of multiple components, each with an independent existence Can be further subdivide to yield additional attributes Example: name  first, middle, last address  street, city, state, zip Composite Attributes STUDENT studentID phoneNO age gender name address addressTOWN addressPOSTCODE addressNO

32 32 Attributes types: iii.Multivalued Attributes attribute that holds multiple values for each occurrence of an entity type Should not be implemented multivalued attributes in relational database Can simplifies multivalued attributes by: a.Create several attributes b.Create new entity of the original multivalued attributes components Example: phone number  handset,office,home qualification  diploma,degree,master

33 33 Attributes types: iii.Multivalued Attributes Can simplifies multivalued attributes by: a.Create several attributes b.Create new entity of the original multivalued attributes components gender STUDENT studentID handsetNO age address CONTACT has homephoneNO studentID* STUDENT age gender address handsetNO homephoneNO studentID

34 34 Attributes types: iv.Derived Attributes An attributes that represents a value that is derived from the value of related attribute or set of attributes, not necessarily in the same entity type. Need not be physically stored within database Example: age, cgpa Derived Attributes STUDENT studentID phoneNO age gender name address

35 35

36 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship 36 Relationship Associations between entities Logical interaction among the entities in a relational database Operates in both directions Naming Relationships: Relationship name is a verb phrase Avoid vague names Defining Relationships: Definition explains what action is being taken and why it is important Give examples to clarify the action Optional participation should be explained Explain reasons for any explicit maximum cardinality Explain any restrictions on participation in the relationship Explain extent of the history that is kept in the relationship Explain whether an entity instance involved in a relationship instance can transfer participation to another relationship instance

37 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Chen Model: Relationship 37 Relationship is described by: i.Degree of the relationship ii.Connectivity of the relationship iii.Cardinality of the relationship iv.Participation

38 38 Relationship is described by: i.Degree of the relationship Indicates number of associated entities within the relationship There are three types: a.Unary Relationship Association is maintained within single entity a.Binary Relationship Two entities are associated c. Ternary Relationship Three entities are associated

39 39

40 40 Relationship is described by: ii.Connectivity of the relationship Logical interaction among entities in a relational database There are three types: a.1:1 b.1:M c.M:N STUDENT under PROGRAM UiTMBRANCH have RECTOR STUDENT register COURSE M N 1 M

41 41 Relationship is described by: iii.Cardinality of the relationship Express the specific number of entity occurrences associated with one occurrence of the related entity Function of organizational policy  business rules

42 42 Relationship is described by: iii.Cardinality of the relationship Example 1: One student can register 1 to 9 courses One course maximum can have 35 student (1,9) (0,35) STUDENT register COURSE N M

43 43 Relationship is described by: iii.Cardinality of the relationship Example 2: One lecturer can teaches maximum 3 courses One course can be thought by 1 lecturer only (0,3) (1,1) LECTURER teach COURSE M 1

44 44 Relationship is described by: iii.Cardinality of the relationship Example 3:

45 Relationship is described by: iii.Cardinality of the relationship Relationship Strength  Existence Dependence – Existence dependence Entity exists in database only when it is associated with another related entity occurrence – Existence independence Entity can exist apart from one or more related entities Sometimes such an entity is referred to as a strong or regular entity

46 Relationship is described by: iii.Cardinality of the relationship From Existence Dependence, exist two relationship strength: a.Weak Relationship  Entity not existence-independent on other entity  PK of related entity doesn’t contain PK component of parent entity  Non-Identifying Relationship b.Strong Relationship  Existence dependence  PK of related entity contains PK component of parent entity  Identifying Relationship 46

47 47

48 48

49 Database Systems, 9h Edition 49

50 50

51 Relationship is described by: iv.Participation Determines whether all or some entity occurrences participates in a relationship There are two types: a.Optional (Partial) One entity occurrence does not require corresponding entity occurrence in particular relationship b.Mandatory (Total) One entity occurrence requires corresponding entity occurrence in particular relationship 51

52 Relationship is described by: iv.Participation Example 1: One lecturer can teaches maximum 3 courses One course can be thought by 1 lecturer only (0,3) (1,1) LECTURER teach COURSE M 1 connectivity cardinality One class can be thought by one lecturer only One lecturer can teaches maximum 3 classes participation ‘not all lecturer teach class’ optional participation for course ‘all class are teach’ (mandatory participation for lecturer)

53 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of E-R Model 53 Alternate style developed to enable easier use of CASE tools. Chen Model The Chen notation favors conceptual modeling Crow’s Foot Model Crow’s Foot notation favors a more implementation-oriented approach UML Model UML notation can be used for both conceptual and implementation modeling

54 Comparison of E-R Modeling Symbols Cardinality & ParticipationChen ModelCrow’s Foot Model Entity Weak Entity Composite Entity Relationship line Relationship Option Symbol One (1) Symbol Many (M) Symbol 1 Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of E-R Model M

55 Chen Model Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of E-R Model

56 Crow’s Foot Model Chapter 4: Entity Relationship (E-R) Modeling 4.2 Developing An E-R Diagram: Comparison of E-R Model

57 Chapter 4: Entity Relationship (E-R) Modeling 4.3 Database Design Challenges Conflicting Goals Database designers often must make design compromises that are trigged by conflicting goals, such as comply with the design standards, processing speed and information requirements. In order to do so, – it is very important to have the entities, attributes, and relationships clearly identified and well-defined – there is a need in balancing between the customer needs and a design that meets logical requirements and conventions – The more thinking and modeling is done the less money and time are needed later on for rework Additional concerns are security, performance, shared access and integrity 57


Download ppt "ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah."

Similar presentations


Ads by Google