100 likes | 218 Views
Relationships. ER Diagrams, Data Structure Diagrams and Relationship Types using the Footy Tips Database. Reviewing Our Data. We have our data in 3NF – but this can be done in 2NF How do these tables relate to each other?. tblTipsters tblTips tblFixtures. Entity Relationship (ER) Diagrams .
E N D
Relationships ER Diagrams, Data Structure Diagrams and Relationship Types using the Footy Tips Database
Reviewing Our Data • We have our data in 3NF – but this can be done in 2NF • How do these tables relate to each other? tblTipsters tblTips tblFixtures
Entity Relationship (ER) Diagrams • Entities are Database Objects such as tables and reports • We have 3 tables at the moment tblTipsters tblFixtures tblTips
ER Diagram: Attributes • These tables have attributes… (fields in this case!) Round TipsterID Match Firstname tblTipsters tblFixtures Home Away Lastname tblTips Result TipsterID Match Pick
ER Diagrams: Relationships • These tables are related to eachother… TipsterID Round Firstname Match Are used for… tblTipsters tblFixtures Home Away Lastname Makes A… tblTips Result TipsterID Match Pick
ER Diagram Complete • Here is out completed ER Diagram TipsterID Round Firstname Match Are used for… tblTipsters tblFixtures Home Away Lastname Makes A… tblTips Result TipsterID Match Pick
Data Structure Diagram • Now that we can see how the data is related, we can work on our structure • First we need to have the tables in 3NF We just want the table structures from here tblTipsters tblTips tblFixtures
Creating the Relationships • How we find the fields that match between tables… • First, the Tipsters and Tips are related by what? • Answer: TipsterID! • Second, the Fixtures and Tips are related by what? • Answer: Match! tblTipsterstblTipstblFixtures
Relationship Types • We have created our relationships, but what types of relationships have we created? • Question: How many times will a TipsterID be in tblTipsters? • Answer: Once… • Question: How many times will a TipsterID be in tblTips? • Answer: Many… • Question: How many times will a Match by in tblFixtures? • Answer: Once… • Question: How many times will a Match by in tblTips? • Answer: Many… tblTipsterstblTipstblFixtures 1 1 ∞ ∞
Completed Relationship Types • Here we have our final Data Structure Diagram • The tblTipsters – tblTips relationship is One to Many • The tblFixtures – tblTips relationship is One to Many tblTipsterstblTipstblFixtures 1 1 ∞ ∞