3.5 Databases Relationships.

Slides:



Advertisements
Similar presentations
The Relational Model J.G. Zheng May 15 th Introduction Edgar F. Codd, 1970 One sentence to explain relational database model: Data are organized.
Advertisements

Data Design The futureERD - CardinalityCODINGRelationshipsDefinition.
GCSE Computing#BristolMet Session Objectives# 21 MUST describe methods of validating data as it is input. SHOULD explain the use of key fields to connect.
12 CHAPTER DATABASES Databases are the key to accessing information throughout our lives. Used in hospitals, grocery stores, schools, department stores,
Access A Relational Database Management System. Prof. Leighton2 Database ► A database is a collection of data that’s related to a particular topic ► A.
Introduction to Databases CIS 5.2. Where would you find info about yourself stored in a computer? College Physician’s office Library Grocery Store Dentist’s.
Database Design Chapter 3.
Database – Part 2a Dr. V.T. Raja Oregon State University.
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Entity Relationships. Relationships Relationships exist between entities The type of relationship is entirely dependent on the business rules The business.
N. J. Taylor Database Management Systems (DBMS) 1.
DATA MODELLING TOOLS FOR ORGANISING DATABASES. For a database to be organised and logical, it must be well-designed and set out. In such cases, the databases.
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
1 Advanced Computer Programming Databases. Overview What is a database? Database Basics Database Components Data Models Normalization Database Design.
Concepts and Terminology Introduction to Database.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
CORE 2: Information systems and Databases NORMALISING DATABASES.
Data Modelling. ICT5 Introduction Historical development with most organisations Small-scale origins Individual computers bought for particular applications.
Session 8: Databases Teaching Computing to GCSE Level with Python.
Btec National - Advanced Databases 1 Advanced Databases Entity Relationship Diagrams.
Relational Databases. Relational database  data stored in tables  must put data into the correct tables  define relationship between tables  primary.
Quiz questions. 1 A data structure that is made up of fields and records? Table.
Lesson 2: Designing a Database and Creating Tables.
Instructor: Pavlos Pavlikas1 How Data is Stored Chapter 8.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Tutorial 2 Data Modelling. 3 Terminology & Notation(1) An entity is an object about which the system needs to hold information –Customer, Student, Course.
Btec National - IT SYSTEMS ANALYSIS AND DESIGN 1 IT Systems Analysis and Design Entity Relationship Diagrams.
Consolidation Objectives of the Lecture : To review a given design of a relational database. To amplify the design by adding Integrity Constraints. To.
1 Microsoft Access 2002 Tutorial 2 – Creating And Maintaining A Database.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Year 12 > 13 Applied GCE ICT Unit 7 Using Database Software.
Database Design Chapters 17 and 18.
IGCSE 4 Cambridge Designing a database table Computer Science
Creating a database table
Chapter 5 UNDERSTANDING AND DESIGNING ACCOUNTING DATA
Databases Chapter 9 Asfia Rahman.
3.5 Databases Relationships.
Databases Chapter 16.
Information Systems Today: Managing in the Digital World
Relational Databases.
Database Management Systems (DBMS)
CSCI-100 Introduction to Computing
Chapter 4 Relational Databases
Database Design and Development
Database Management  .
Databases A brief introduction….
Databases and Information Management
Entity-Relationship Model and Diagrams (continued)
Entity Relationships and Normalization
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Order Database – ER Diagram
Normalization Referential Integrity
Database Fundamentals
Database Management Concepts
Databases and Information Management
Database Design and Development
Computer Science Projects Database Theory / Prototypes
Database Design and Development
Lingma Acheson Department of Computer and Information Science IUPUI
logical design for relational database
Databases 1.
Conceptual modeling of databases
DATABASE Purpose of database
MIS2502: Data Analytics Relational Data Modeling 3
Use of SQL – The Patricia database
G061 - Data Dictionary.
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

3.5 Databases Relationships

3.5 Databases 3.5.1 Understand the characteristics of structured and unstructured data 3.5.2 Understand that data can be decomposed and organised in a structured database [tables, records, fields, relationships, keys] 3.5.3 Understand the need for and be able to use SQL statements

What is an entity?

An entity is… Not an individual item, like tomato, orange, pineapple The entity in this case would be something like “Stock Item” Tomatoes, oranges and pineapples are instances of the entity “Stock Item” Think of some more examples of entities

Entities and tables Look again at tblEvent in the SportsDay database What entity does this table hold data about?

Adding a field to the table The organiser of the School Sports Day wants to add a field specifying what House each competitor is in When this is done, the Events table looks like this: Do you see any problem with this table?

Each entity should have its own table An entity is a category of person or thing about which data is held As you probably spotted, there are two entities involved in tblEvent: Sports event Winners What are the weaknesses of this table structure?

Data redundancy The firstname, surname and House of the winner are recorded against each event Holding the same data about an entity means you are holding redundant data – more data than necessary This takes time and space in the database, and can result in inconsistencies in the data Are there two girls in Year 7 named Karen Mason?

Entities and attributes Each entity has attributes associated with it. Each attribute is a field in the table which describes the entity What are the attributes of the Event entity? What are the attributes of the Winner entity? What is the unique ID of an Event?

Relationships between entities There are three possible relationships between two entities One-to-one (e.g. husband and wife) One-to many (e.g. mother and children) Many-to-many (e.g. pupils and subjects) What is the relationship between Sports event and Winner (i.e. Pupil)?

Worksheet 2 Now try Task 1 on Worksheet 2

Relating two tables We need to rearrange the SportsDay database so that it has two related tables, one for Event and one for Pupil The tables will be related by means of the key field in tblPupil tblEvent EventID EventCategory EventName PreviousRecord Units DateRecordSet WinnerID WinningResult Record tblPupil PupilID FirstName Surname House DateOfBirth ContactTelephoneNo (other fields)  

A relational database A database consisting of two or more related tables is known as a relational database The tables are related by means of a field that is common to both tables The field is a primary key in one of the tables

The primary key As a general rule, each table in a database needs a primary key The primary key uniquely identifies the record Which field is the primary key field in tblPupil?

Making the connection Which pupil won the Year 7 Girls 60m? Which pupil won the Year 7 Boys 60m Hurdles? Which pupil won the Year 7 Girls High Jump? What House is she in?

Data redundancy How has this arrangement of two linked tables cured the problem of data redundancy that existed in the single table arrangement? What other potential problems are solved by having two linked tables, each holding data about one entity, rather than holding all the data in a single table?

Worksheet 2 Now try Task 2 on the Worksheet

Foreign key When you created the link between the tables tblPupil and TblEvent, the field which linked the two tables was PupilID, the key field in TblPupil In TblWinner this field was named WinnerID, but it could have been named PupilID WinnerID is called a foreign key A foreign key in a table is the field that links to the primary key in the related table

A many-to-many relationship You cannot directly set up a many-to-many relationship between two entities. You need a table “in-between”, linking to both tables Link Winner Subject

How are the tables linked? In Access, set up two one-to-many relationships: