Bài giảng Management information systems - Module C: Designing Databases and Entity-Relationship Diagramming

INTRODUCTION Database – collection of information that you organize and access according to the logical structure of that information Relational database – uses a series of logically related two-dimensional tables or files to store information in the form of a database

ppt41 trang | Chia sẻ: baothanh01 | Lượt xem: 749 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Bài giảng Management information systems - Module C: Designing Databases and Entity-Relationship Diagramming, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Extended Learning Module CDesigning Databases and Entity-Relationship DiagrammingINTRODUCTIONDatabase – collection of information that you organize and access according to the logical structure of that informationRelational database – uses a series of logically related two-dimensional tables or files to store information in the form of a database DESIGNING & BUILDING A RELATIONAL DATABASEDefine entity classes & primary keysDefine relationships among classesDefine information for each relationRelation = table = fileUse a data definition language to create database Remember Solomon Enterprises?From Chapter 3Provides concrete to commercial builders & home ownersChapter 3 – the CRM side of Solomon’s databaseFocus now – SCM side of Solomon’s database Remember Solomon Enterprises?Remember Solomon Enterprises?Solomon’s database tablesCustomerConcrete TypeOrderTruckEmployee Observations for Solomon5 concrete typesHome foundation and walkwaysCommercial foundation and infrastructurePremier speckled (with gravel)Premier marblePremier shell Observations for SolomonObservations for Solomon6 raw materialsWaterCement pasteSandGravelMarbleShellMixing instructions are for a cubic yard Observations for SolomonSome raw materials are in several concrete typesConcrete types require several raw materialsInventory (QOH) is tracked for all raw materials Observations for SolomonSuppliers provide raw materialsSolomon uses only 1 supplier for a given raw materialA supplier can provider several raw materials Observations for SolomonWaterSupplier not trackedQOH not tracked Business Rules for SolomonGiven concrete type will have many raw materialsGiven raw material may appear in many concrete typesEach raw material has one and only one supplier Business Rules for SolomonA supplier may provide many raw materialsThere may be suppliers present not providing any raw materialsThese business rules are very important to remember STEP 1: DEFINE ENTITY CLASSES & PRIMARY KEYSEntity class – concept – typically, person, place, or thing – about which you wish to store information and that you can identify with a unique key (primary key)Concrete TypeRaw MaterialSupplier STEP 1: DEFINE ENTITY CLASSES & PRIMARY KEYSPrimary key – a field (or group of fields) that uniquely describe each recordA record in a database is sometimes called an instance (of an entity class) STEP 1: DEFINE ENTITY CLASSES & PRIMARY KEYSIn general, stay away from names for primary keys (duplicates)Concrete Type – Concrete TypeRaw Material – Raw Material IDSupplier – Supplier ID STEP 1: DEFINE ENTITY CLASSES & PRIMARY KEYSSTEP 2: DEFINE RELATIONSHIPS AMONG ENTITY CLASSESTo define relationships, you create an E-R diagramEntity-relationship (E-R) diagram – a graphic method of representing entity classes and their relationships E-R DiagramsUse 5 symbolsRectangle – entity classDotted line – relationship| - single relationship0 – zero/optional relationshipCrow’s foot () – multiple relationship E-R DiagramsE-R DiagramsFigure C.2 on page 375 reads asA Concrete Type is composed of Raw MaterialA Raw Material is used to create a Concrete TypeA Supplier provides a Raw MaterialA Raw Material is provided by a Supplier E-R Diagrams - CardinalityE-R diagrams show relationshipsThey also show numerical nature of relationshipsThis is called cardinality| - single relationship0 – zero/optional relationship - multiple relationship E-R Diagrams - CardinalityFollowing lines marked A:A Supplier may not provide any Raw Material (0) but may provide more than one Raw Material ()E-R Diagrams - CardinalityFollowing lines marked B:A Raw Material must be provided by a Supplier (|) and can only be provided by one Supplier (|) NormalizationNormalization – process of assuring that a relational database structure can be implemented as a series of two-dimensional tablesWe will follow three rules of normalization Normalization RulesEliminate repeating groups or many-to-many relationshipsAssure that each field in a relation depends only on the primary key for that relationRemove all derived fields from the relations Eliminating Many-to-Many RelationshipsA many-to-many relationship exists if there is a crow’s foot () on each endYou must eliminate these by creating an intersection relation Eliminating Many-to-Many RelationshipsEliminating Many-to-Many RelationshipsIntersection (composite) relation – a relation you create to eliminate a many-to-many relationshipIntersection relation will have a composite primary keyComposite primary key – consists of the primary key fields from the two intersecting relations Solomon’s New Database Structure Steps to Eliminate a Many-to-Many Relationship Draw the part of the E-R diagram with many-to-many relationshipWrite some primary keys for each relationCreate new E-R diagram with intersection relation in the middleWrite some composite primary keys for intersection relation Steps to Eliminate a Many-to-Many Relationship Create a meaningful name for intersection relationMove minimum cardinality next to left relation to the right of intersection relationMove minimum cardinality next to right relation to the left of intersection relation Steps to Eliminate a Many-to-Many Relationship Maximum cardinality on both sides of intersection relation is always many ()General rule – new minimum and maximum cardinalities for the 2 original relations will be one (|) and one (|) STEP 3: DEFINING INFORMATION FOR EACH RELATIONTo ensure that each field is in the right relation, ask the following question:“Does this piece of information depend only on the primary key for this relation?”Yes – it’s in the correct relationNo – It’s in the wrong relation STEP 3: DEFINING INFORMATION FOR EACH RELATIONSee Figure C.6 on page 381Look at Raw Material relationEvery field must depend only on Raw Material IDRaw Material Name, QOH, and Supplier ID doSupplier Name does not STEP 3: DEFINING INFORMATION FOR EACH RELATIONWhat does Supplier Name depend on?It depends on Supplier IDSupplier ID is primary key for Supplier relationTherefore, Supplier Name belongs only in Supplier relation STEP 3: DEFINING INFORMATION FOR EACH RELATIONSee Figure C.6 on page 381Do you see any derived information?Counts?Sums?Averages?If you see them, remove them STEP 3: DEFINING INFORMATION FOR EACH RELATIONRaw Material Total in the Concrete Type relation is derivedIt can be obtained by summing the appropriate fields of the appropriate records in the Bill of Material relationTherefore, you do not need Raw Material TotalTake it out STEP 3: DEFINING INFORMATION FOR EACH RELATIONSee Figure C.7 on page 382It is the correct and final structureNo many-to-many relationshipsEach field depends only on relation’s primary keyNo derived fieldsGood database design STEP 4: USE A DATA DEFINITION LANGUAGE TO CREATE YOUR DATABASEYou’re ready to implement Solomon’s database with a DBMSDatabase management system (DBMS) – helps you specify the logical organization for a database and access and use the information within the database