290 likes | 374 Views
Remember. Course Contents. Chapter No: 02. Chapter No: 02. COURSE INSTRUCTOR : ILTAF MEHDI. Course Title : Database-1. E-R Model: “An entity Relationship Model is a logical representation of data for an organization or for a business area”.
E N D
By ILTAF MEHDI (MCS, MCSE, CCNA) Remember
By ILTAF MEHDI (MCS, MCSE, CCNA) Course Contents
By ILTAF MEHDI (MCS, MCSE, CCNA) Chapter No: 02 Chapter No: 02 COURSE INSTRUCTOR: ILTAF MEHDI CourseTitle: Database-1
E-R Model: “An entity Relationship Model is a logical representation of data for an organization or for a business area”. The E-R Model is expressed in terms of entities in the business environment, the relationships or associations among entities and the attributes of both the entities and relationships. By ILTAF MEHDI (MCS, MCSE, CCNA) Entity Relational (e-r) Model
E-R Diagram: An E-R model normally expressed as an entity relationship diagram. Where “the E-R Diagram is a graphical representation of an entity relationship model”. By ILTAF MEHDI (MCS, MCSE, CCNA) Entity relationship Diagram
There is no industry standard notation for the E-R model. But some basic notations combine most of the desirable features of the different notations that are commonly used. The basic notations used for E-R model are given on the next slide. By ILTAF MEHDI (MCS, MCSE, CCNA) E-R Model notations
By ILTAF MEHDI (MCS, MCSE, CCNA) E-r model notations Associative Entity Strong Entity Weak Entity Attribute Relationship Multi-Valued Attribute Identifying Relationship Derived Attribute
The basic constructs of the E-R model are: • Entities • Attributes • Relationships or Associations By ILTAF MEHDI (MCS, MCSE, CCNA) E-r model constructs
1. Entity: • “An entity is a person, place, object, event or concept in the user environment about which the organization whishes to maintain data”. • Some examples of each of these types of entities are given below: PERSON: Employee, Student, Patient etc PLACE: City, State, Country etc OBJECT: Machine, Building, Automobile etc EVENT: Sale, Registration, Renewal etc CONCEPT: Account, Course, Work Center etc By ILTAF MEHDI (MCS, MCSE, CCNA) E-r model constructs
Following are the major types of the entity: Entity Type Entity Instance Strong Entity Type Weak Entity Type By ILTAF MEHDI (MCS, MCSE, CCNA) Types of entity
Entity Type: “A collection of entities that share common properties or characteristics is called entity type”. Entity type is also called Entity Class. 2. Entity Instance: “The single occurrence of an entity type is called entity instance”. An entity Type is described just once in a database, while many instances of that entity type may be represented by data stored in the database. For example: An entity Type “Employee” has many entity instances in organization. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of entity
3. Strong Entity Type: “An entity that exists independently of other entity types is called Strong Entity Type”. 4. Weak Entity Type: “An entity Type whose existence depends on some other entity type is called Weak Entity Type”. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of entity
Identifying Relationship: “The relationship between weak entity type and its owner is called Identifying Relationship”. Identifying Owner: “The entity type on which the weak entity type depends is called Identifying Owner”. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of entity
By ILTAF MEHDI (MCS, MCSE, CCNA) Attributes Emp-Id Emp-Name Dependent-Name Date-Of-Birth EMPLOYEE Has DEPENDENT STRONG ENTITY OR IDENTIFYING OWNER IDENTIFYING RELATIONSHP WEAK ENTITY
2. Attribute: “A property or characteristics of an entity type that is of an interest to the organization is called attribute”. Following are some entity types and their attributes, (shown by shorthand notation): STUDENT (st-Id, st-Name, st-F/Name, st-Address etc) EMPLOYEE (Emp-id, Emp-Name, Emp-Skill etc) AUTOMOBILE (Vechile-id, Vechile-Color, Vechile-Weight etc ) By ILTAF MEHDI (MCS, MCSE, CCNA) E-r model constructs
Following are the major types of attribute: Simple Attribute Composite Attribute Multi-Valued Attribute Derived Attribute Identifier Composite Identifier By ILTAF MEHDI (MCS, MCSE, CCNA) Types of attributes
Simple Attribute: “An attribute that can’t be broken down into smaller components is called Simple Attribute”. For example: All Attributes associated with AUTOMOBILE are Simple Attributes. 2.Composite Attribute: “An attribute that can be broken down into components is called Composite Attribute”. For example: “Address” attribute is a Composite Attribute which can be broken down intoStreet-Add, City-Add, State-AddandPostal-Code. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of attributes
3. Multi-Valued Attribute: “An attribute that may take on more than one value for a given entity instance is known as Multi-Valued Attribute”. Multi-Valued Attribute is indicated by “double ellipse” in an E-R Diagram. 4. Derived Attribute: “An Attribute whose values can be calculated from related attribute value is known as Derived Attribute”. Derived Attribute is indicated by “ellipse with dashed line” in an E-R Diagram. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of attributes
By ILTAF MEHDI (MCS, MCSE, CCNA) Identifier Composite Attribute Emp-Id Emp-Name Emp-Address Derived Attribute Multi-Valued Attribute EMPLOYEE Year-Employed Skill Date-Employed
5. Identifier: “An Attribute that uniquely identifies individual instances of an entity type is called Identifier or Key”. Identifier name or key is underlined in E-R diagram. 6. Composite Identifier: “An identifier that consists of a composite attribute is known as Composite Identifier or key”. Composite Identifier or key is underlined while the components are not underlined in E-R diagram. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of attributes SEE THE EXAMPLES ON NEXT SLIDE
By ILTAF MEHDI (MCS, MCSE, CCNA) Other attributes st-Id st-Name STUDENT In the above E-R diagram, the Identifier for STUDENT entity type is “st-Id” (Student-ID). Flight-No Date No-of-passengers Flight-Id FLIGHT In the above E-R diagram, the composite Identifier for FLIGHT entity type is “Flight-Id” .
3. Relationship: • Relationship is also called association. • Def:“An association is a logical relation between data items”. OR • “the meaningful connection between data items is called relationship or association ”. OR • “An association is a relationship between the instances of one or more entity types that is of an interest to the organization”. • Diamond symbol is used to show the relationship between entities. For example: By ILTAF MEHDI (MCS, MCSE, CCNA) E-r model constructs Reg-No student has Relationship
Def: “The number of entity types that participate in a relationship is known as Degree of association or relationship”. Associations may be: Unary (Degree 1) Binary (Degree 2) Ternary (Degree 3) By ILTAF MEHDI (MCS, MCSE, CCNA) Degreeof association or relationship
By ILTAF MEHDI (MCS, MCSE, CCNA) Relationship degree b. Binary Relationship a. Unary Relationship c. Ternary Relationship
There are three main types of association and reverse association. Which are given below: One to One Relationship One to Many Relationship (or Many to One) Many to Many Relationship By ILTAF MEHDI (MCS, MCSE, CCNA) Typesof Association and reverse association
1. One to One Relationship: “When one occurrence of entity A can relate to one and only one occurrence of entity B and reversely the occurrence of entity B can relate to one and only one occurrence of entity A is called one to one relationship”. One to One Relationship can be represented by one-head arrow. For example: “Student has only one Reg-no” and reversely “On one Reg-no there must be only one Student”. Similarly,“A Patient can have only one Bed” and reversely “On one Bed there must be only one Patient” By ILTAF MEHDI (MCS, MCSE, CCNA) Types of Relationship A B Student Reg-no A B Patient Bed
2. One to Many Relationship (or Many to One): “When One occurrence of entity A can relate to many occurrences of entity B then it is called One to many relationship butreversely when an occurrence of entity B can relate to only occurrence of entity A then it is called Many to one relationship”. One to Many Relationship can represented by double-head arrow. For Example:“A Mother can have many Childs” but reversely “a Child can have only one Mother”. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of Relationship A B Mother Child
3. Many to Many Relationship: “An occurrence of entity A can relate to more occurrences of entity B and reversely an occurrence of entity B can relate to more occurrences of entity A is called Many to Many Relationship”. For example: “A Student can have many teachers” and reversely “A Teacher can have many students”. Similarly, “A Student can take many courses” and reversely “A Course can be taken by many students”. By ILTAF MEHDI (MCS, MCSE, CCNA) Types of Relationship A B Student Teacher A B Student Course
By ILTAF MEHDI (MCS, MCSE, CCNA) Relationship cardinality Mandatory One Mandatory Many Optional One Optional Many