9780538469685_PPT_ch03

download 9780538469685_PPT_ch03

of 52

Transcript of 9780538469685_PPT_ch03

  • Database Systems: Design, Implementation, and ManagementNinth EditionChapter 3The Relational Database Model

  • Database Systems, 9th Edition*ObjectivesIn this chapter, students will learn:That the relational database model offers a logical view of dataAbout the relational models basic component: relationsThat relations are logical constructs composed of rows (tuples) and columns (attributes)That relations are implemented as tables in a relational DBMS

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Objectives (contd.)About relational database operators, the data dictionary, and the system catalogHow data redundancy is handled in the relational database modelWhy indexing is important

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*A Logical View of DataRelational model View data logically rather than physicallyTable Structural and data independenceResembles a file conceptuallyRelational database model is easier to understand than hierarchical and network models

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Tables and Their CharacteristicsLogical view of relational database is based on relationRelation thought of as a tableTable: two-dimensional structure composed of rows and columnsPersistent representation of logical relationContains group of related entities (entity set)

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*KeysEach row in a table must be uniquely identifiableKey is one or more attributes that determine other attributesKeys role is based on determinationIf you know the value of attribute A, you can determine the value of attribute BFunctional dependenceAttribute B is functionally dependent on A if all rows in table that agree in value for A also agree in value for B

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Keys (contd.)Composite keyComposed of more than one attributeKey attributeAny attribute that is part of a keySuperkeyAny key that uniquely identifies each rowCandidate key A superkey without unnecessary attributes

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Keys (contd.)NullsNo data entryNot permitted in primary keyShould be avoided in other attributesCan represent:An unknown attribute valueA known, but missing, attribute valueA not applicable condition

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Keys (contd.)Nulls (contd.)Can create problems when functions such as COUNT, AVERAGE, and SUM are usedCan create logical problems when relational tables are linked

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Keys (contd.)Controlled redundancyMakes the relational database workTables within the database share common attributes Enables tables to be linked togetherMultiple occurrences of values not redundant when required to make the relationship workRedundancy exists only when there is unnecessary duplication of attribute values

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Keys (contd.)Foreign key (FK) An attribute whose values match primary key values in the related tableReferential integrity FK contains a value that refers to an existing valid tuple (row) in another relationSecondary key Key used strictly for data retrieval purposes

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Integrity RulesMany RDBMs enforce integrity rules automaticallySafer to ensure that application design conforms to entity and referential integrity rules Designers use flags to avoid nullsFlags indicate absence of some value

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Relational Set OperatorsRelational algebra Defines theoretical way of manipulating table contents using relational operatorsUse of relational algebra operators on existing relations produces new relations:

    SELECT DIFFERENCE PROJECT JOIN UNION PRODUCT INTERSECT DIVIDE

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Relational Set Operators (contd.)Natural JoinLinks tables by selecting rows with common values in common attribute(s)EquijoinLinks tables on the basis of an equality condition that compares specified columnsTheta joinAny other comparison operator is usedOuter joinMatched pairs are retained, and any unmatched values in other table are left null

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*The Data Dictionary and System CatalogData dictionary Provides detailed accounting of all tables found within the user/designer-created databaseContains (at least) all the attribute names and characteristics for each table in the systemContains metadata: data about dataSystem catalogContains metadataDetailed system data dictionary that describes all objects within the database

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Relationships within the Relational Database1:M relationship Relational modeling idealShould be the norm in any relational database design1:1 relationshipShould be rare in any relational database design

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Relationships within the Relational Database (contd.)M:N relationships Cannot be implemented as such in the relational modelM:N relationships can be changed into 1:M relationships

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*The 1:M RelationshipRelational database normFound in any database environment

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*The 1:1 RelationshipOne entity related to only one other entity, and vice versaSometimes means that entity components were not defined properlyCould indicate that two entities actually belong in the same tableCertain conditions absolutely require their use

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*The M:N RelationshipImplemented by breaking it up to produce a set of 1:M relationshipsAvoid problems inherent to M:N relationship by creating a composite entityIncludes as foreign keys the primary keys of tables to be linked

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Data Redundancy RevisitedData redundancy leads to data anomaliesCan destroy the effectiveness of the databaseForeign keysControl data redundancies by using common attributes shared by tablesCrucial to exercising data redundancy controlSometimes, data redundancy is necessary

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*IndexesOrderly arrangement to logically access rows in a tableIndex key Indexs reference pointPoints to data location identified by the keyUnique indexIndex in which the index key can have only one pointer value (row) associated with itEach index is associated with only one table

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*Codds Relational Database RulesIn 1985, Codd published a list of 12 rules to define a relational database systemProducts marketed as relational that did not meet minimum relational standardsEven dominant database vendors do not fully support all 12 rules

    Database Systems, 9th Edition

  • Database Systems, 9th Edition*SummaryTables are basic building blocks of a relational databaseKeys are central to the use of relational tablesKeys define functional dependenciesSuperkeyCandidate keyPrimary keySecondary keyForeign key

    Database Systems, 9th Edition

  • Summary (contd.)Each table row must have a primary key that uniquely identifies all attributes Tables are linked by common attributesThe relational model supports relational algebra functionsSELECT, PROJECT, JOIN, INTERSECT UNION, DIFFERENCE, PRODUCT, DIVIDEGood design begins by identifying entities, attributes, and relationships1:1, 1:M, M:NDatabase Systems, 9th Edition*

    Database Systems, 9th Edition

    *