150 likes | 199 Views
Learn how entities, attributes, and relationships are defined in a conceptual data model. Explore guidelines for naming and defining entity types, attributes, and relationships, illustrated with examples. Understand types of relationships like one-to-one, one-to-many, and many-to-many in an entity-relationship diagram.
E N D
Conceptual data model From the statement of data requirements a conceptual data model is produced. This describes how the data elements in the database are to be grouped. Three terms are used to describe the data requirements: Entity • An entity is a thing of interest to an organisation about which data is to be held Attribute: • An attribute is a property or characteristic of an entity Relationship: • A relationship is a link or association between entities Mazharjaved2001@yahoo.com
Association between the instances of one or more entity types EntityName Verb Phrase AttributeName named property or characteristic of an entity Person, place, object, event or concept about which data is to be maintained Represents a set or collection of objects in the real world that share the same properties Mazharjaved2001@yahoo.com
Entities • Examples of entities: • Person: EMPLOYEE, STUDENT, PATIENT • Place: STORE, WAREHOUSE • Object: MACHINE, PRODUCT, CAR • Event: SALE,REGISTRATION, RENEWAL • Concept: ACCOUNT, COURSE • 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. Mazharjaved2001@yahoo.com
Attributes • Example of entity types and associated attributes: STUDENT: Student_ID, Student_Name, Home_Address, Phone_Number, Major • Guidelines for naming 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. Mazharjaved2001@yahoo.com
Relationships • Associations between instances of one or more entity types that is of interest • Given a name that describes its function. • relationship name is an active or a passive verb. Relationship name: writes Book Author An author writes one or more booksA book can be written by one or more authors. Mazharjaved2001@yahoo.com
Types of relationship • One-to-one • Eg Products in a supermarket each have a unique barcode number. • One-to-many • Eg A video club member may hire out a number of videos. • Many-to-many • Teachers and pupils in a school. Each teacher teaches many pupils and each pupil has many teachers. Mazharjaved2001@yahoo.com
Types of relationship • One to One. • 1. A department in school is led up by an individual person, and this person only leads one department. • One to Many • The head of department may be in charge of many staff, but these staff only have one head of department. • Many to Many • A teacher may order many books, but each book could be ordered by many teachers. Mazharjaved2001@yahoo.com
drives (One-to-one) Employee Company car holds Ward Patient (One-to-many) features Album Singers (Many-to-many) Entity-relationship diagrams • An entity-relationship diagram is a diagrammatic way of representing the relationships between the entities in a database. Mazharjaved2001@yahoo.com
Data Requirements for a Hospital In-patient System • A hospital is organised into a number of wards. • Each ward has a ward number and a name recorded, along with a number of beds in that ward. • Each ward is staffed bynurses. • Nurses have their staff number and namerecorded, and are assigned to a single ward. • Each patient in the hospital has a patient identificationnumber, and their name, address and date of birth are recorded. • Each patient is under the care of a single consultant and is assigned to a single ward. • Each consultant is responsible for a number of patients. Consultants have their staff number, nameand specialismrecorded. Mazharjaved2001@yahoo.com
Entity Relationship Diagram • Entity ( identifier ) • Ward Ward Id • Nurse Staff id • Patient Patient id • Consultant Staff id holds Ward Patient (One-to-many) Sees Staffed by Consultant Nurse Mazharjaved2001@yahoo.com
Scenario • Each semester, each student must be assigned an advisor who counsels students about degree requirements and helps the students register for classes. • Each student must register for classes with the help of an advisor, but if the student’s assigned advisor is not available, the student may register with any advisor. • We must keep track of students, the assigned advisor for each, and the name of the advisor with whom the student registerd for the current term. Mazharjaved2001@yahoo.com
ERD For Scenario Mazharjaved2001@yahoo.com
Scenario • A course is always taught by some teacher. • A teacher cannot exist without corresponding course. A course may be taught by at least one or more teachers. • On the other hand, a teacher may teach at least one or more courses. • Draw ERD diagram ??? Mazharjaved2001@yahoo.com
Scenario 2 • Each department has a chairman while a chairman chairs only one department. • The relationship between department and chairman will be what?? Mazharjaved2001@yahoo.com