DOC PREVIEW
UMD CMSC 424 - Database Design

This preview shows page 1-2-3-4-27-28-29-30-56-57-58-59 out of 59 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC424: Database DesignTodayDatabase Design StepsMotivationER Diagram: Starting ExampleMapping CardinalitiesSlide 7Slide 8Next: Types of AttributesTypes of AttributesSlide 11Slide 12Next: KeysEntity KeysSlide 15Slide 16Relationship Set KeysSlide 18Slide 19Slide 20Slide 21Slide 22…Next: Recursive RelationshipsRecursive RelationshipsNext: Weak Entity SetsWeak Entity SetsSlide 28Slide 29Slide 30More…Example DesignPowerPoint PresentationSlide 34Slide 35Slide 36Slide 37Thoughts…Slide 39Design IssuesSummarySlide 42Relational Data ModelKey Abstraction: RelationWhy Called Relations?RelationsSlide 47DefinitionsSo…Extra slides…Next: Data ConstraintsParticipation ConstraintSlide 53Cardinality ConstraintsNext: SpecializationFinally: AggregationSlide 57Slide 58Next: Relationship CardinalitiesCMSC424: Database DesignInstructor: Amol Deshpande [email protected]E/R Modeling continued…Example of an E/R ModelRelational Model3 Database Design StepsThree Levels of ModelinginfoConceptual Data ModelLogical Data ModelPhysical Data Model Conceptual DB design Logical DB design Physical DB designEntity-relationship Model Typically used for conceptual database designRelational Model Typically used for logical database designMotivationYou’ve just been hired by Bank of America as their DBA for their online banking web site.You are asked to create a database that monitors:customersaccountsloansbranchestransactions, …Now what??!!!5ER Diagram: Starting ExampleRectangles: entity setsDiamonds: relationship setsEllipses: attributescustomerhascust-streetcust-idcust-namecust-cityaccountbalancenumberaccess-dateMapping CardinalitiesExpress the number of entities to which another entity can be associated via a relationship setMost useful in describing binary relationship setsMapping CardinalitiesOne-to-OneOne-to-ManyMany-to-OneMany-to-ManycustomerhasaccountcustomerhasaccountcustomerhasaccountcustomerhasaccountMapping CardinalitiesExpress the number of entities to which another entity can be associated via a relationship setMost useful in describing binary relationship setsN-ary relationships ?More complicatedDetails in the bookNext: Types of AttributesSimple vs CompositeSingle value per attribute ?Single-valued vs Multi-valuedE.g. Phone numbers are multi-valuedDerivedIf date-of-birth is present, age can be derivedCan help in avoiding redundancy, enforcing constraints etc…Types of Attributescustomerhascust-streetcust-idcust-namecust-cityaccountbalancenumberaccess-dateTypes of Attributescustomercust-streetcust-idcust-namecust-cityhasaccountbalancenumberaccess-datephone no.date-of-birthagemulti-valued (double ellipse)derived (dashed ellipse)Types of Attributescustomercust-streetcust-idcust-namecust-cityhasaccountbalancenumberaccess-datephone no.date-of-birthagemonthday yearComposite AttributeNext: KeysKey = set of attributes that uniquely identifies an entity or a relationshipcustomercust-streetcust-idcust-namecust-cityphone no.agedate-of-birthPossible Keys: {cust-id} {cust-name, cust-city, cust-street} {cust-id, age} cust-name ?? Probably not.Domain knowledge dependent !!Entity KeysEntity KeysSuperkeyany attribute set that can distinguish entitiesCandidate keya minimal superkeyCan’t remove any attribute and preserve key-ness{cust-id, age} not a candidate key {cust-name, cust-city, cust-street} is assuming cust-name is not uniquePrimary keyCandidate key chosen as the key by DBAUnderlined in the ER DiagramEntity Keys{cust-id} is a natural primary keyTypically, SSN forms a good primary keyTry to use a candidate key that rarely changese.g. something involving address not a great ideacustomercust-streetcust-idcust-namecust-cityphone no.agedate-of-birthRelationship Set KeysWhat attributes are needed to represent a relationship completely and uniquely ?Union of primary keys of the entities involved, and relationship attributes{cust-id, access-date, account number} describes a relationship completelycustomerhascust-idaccountnumberaccess-dateRelationship Set KeysIs {cust-id, access-date, account number} a candidate key ?No. Attribute access-date can be removed from this set without losing key-nessIn fact, union of primary keys of associated entities is always a superkeycustomerhascust-idaccountnumberaccess-dateRelationship Set KeysIs {cust-id, account-number} a candidate key ?Dependscustomerhascust-idaccountnumberaccess-dateRelationship Set KeysIs {cust-id, account-number} a candidate key ?Dependscustomerhascust-idaccountnumberaccess-dateIf one-to-one relationship, either {cust-id} or {account-number} sufficientSince a given customer can only have one account, she can only participate in one relationshipDitto accountRelationship Set KeysIs {cust-id, account-number} a candidate key ?Dependscustomerhascust-idaccountnumberaccess-dateIf one-to-many relationship (as shown), {account-number} is a candidate keyA given customer can have many accounts, but at most one account holder per account allowedRelationship Set KeysGeneral rule for binary relationshipsone-to-one: primary key of either entity setone-to-many: primary key of the entity set on the many sidemany-to-many: union of primary keys of the associate entity setsn-ary relationshipsMore complicated rules…What have we been doingWhy ?Understanding this is importantRest are details !!That’s what books/manuals are for.Next: Recursive RelationshipsSometimes a relationship associates an entity set to itselfRecursive Relationships Must be declared with rolesemployeeworks-foremp-streetemp-idemp-nameemp-citymanagerworkerNext: Weak Entity SetsAn entity set without enough attributes to have a primary keyE.g. Transaction EntityAttributes:transaction-number, transaction-date, transaction-amount, transaction-typetransaction-number: may not be unique across accountsWeak Entity SetsA weak entity set must be associated with an identifying or owner entity setAccount is the owner entity set for TransactionWeak Entity SetsaccountbalancenumberTransactionhastrans-typetrans-numbertrans-datetrans-amt Still need to be able to distinguish between different weak entities associated with the same strong entityWeak Entity


View Full Document

UMD CMSC 424 - Database Design

Documents in this Course
Lecture 2

Lecture 2

36 pages

Databases

Databases

44 pages

Load more
Download Database Design
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Database Design and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Database Design 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?