chapter 3 the relational database model. logical view of data relational database – designer...
TRANSCRIPT
![Page 1: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/1.jpg)
Chapter 3The Relational Database Model
![Page 2: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/2.jpg)
Logical View of DataLogical View of Data
Relational Database – Designer focuses on logical representation
rather than physical– Use of table advantageous
Structural and data independenceRelated records stored in independent tablesLogical simplicity
![Page 3: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/3.jpg)
A Logical View of DataA Logical View of DataA Logical View of DataA Logical View of Data Relational database model’s structural and data
independence
– allow us to ignore the structure’s physical complexity.
– enables us to view data logically rather than physically.
The logical view allows a simpler file concept of data storage.
The use of logically independent tables is easier to understand.
Logical simplicity yields simpler and more effective database design methodologies.
![Page 4: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/4.jpg)
A Logical View of DataA Logical View of Data Entities and Attributes
– An entity is a person, place, event, or thing for which we intend to collect data.
University -- Students, Faculty Members, Courses
– Each entity has certain characteristics known as attributes.
Student -- Student Number, Name, GPA, Date of Enrollment, Data of Birth, Home Address, Phone Number, Major
– A grouping of related entities becomes an entity set.
The STUDENT entity set contains all student entities.
The FACULTY entity set contains all faculty entities.
![Page 5: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/5.jpg)
Table CharacteristicsTable Characteristics• Two-dimensional structure with rows and columns• Row (tuple) represent a single entity occurrence within the
entity set.• Columns represent attributes• Row/column intersection represents single value• Column values all have same data format• Each column has range of values called attribute domain
• Order of the rows and columns is immaterial to the DBMS
• Tables must have an attribute to uniquely identify each row
![Page 6: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/6.jpg)
A Logical View of DataA Logical View of DataA Logical View of DataA Logical View of Data
Tables and Their Characteristics
– A table contains a group of related entities -- i.e. an entity set.
– The terms entity set and table are often used interchangeably.
– A table is also called a relation.
entity set ≒ table ≒ relation
![Page 7: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/7.jpg)
![Page 8: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/8.jpg)
![Page 9: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/9.jpg)
KeysKeys
– A key Consists of one or more attributes that determine other attributes
– Primary key (PK) is an attribute (or a combination
of attributes) that uniquely identifies any given entity (row)
![Page 10: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/10.jpg)
KeysKeys– The key’s role is based on a concept known as
determination, which is used in the definition of functional dependence.
The attribute B is functionally dependent on A if A determines B. ( A → B )
An attribute that is part of a key is known as a key attribute.
A multi-attribute key is known as a composite key.
If the attribute (B) is functionally dependent on a composite key (A) but not on any subset of that composite key, the attribute (B) is fully functionally dependent on (A). (A is minimal !)
![Page 11: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/11.jpg)
STU_HRS → STU_CLASS
Freshman
Sophomore
Junior
Senior
![Page 12: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/12.jpg)
Keys Keys
Superkey– Uniquely identifies each entity
Candidate key– Minimal superkey
Primary key– Candidate key selected to uniquely identify all other
attributes in a given row
Secondary key– Used only for data retrieval
Foreign key– Values must match primary key in another table
![Page 13: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/13.jpg)
Super key– STU_NUM– (STU_NUM, STU_LNAME)
Candidate key– STU_NUM– (STU_LNAME, STU_FNAME, STU_INIT, STU_PHONE)
Primary key– STU_NUM
Secondary keynot necessarily yield a unique outcome– CUSTOMER table:
Primary key : Customer number Secondary key : Customer last name, Customer phone number
– A secondary key’s effectiveness in narrowing down a search depends on how restrictive it is.
![Page 14: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/14.jpg)
Null ValuesNull Values
No data entry Not permitted in primary key Should be avoided in other attributes Can represent
– An unknown attribute value
– A known, but missing, attribute value
– A “not applicable” condition
Can create problems in logic and using formulas (COUNT, AVERAGE, and SUM)
![Page 15: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/15.jpg)
KeysKeysKeysKeys
Controlled redundancy (shared common attributes) makes the relational database work.
The primary key of one table appears again as the link (foreign key) in another table.
– VEND_CODE in PRODUCT table (Figure 3.2)
referential integrity :if the foreign key contains a value, that value refers to an existing valid tuple in another relation.
![Page 16: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/16.jpg)
![Page 17: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/17.jpg)
![Page 18: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/18.jpg)
![Page 19: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/19.jpg)
![Page 20: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/20.jpg)
Integrity RulesIntegrity RulesEntity integrity
– (unique and no null) All Primary key entries are unique , and no part of a Primary key may be null .
CUS_CODE AGENT_CODE
Referential integrity– (null or matching)
A Foreign key may have either a null entry or an entry that matches the primary key value in a tableto which it is related.
AGENT_CODE
![Page 21: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/21.jpg)
null or matching
![Page 22: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/22.jpg)
Relational Database OperatorsRelational Database OperatorsRelational Database OperatorsRelational Database Operators Relational algebra defines the theoretical way of
manipulating table contents using the eight relational functions: – SELECT– PROJECT– JOIN– INTERSECT– UNION– DIFFERENCE– PRODUCT– DIVIDE
Use of relational algebra operators on existing tables (relations) produces new relations
![Page 23: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/23.jpg)
Relational Database OperatorsRelational Database OperatorsRelational Database OperatorsRelational Database Operators UNION combines all rows from two tables. The two
tables must be union compatible.(share the same columns and domains)
![Page 24: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/24.jpg)
INTERSECT produces a listing that contains only the rows that appear in both tables. The two tables must be union compatible.
![Page 25: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/25.jpg)
DIFFERENCE yields all rows in one table that are not found in the other table; i.e., it subtracts one table from the other. The tables must be union compatible.
![Page 26: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/26.jpg)
PRODUCT produces a list of all possible pairs of rows from two tables. (Cartesian product)
![Page 27: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/27.jpg)
SELECT yields values for all rows found in a table. It yields a horizontal subset of a table.
Figure 2.9
![Page 28: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/28.jpg)
PROJECT produces a list of all values for selected attributes. It yields a vertical subset of a table.
![Page 29: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/29.jpg)
JOIN allows us to combine information from two or more tables. JOIN is the real power behind the relational database, allowing the use of independent tables linked by common attributes.
![Page 30: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/30.jpg)
Relational Database OperatorsRelational Database Operators• Natural JOIN links tables by selecting only the
rows with common values in their common attribute(s). It is the result of a 3-stage process:
1. A PRODUCT of the tables is created. (Figure 3.12)
2. A SELECT is performed on the output of the first step to yield only the rows for which the common attribute values match. (Figure 3.13)Common column(s) are called join column(s)
3. A PROJECT is performed to yield a single copy of each attribute, thereby eliminating the duplicate column. (Figure 3.14)
![Page 31: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/31.jpg)
![Page 32: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/32.jpg)
![Page 33: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/33.jpg)
Relational Database OperatorsRelational Database OperatorsRelational Database OperatorsRelational Database Operators– Data warehouse
links tables based on an equality condition that compares specified columns of each table. The outcome of the EquiJOIN does not eliminate duplicate columns and the condition or criteria to join the tables must be explicitly defined.
– Theta JOIN is an equiJOIN that compares specified columns of each table using a comparison operator other than the equality(=) comparison operator.
– In an Outer JOIN, the unmatched pairs would be retained and the values for the unmatched other tables would be left null.
![Page 34: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/34.jpg)
equiJOIN criteria(C=E)
A B C
1 X 10
2 X 2020
3 y 10
D E
m 10
n 2020
p 40
A B C D E
1 x 10 m 10
3 y 10 m 10
2 x 2020 n 2020
![Page 35: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/35.jpg)
theta JOIN criteria(C<E)
A B C
1 X 10
2 X 2020
3 y 10
D E
m 10
n 2020
p 40
A B C D E
1 x 10 n 2020
1 x 10 p 40
2 x 2020 p 40
3 y 10 n 2020
3 y 10 p 40
![Page 36: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/36.jpg)
CUSTOMER Full Outer JOINCUSTOMER.AGENT_CODE=AGENT.AGENT_CODE AGENT
![Page 37: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/37.jpg)
CUSTOMER Left Outer JOINCUSTOMER.AGENT_CODE=AGENT.AGENT_CODE AGENT
![Page 38: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/38.jpg)
CUSTOMER Right Outer JOINCUSTOMER.AGENT_CODE=AGENT.AGENT_CODE AGENT
![Page 39: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/39.jpg)
DIVIDE requires the use of one single-column table and one two-column table.
![Page 40: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/40.jpg)
This is not an uncommon situation, but the solution is not straightforward since the SQL SELECT statement does not directly support relational division.
There are numerous ways to achieve the same results as a relational division, however. The easiest method is to rephrase the request. Instead of "list the suppliers who provide all product categories,“ which is difficult to process, try "list all suppliers where the count of their product categories is equal to the count of all product categories."
![Page 41: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/41.jpg)
The Data Dictionary and The Data Dictionary and the System Catalogthe System Catalog
Data dictionary contains metadata to provide detailed accounting of all tables within the database.
System catalog is a very detailed system data dictionary that describes all objects within the database.
– Authorized users, access privileges …
– System catalog is a system-created database whose tables store the database characteristics and contents.
Terms “system catalog” and “data dictionary” are often used interchangeably
![Page 42: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/42.jpg)
![Page 43: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/43.jpg)
Relationships within the Relationships within the Relational DatabaseRelational Database
E-R Diagram (ERD)
– Rectangles are used to represent entities.
– Entity names are nouns and capitalized.
– Diamonds are used to represent the relationship(s) between the entities.
– “1” side of relationship Number 1 in Chen Model
Bar crossing line in Crow’s Feet Model
– “Many” relationships Letter “M” and “N” in Chen Model
Three pronged “Crow’s foot” in Crow’s Feet Model
![Page 44: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/44.jpg)
The The 1:11:1 Relationship Relationship One entity can be related to only one other
entity, and vice versa
Often means that entity components were not defined properly
Could indicate that two entities actually belong in the same table
Sometimes 1:1 relationships are appropriate
![Page 45: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/45.jpg)
The 1:1 Relationship Between The 1:1 Relationship Between PROFESSOR and DEPARTMENTPROFESSOR and DEPARTMENT
![Page 46: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/46.jpg)
The Implemented 1:1 Relationship Between The Implemented 1:1 Relationship Between PROFESSOR and DEPARTMENTPROFESSOR and DEPARTMENT
![Page 47: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/47.jpg)
The 1:M Relationship The 1:M Relationship Between PAINTER and PAINTINGBetween PAINTER and PAINTING
![Page 48: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/48.jpg)
Example 1:M RelationshipExample 1:M Relationship
![Page 49: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/49.jpg)
The Implemented 1:M Relationship The Implemented 1:M Relationship Between PAINTER and PAINTINGBetween PAINTER and PAINTING
PAINTER (PAINTER_NUM)
PAINTING (PAINTING_NUM) (PAINTER_NUM)
![Page 50: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/50.jpg)
The 1:M Relationship The 1:M Relationship Between COURSE and CLASSBetween COURSE and CLASS
![Page 51: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/51.jpg)
The Implemented 1:M RelationshipThe Implemented 1:M RelationshipBetween COURSE and CLASSBetween COURSE and CLASS
COURSE (CRS_CODE)
CLASS (CLASS_CODE) (CRS_CODE)
![Page 52: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/52.jpg)
The The M:N M:N RelationshipRelationship
Can be implemented by breaking it up to produce a set of 1:M relationships
Can avoid problems inherent to M:N relationship by creating a composite entity or bridge entity
![Page 53: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/53.jpg)
The ERD’s M:N Relationship The ERD’s M:N Relationship Between STUDENT and CLASSBetween STUDENT and CLASS
![Page 54: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/54.jpg)
Sample Student Enrollment DataSample Student Enrollment Data
![Page 55: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/55.jpg)
The M:N Relationship The M:N Relationship Between STUDENT and CLASSBetween STUDENT and CLASS
321452
10014
![Page 56: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/56.jpg)
Composite EntityComposite Entity The tables (Figure 3.25) creates many
redundancies.
Composite Entity ( Bridge Entity)– Links the tables originally were related in a M:N relationship– Includes at least the primary keys of the tables that are to
be linked.
– In ERD,represented by a diamond within a rectangle
![Page 57: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/57.jpg)
Converting the M:N Relationship Converting the M:N Relationship into Two 1:M Relationshipsinto Two 1:M Relationships
ENROLL (CLASS_CODE+STU_NUM) (CLASS_CODE,STU_NUM)
STUDENT (STU_NUM)
CLASS (CLASS_CODE) (CRS_CODE)
![Page 58: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/58.jpg)
Changing the M:N Relationship Changing the M:N Relationship to Two 1:M Relationshipsto Two 1:M Relationships
![Page 59: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/59.jpg)
The Expanded Entity Relationship ModelThe Expanded Entity Relationship Model
![Page 60: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/60.jpg)
The Relational Schema for the The Relational Schema for the Ch03_TinyCollege DatabaseCh03_TinyCollege Database
![Page 61: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/61.jpg)
Data Redundancy RevisitedData Redundancy Revisited
Data redundancy leads to data anomalies
– Such anomalies can destroy database effectiveness
Foreign keys
– Control data redundancies by using common attributes shared by tables
– Foreign keys can reduce redundancy
Sometimes, data redundancy is necessary
![Page 62: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/62.jpg)
Changing the M:N Relationship Changing the M:N Relationship to Two 1:M Relationshipsto Two 1:M Relationships
INVOICE
INVOICE
PRODUCT
PRODUCTLINE
![Page 63: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/63.jpg)
A Small Invoicing System
CUSTOMER (CUS_CODE)
INVOICE (INV_NUM) (CUS_CODE)
LINE (INV_NUM+LINE_NUM) (INV_NUM, PROD_CODE)
PRODUCT (PROD_CODE)
![Page 64: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/64.jpg)
The Relational SchemaThe Relational Schemafor the Invoicing Systemfor the Invoicing System
![Page 65: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/65.jpg)
Why Data Redundancies ?Why Data Redundancies ?
Sometimes, data redundancy is necessary Product price (LINE_PRICE in LINE table) :
Data redundancies !Data redundancies ! The redundancy is crucial to the system’s success.
Copying the product price from PRODUCT table to the LINE table means that it is possible to maintain the historical accuracy of the transactions. Product price may change.
![Page 66: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/66.jpg)
IndexesIndexesIndexesIndexes An index is an orderly arrangement used to logically
access rows in a table of keys and pointers.
An index is composed of – an index key (the index’s reference point) (PAINTER_NUM)
– a set of pointers.
Each pointer points to the location of the data identified by the key.
Makes retrieval of data faster
Each index is associated with only one table
![Page 67: Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –](https://reader030.vdocuments.site/reader030/viewer/2022013119/56649f485503460f94c69f48/html5/thumbnails/67.jpg)
IndexesIndexesIndexesIndexes