Conceptual modeling of databases Database Management Systems Instructor: Karthik Srinivasan 5/19/2019 Database Management Systems
Recollect What is a database? A database is an organized collection of logically related data, designed to meet the information needs of an organization 5/19/2019 Database Management Systems
Learning objectives To be able to describe a database miniworld To be able to describe what is conceptual model in database design To be able to define the elements of a conceptual model To be able to create a conceptual model (i.e., an entity relationship diagram) for a given description of a miniworld 5/19/2019 Database Management Systems
Miniworld A miniworld is a system we are interested in knowing more about, and whose data we wish to store and access using a database Examples of miniworlds: A company A restaurant A shop A hospital Miniworld are also called as universe of discourse. 5/19/2019 Database Management Systems
A miniworld contains entities Customers Products Employees Transactions Operating costs Miniworld of a shop Suppliers Stock Can you list entities of the miniworld of a university? 5/19/2019 Database Management Systems
What is a conceptual model? Schema of a database modeled as a collection of entities and relationships among entities Also called Entity-Relationship Diagram or an ER model Representation of business rules and requirements as a diagram What is the need to represent business rules using a conceptual model? 5/19/2019 Database Management Systems
Need for a conceptual model Starting point for the design process after requirement gathering/analysis A communication tool to describe the database A model is independent of technology Elicits business rules to all stakeholders Strong foundation for development process 5/19/2019 Database Management Systems
How a conceptual model looks like… 5/19/2019 Database Management Systems
Chen notation for conceptual modeling 5/19/2019 Database Management Systems
Entity class, instance and attribute Entity class: An abstract representation of a person, place, thing, or event about which information is maintained e.g., Customer, Product, Company Instance: A specific person, place, thing, or event; a single representation of an entity e.g., John (Customer), iPhone X (Product), Intel (Company) Attribute: A characteristic or quality of an entity e.g., Age (Customer), Cost (Product), Turnover (Company) A record is also called instance/tuple/entry 5/19/2019 Database Management Systems
Entity class, instance and attribute Entity class often corresponds to a table in a database e.g., Customers table, Products table, Companies table Instances correspond to rows in the table represented by an entity class Attributes correspond to columns in the table represented by an entity class A record is also called instance/tuple/entry 5/19/2019 Database Management Systems
Entity class and instances Students Entity/Instance “Hi - I’m Mark.” “Hi - I’m John.” “Hi - I’m Julia.” Entity class 5/19/2019 Database Management Systems
Entity class as a table Students Given that we have some information about each of these students, we can create the following table STUDENTS table Students Mark John Julia Student Name Student Email Student GPA Mark mark@highschool.com 3.8 John john@highschool.com Julia julia@highschool.com 3.9 … 5/19/2019 Database Management Systems
Representing the Entity class STUDENTS table STUDENTS Entity class Student Name Student Email Student GPA Mark mark@highschool.com 3.8 John john@highschool.com Julia julia@highschool.com 3.9 … STUDENTS student GPA student Name Student Email Note that the conceptual model does not show entity instances! 5/19/2019 Database Management Systems
A more verbose example John Doe bought 10 dollars worth of Cheese and 20 dollars worth of Ham in the foods section of Walmart How many entities are present in the above Walmart mini-world? A record is also called instance/tuple/entry Note that the mini-world (i.e., Walmart) itself is NOT specified as an entity 5/19/2019 Database Management Systems
Entities – Example (contd.) Answer: 4 entities from 3 entity classes John Doe bought 10 dollars worth of Cheese and 20 dollars worth of Ham in the foods section of Walmart A record is also called instance/tuple/entry 5/19/2019 Database Management Systems
Entities – Example (contd.) John Doe bought 10 dollars worth of Cheese and 20 dollars worth of Ham in the foods section of Walmart PRODUCTS table CUSTOMERS table Product Product ID Product type Cheese 23322 Milk-based Ham 23244 Meat … Name Customer ID Address John Doe 832333 1333 N . … SECTIONS table Section Section ID Section category Foods 2 Perishable … 5/19/2019 Database Management Systems
Primary Key Primary key is an attribute in an entity class that uniquely identifies an entity/instance It is one of the attributes chosen to identify entity instances uniquely The attribute which is the primary key: Should not change values over time for each row Must be unique for each row Must have non-null values for each row 5/19/2019 Database Management Systems
Primary key - Example STUDENTS studentID studentName studentEmail STUDENTS table Student ID Student Name Student Email 212 Mark mark@highschool.com 213 John john@highschool.com 214 Julia julia@highschool.com … Why should StudentID be the primary key and not Name or Email? 5/19/2019 Database Management Systems
Primary key – Another example TEACHERS teacherID teacherName teacherEmail teacherSalary Which is the primary key for TEACHERS entity class? Can you create the table for the TEACHERS entity class? 5/19/2019 Database Management Systems
TEACHERS entity class TEACHERS Teacher ID Teacher Name Teacher Email teacherSalary Teacher ID Teacher Name Teacher Email Teacher salary 512 Martha martha@highschool.com NULL 513 Bob bob@highschool.com 44,500 … TEACHERS table 5/19/2019 Database Management Systems
COURSES entity class We want to represent all COURSES and keep track of course numbers and course names. courseNo courseName Course ID Course Name 122 Geography 123 History … COURSES 5/19/2019 Database Management Systems
What we have done so far We have created the STUDENTS, TEACHERS, and COURSES entity classes Each entity has its own attributes Each entity has a primary key 5/19/2019 Database Management Systems
Entities are connected by Relationships TEACHERS teach COURSES teacherEmail teacherName courseNo courseName Teach COURSES TEACHERS teacherSalary teacherID 5/19/2019 Database Management Systems
Entities are connected by Relationships STUDENTS enroll in COURSES courseName studentID courseNo Enroll_In STUDENTS COURSES studentName studentEmail 5/19/2019 Database Management Systems
Conceptual model for our example courseNo courseName teacherEmail teacherName Teach COURSES TEACHERS teacherSalary teacherID studentID Enroll_In STUDENTS studentName studentEmail Miniworld description: Teachers teach courses in which students enroll into 5/19/2019 Database Management Systems
Conceptual modeling guidelines Get description of the mini-world through requirement analysis Determine entity classes from the description Mark attributes for the entity classes Mark identifiers for each entity class Determine relationship classes among the entity classes Capture the user data requirements using entities, the properties of entities (i.e., attributes) and relationships between entities Use different names for different elements If an entity has only one attribute, ask yourself if it is really necessary 5/19/2019 Database Management Systems
What we learned in this module Describe a database miniworld Describe what is conceptual model in database design Define the elements of a conceptual model – Entity class, entity instances, entity attributes, relationship, primary key Create a conceptual model (i.e., an entity relationship diagram) for a given description of a miniworld 5/19/2019 Database Management Systems
A take-home example Mariott international is a hospitality company that owns several hotels across the globe. Each hotel has a unique hotel ID, website, address and customer service phone number and email. Customers checking into hotels in Mariott are assigned a unique customer number. Information such as phone number, credit card type, number of days of stay, check-in date, type of suite booked are logged for each customer. Refer the reference textbook for more worked out examples. More practice is always recommended 5/19/2019 Database Management Systems
Topics for upcoming classes Types of attributes Cardinality of relationships Types of relationships Weak entity classes Enhanced ER modeling 5/19/2019 Database Management Systems