PowerPoint PresentationChapter 3 OutlineThe Relational Data Model and Relational Database ConstraintsRelational Model ConceptsRelational Model Concepts (cont’d.)Domains, Attributes, Tuples, and RelationsDomains, Attributes, Tuples, and Relations (cont’d.)Slide 8Characteristics of RelationsCharacteristics of Relations (cont’d.)Slide 11Slide 12Slide 13Relational Model NotationSlide 15Slide 16Relational Model ConstraintsRelational Model Constraints (cont’d.)Domain ConstraintsKey Constraints and Constraints on NULL ValuesKey Constraints and Constraints on NULL Values (cont’d.)Slide 22Slide 23Relational Databases and Relational Database SchemasRelational Databases and Relational Database Schemas (cont’d.)Integrity, Referential Integrity, and Foreign KeysIntegrity, Referential Integrity, and Foreign Keys (cont’d.)Slide 28Update Operations, Transactions, and Dealing with Constraint ViolationsSlide 30Slide 31Slide 32The Insert OperationThe Delete OperationThe Update OperationSummaryCopyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-WesleyChapter 3The Relational Data Model and Relational Database ConstraintsCopyright © 2011 Ramez Elmasri and Shamkant NavatheChapter 3 OutlineThe Relational Data Model andRelational Database ConstraintsRelational Model Constraintsand Relational Database SchemasUpdate Operations, Transactions,and Dealing with Constraint ViolationsCopyright © 2011 Ramez Elmasri and Shamkant NavatheThe Relational Data Model andRelational Database ConstraintsRelational modelFirst commercial implementations available in early 1980sHas been implemented in a large number of commercial systemHierarchical and network modelsPreceded the relational modelCopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model ConceptsRepresents data as a collection of relationsTable of valuesRow •Represents a collection of related data values•Fact that typically corresponds to a real-world entity or relationship•TupleTable name and column names •Interpret the meaning of the values in each row attributeCopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model Concepts (cont’d.)Copyright © 2011 Ramez Elmasri and Shamkant NavatheDomains, Attributes, Tuples, and RelationsDomain D Set of atomic valuesAtomicEach value indivisibleSpecifying a domain Data type specified for each domainCopyright © 2011 Ramez Elmasri and Shamkant NavatheDomains, Attributes, Tuples, and Relations (cont’d.)Relation schema RDenoted by R(A1, A2, ...,An)Made up of a relation name R and a list of attributes, A1, A2, ..., AnAttribute Ai Name of a role played by some domain D in the relation schema RDegree (or arity) of a relation Number of attributes n of its relation schemaCopyright © 2011 Ramez Elmasri and Shamkant NavatheDomains, Attributes, Tuples, and Relations (cont’d.)Relation (or relation state) Set of n-tuples r = {t1, t2, ..., tm}Each n-tuple t •Ordered list of n values t =<v1, v2, ..., vn>•Each value vi, 1 ≤ i ≤ n, is an element of dom(Ai) or is a special NULL valueCopyright © 2011 Ramez Elmasri and Shamkant NavatheCharacteristics of RelationsOrdering of tuples in a relationRelation defined as a set of tuplesElements have no order among themOrdering of values within a tuple and an alternative definition of a relationOrder of attributes and values is not that important As long as correspondence between attributes and values maintainedCopyright © 2011 Ramez Elmasri and Shamkant NavatheCharacteristics of Relations (cont’d.)Alternative definition of a relation Tuple considered as a set of (<attribute>, <value>) pairsEach pair gives the value of the mapping from an attribute Ai to a value vi from dom(Ai)Use the first definition of relationAttributes and the values within tuples are orderedSimpler notationCopyright © 2011 Ramez Elmasri and Shamkant NavatheCharacteristics of Relations (cont’d.)Copyright © 2011 Ramez Elmasri and Shamkant NavatheCharacteristics of Relations (cont’d.)Values and NULLs in tuplesEach value in a tuple is atomicFlat relational model•Composite and multivalued attributes not allowed •First normal form assumptionMultivalued attributes •Must be represented by separate relationsCopyright © 2011 Ramez Elmasri and Shamkant NavatheCharacteristics of Relations (cont’d.)NULL valuesRepresent the values of attributes that may be unknown or may not apply to a tupleMeanings for NULL values•Value unknown•Value exists but is not available•Attribute does not apply to this tuple (also known as value undefined)Copyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model NotationRelation schema R of degree n Denoted by R(A1, A2, ..., An)Uppercase letters Q, R, S Denote relation namesLowercase letters q, r, s Denote relation statesLetters t, u, v Denote tuplesCopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model NotationName of a relation schema: STUDENTIndicates the current set of tuples in that relationNotation: STUDENT(Name, Ssn, ...) Refers only to relation schemaAttribute A can be qualified with the relation name R to which it belongs Using the dot notation R.ACopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model Notationn-tuple t in a relation r(R) Denoted by t = <v1, v2, ..., vn>vi is the value corresponding to attribute AiComponent values of tuples:t[Ai] and t.Ai refer to the value vi in t for attribute Ait[Au, Aw, ..., Az] and t.(Au, Aw, ..., Az) refer to the subtuple of values <vu, vw, ..., vz> from t corresponding to the attributes specified in the listCopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model ConstraintsConstraintsRestrictions on the actual values in a database stateDerived from the rules in the miniworld that the database representsInherent model-based constraints or implicit constraintsInherent in the data modelCopyright © 2011 Ramez Elmasri and Shamkant NavatheRelational Model Constraints (cont’d.)Schema-based constraints or explicit constraintsCan be directly expressed in schemas of the data modelApplication-based or semantic constraints or business rulesCannot be directly expressed in schemasExpressed and enforced by application programCopyright © 2011 Ramez Elmasri and Shamkant NavatheDomain
View Full Document