59
Conceptual Design Conceptual Design and Data Modeling and Data Modeling Chapter 2 Chapter 2

Conceptual Design and Data Modeling Chapter 2. 10/15/2015Chapter 22 of 37 Database Design Process Conceptual Design Conceptual Design Investigate business

Embed Size (px)

Citation preview

  • Conceptual Design and Data ModelingChapter 2

    Chapter 2

  • *Chapter 2* of 37 Database Design ProcessConceptual DesignInvestigate business requirements and data used.How to present the data to the end user.Independent of hardware and software.Database DesignPhysical Design

    Chapter 2

  • *Chapter 2* of 37 Database Design ProcessConceptual DesignDatabase DesignConvert data model into tables in a relational database.Normalizing process.Primary keys and foreign keys to connect the tables.Constraints implemented for attributesPhysical Design

    Chapter 2

  • *Chapter 2* of 37 Database Design ProcessConceptual DesignDatabase DesignPhysical DesignSpecify the hardware, software and physical environment.Where to store the data.How to import and export data.Enforce security measures.

    Chapter 2

  • *Chapter 2* of 37 Understanding the Business ProcessCollect the following information:What works and what does not in the current business process.Goals the database will achieve.Type and amount of data to be stored.Business rules.How the data will be used in the business process.Implementation problems and limitations.

    Chapter 2

  • *Chapter 2* of 37 Understanding the Business ProcessHow and where can you find the above information?Examining the companys documents.Observe how data are transferred from one location to another.Identify and interview the key players in the business process.

    Chapter 2

  • *Chapter 2* of 37 Case StudyHillcrest Computing Business ProcessPages. 20 24Hillcrest Computing manufactures and sells computer productsIt customizes computer systems based on customers requests.It buys computer parts from different vendors.It has four sales centers across the nation.

    Chapter 2

  • *Chapter 2* of 37 Case StudyAt each sales center, there are about 10 employees.Customer purchase orders are processed at each sales center.Each purchase order may contain different shipping addresses.One shipping address may also place multiple orders.

    Chapter 2

  • *Chapter 2* of 37 Case Study (Sale)When a customer places an order, a purchase order form will be filled out.The form includes items such as:Type of computer systemOrder datePriceShipping information such as customer name, address, and timeSales center where the order is processed

    Chapter 2

  • *Chapter 2* of 37 Case Study (Sale)When purchase orders (PO) come in, the assembly workers will assemble the computer systems.One PO may include one or more types of computer systems.Different POs may contain the same type of computer system.

    Chapter 2

  • *Chapter 2* of 37 Case Study (Assembly)To assemble a computer system, several workers will participate in an assembly process.Each assembly worker may assemble many computer systems, i.e., he or she may participate in many assembly processes.

    Chapter 2

  • *Chapter 2* of 37 Case Study (Assembly)In an assembly process, computer parts such as hard drives, memory, and motherboards will be put together to make a computer system based on the customers request.Different computer systems may use the same kind of parts. Ex. Two computer systems with different operating systems may have the same kind of hard drive.Detailed information for each part is kept for reference.

    Chapter 2

  • *Chapter 2* of 37 Case Study (Assembly)After a computer system is assembled, the workers need to fill out a form that is used to track the products. The form includes the following items:Workers ID numbers and namesTime used to complete the jobType of computer system assembledParts used for the job

    Chapter 2

  • *Chapter 2* of 37 Case Study (Accounting)The cost of a computer system will depend on the labor cost of the workers, the parts used for the computer system, and other miscellaneous costs.The company needs to keep track of the information about ordering, computer system assembling, computer parts, labor costs, and shipping.

    Chapter 2

  • *Chapter 2* of 37 Case Study (Accounting)The accountants will record computer system prices on purchase orders, costs of computer parts purchased from various vendors, etc.They need to keep records of the following items:Operation costs of the sales centersCosts of computer partsRevenue produced at each sales centerPrices of computer systems sold to customersSalaries paid to Hillcrest Computing employees

    Chapter 2

  • *Chapter 2* of 37 Case Study (Personnel)Key players in the company:

    Chapter 2

  • *Chapter 2* of 37 Case Study (Problem)YOU the manager of IT have been asked to computerized this process by designing and implementing a database for the company.

    Chapter 2

  • *Chapter 2* of 37 Case Study (YOU)After talking with the key people, you have identified the goals of the database project as follows:Store the necessary information in a database to reduce the time to complete forms.Make sure that the sales manager is informed of the assembly process.Help the accounting manger collect productivity information.Track market prices of computer parts and other details.

    Chapter 2

  • *Chapter 2* of 37 Case Study (YOU)You have classified the information into the following categories:Order-Shipping SystemSales center information managementPurchase order managementShipping managementInventory SystemComputer parts inventoryParts detail informationAssembly SystemAssembly worker managementAssembly process information

    Chapter 2

  • *Chapter 2* of 37 Case Study (YOU)By carefully interpreting the interview results, the database designer (YOU) comes up with a logical representation of the database structure also called a data model.This is the designers view of the business data.At this point, the database designer will focus on the components of data modeling that

    Chapter 2

  • *Chapter 2* of 37 Case Study (YOU)At this point, the database designer will focus on the components of data modeling that include:Entities,Attributes,Domains,Relationships,Business rules.

    Chapter 2

  • *Chapter 2* of 37 Entity-Relationship Data ModelOne of the most widely used modeling tool developed in the 1970s.A graphical tool used to represent the logical structure of a database.Keep in mind that after you have populated a database with data, it is very difficult to make changes to the structure of the database.

    Chapter 2

  • *Chapter 2* of 37 EntityAn entity is a generic name for an object, such as a person, a computer, or a location that you want to keep in a database.Entities are things referred to as nouns.Each worker in the assembly worker group is known as an entity instance.A collection of entity instances is called an entity class.

    Chapter 2

  • *Chapter 2* of 37 EntityGraphically, an entity is represented by a rectangle with the entity name printed on it in capital letters.PART_DETAIL

    Chapter 2

  • *Chapter 2* of 37 AttributesAttributes are used to describe an entity, such as a persons name, social security number, and gender.An instance of the entity.A composite attribute is a set of related attributes, such as an Address that consists of the Street, City, State, and Zip.A multi-valued attribute has more than one value in it. Ex. The attribute Car may contain two values if a person has two cars.

    Chapter 2

  • *Chapter 2* of 37 IdentifiersTo identify the entity instances that are workers, an identifier such as worker ID is required.An identifier can consist of more than one attribute. Ex. A combination of the first and last name.

    Chapter 2

  • *Chapter 2* of 37 IdentifiersWhen an identifier is used to identify each individual entity instance, it is unique.However, to identify groups of instances, the identifier can be non-unique because all members in the same group are identified by the same id.A unique identifier is called a key.When there is no unique identifier from the attributes of an entity, a sequence of unique numbers can be used. Called a surrogate key.

    Chapter 2

  • *Chapter 2* of 37 DomainsThe set of possible values that an attribute can use is called a domain.Ex. The possible values for the attribute Gender are male or female.The set {male, female} is the domain for the attribute.Data types and constraints are specified in the domain of an attribute.

    Chapter 2

  • *Chapter 2* of 37 RelationshipsEntities are often related to one another.Relationships are used to describe how entities are associated with each other.Ex. Because apartments are built inside buildings, the Apartment entity is related to the Building entity.Four major types of relationships

    Chapter 2

  • *Chapter 2* of 37 1. Identifying RelationshipsConsider the relationship between the Apartment entity and the Building entity.Two apartments built in two buildings may have the same apartment number.To distinguish between these two apartments, you need to attach the building number to the apartment number.

    Chapter 2

  • *Chapter 2* of 37 1. Identifying RelationshipsThe apartment id depends on the existence of the building id.Hence, the identifier for the Apartment entity should include the identifier for the Building entity.Such a relationship is called an identifying relationship.The Apartment entity is the child entity.The Building entity is the parent entity.

    Chapter 2

  • *Chapter 2* of 37 1. Identifying RelationshipsGraphically, the identifying relationship is represented by a solid line.The parent entity is represented by a rectangle.The child entity is a rounded rectangle.A filled-in black dot placed on the side of the child means that zero, one, or many apartments may be related to a single building.In a 1:N relationship, the black dot is on the N side.

    Chapter 2

  • *Chapter 2* of 37 1. Identifying RelationshipsIn an identifying relationship, the key for the child entity always includes the key from the parent entity.When the key from one entity is used by another entity, it is called the foreign key and is denoted by (FK).BuildingIdBuildingNameSquareFootageApartmentNumberBuildingId (FK)TypeRentBUILDINGAPARTMENT1:N

    Chapter 2

  • *Chapter 2* of 37 2. NonIdentifying RelationshipsConsider the relationship between the Advisor entity and the Student entity.A faculty may advise zero, one, or many students, so it is a 1:N relationship.However, each student has his or her own id, and the faculty id is not part of the key for the Student entity.Such a relationship is called a nonidentifying relationship.

    Chapter 2

  • *Chapter 2* of 37 2. Nonidentifying RelationshipsAlthough the entities are related by placing the advisor id in the Student entity, this time the advisor id is NOT part of the key for the Student entity.AdvisorIdFirstNameLastNameTeachingAreaStudentIdFirstNameLastNameMajorAdvisorId (FK)ADVISORSTUDENT

    Chapter 2

  • *Chapter 2* of 37 3. Nonspecific RelationshipsConsider the relationship between the Student entity and the Class entity.A student may take many classes.Many students may take the same class.Such a relationship does not have a direction from the parent entity to the child entity.This is called a nonspecific relationship, or a many-to-many (M:N) relationship.

    Chapter 2

  • *Chapter 2* of 37 3. Nonspecific RelationshipsGraphically, a nonspecific relationship is represented by a solid line with a filled-in black dot on each end.Physically, it is difficult to implement such a relationship. InsteadOften represented by two specific 1:N relationships with an intersection entity containing only the keys from the two entities.

    Chapter 2

  • *Chapter 2* of 37 3. Nonspecific RelationshipsClassIdClassNameTimeDayInstructorClassRoomClassID (FK)StudentID (FK)StudentIdFirstNameLastNameMajorAdvisorIdSTUDENTCLASSSTUDENT_CLASS

    Chapter 2

  • *Chapter 2* of 37 4. Categorization RelationshipsCategorization relationship is used to represent one entity that is a specific type of another entity.Consider the Employee entity which includes the faculty and staff.The faculty and staff have some unshared attributes. If we place all the unshared instances in the Employee entity, the unshared attributes will contain a large number of null values.

    Chapter 2

  • *Chapter 2* of 37 4. Categorization RelationshipsWe can placed the shared attributes into the generic entity Employee and the unshared attributes into the specific entity Professor and Staff.Such a relationship is called a categorization relationship.The generic entity is the parent entity.The specific entities are the child entities.

    Chapter 2

  • *Chapter 2* of 37 4. Categorization RelationshipsAn incomplete categorization is if some possible categories are not included in the relationship.A complete categorization is when every possible specific entity is included in the categorization.

    Chapter 2

  • *Chapter 2* of 37 4. Categorization RelationshipsEmployeeIdNamePhone NumberOfficeJobCodeEmployeeId (FK)RankTeachingAreaEMPLOYEEPROFESSOREmployeeId (FK)PositionDutySTAFFShared attributesUnshared attributesIncomplete

    Chapter 2

  • *Chapter 2* of 37 4. Categorization RelationshipsEmployeeIdNamePhone NumberOfficeJobCodeEmployeeId (FK)RankTeachingAreaEMPLOYEEPROFESSOREmployeeId (FK)PositionDutySTAFFShared attributesUnshared attributesCompleteEmployeeId (FK)HourlyRateWorkScheduleSTUDENT_WORKDER

    Chapter 2

  • *Chapter 2* of 37 HAS-A RelationshipsTwo types of 1:N relationships:A HAS-A relationship associates entities of different logical types.One or more attributes in the parent entity are used by the child entities.Ex. The Class and Student entities

    Chapter 2

  • *Chapter 2* of 37 IS-A RelationshipsAn IS-A relationship associates entities having the same logical type.The child entities are the specific types of the parent entity.The parent entity contains attributes that are common to all the child entities, and each child entity contains attributes specific to itself.Ex. The Employee, Faculty, and Staff.

    Chapter 2

  • *Chapter 2* of 37 CardinalityCardinality is the number of entity instances that can be involved in a relationship.One-or-more cardinality: PEx. Each advisor must advise at least one student.M:N cardinality:Ex. A class can have 1 to 25 students.Zero-or-one cardinality: ZEx. An employee is either a faculty or staff

    Chapter 2

  • *Chapter 2* of 37 Relationship NamingYou can name a relationship by placing a name on the line between a parent and child.Name the relationship with a verb phrase from parent to child.

    Chapter 2

  • *Chapter 2* of 37 Recursive RelationshipsA binary relationship is when a relationship connects two entities.A recursive relationship is when the parent and child entities are the same entity.Ex. In the Student entity, you have the attribute StudentSpouse. A students spouse may also be a student.

    Chapter 2

  • *Chapter 2* of 37 Ternary RelationshipIn a ternary relationship, three or more entities are involved.Ex. Consider the situation where there are many classes and each may have multiple sections.A professor teaches four class sections; each section may be taught by more than one professor. M:N relationship.Each section may use more than one classroom; each classroom for many classes. M:N relationship.

    Chapter 2

  • *Chapter 2* of 37 Business RulesBusiness rules are set up by companies to control business behaviors.A well-defined database should implement these rules.Ex. A senior sales person have sold at least 1000 computer systems

    Chapter 2

  • *Chapter 2* of 37 Hillcrest Computing ExampleGoals:Reduce the time to complete forms.Allow the sales manager to be informed of the assembly process.Help the accounting manager to collect productivity information.Track market prices of computer parts.

    Chapter 2

  • *Chapter 2* of 37 Hillcrest Computing ExampleSteps in developing the E-R model:Identifying the entities.By examining the nouns in the business requirements.Identifying attributes for the entities.Identifying relationships among the entities.Identifying cardinalities.

    Chapter 2

  • *Chapter 2* of 37 Hillcrest Computing Example

    Chapter 2

  • *Chapter 2* of 37 Identifying EntitiesThe first goal is to help workers fill out the forms electronically. On the forms, one needs the information about:ASSEMBLY_WORKERASSEMBLY_PROCESSCOMPUTER_SYSTEMPART

    Chapter 2

  • *Chapter 2* of 37 Identifying EntitiesThe second goal is to allow the sales manager and sales clerks to check the production progress with the following entities:SALES_CENTERPURCHASE_ORDERSHIPPING

    Chapter 2

  • *Chapter 2* of 37 Identifying EntitiesThe third goal requires information about costs of computer parts and assembly workers. The following entities will store information about labor cost and system cost.SYSTEM_PARTSYSTEM_WORKER

    Chapter 2

  • *Chapter 2* of 37 Identifying EntitiesThe cost of a part depends on detailed market information, so we have the entity:PART_DETAIL

    Chapter 2

  • *Chapter 2* of 37 Identifying AttributesAfter the entities are created, we add attributes to the entities.

    Chapter 2

  • *Chapter 2* of 37 Hillcrest Computing Example

    Chapter 2