Mark Dixon, SoCCE SOFT 131Page 1 14 – Databases: Multiple Tables.

Slides:



Advertisements
Similar presentations
Relationships Relational Database. Identifying Entities… In the previous tutorial you learnt about identifying entities in a flat file database. Also.
Advertisements

Mark Dixon Page 1 05 – Database Design: Sub-forms.
Mark Dixon Page 1 04 – Database Design: Forms. Mark Dixon Page 2 Session Aims & Objectives Aims –To allow easier data entry using forms Objectives, by.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Modular Design in ASP.
Mark Dixon Page 1 06 – Expression Builder. Mark Dixon Page 2 Session Aims & Objectives Aims –To use expressions to perform more complex calculations in.
Mark Dixon Page 1 03 – Database Design: Multiple Tables.
SUNY Morrisville-Norwich Campus-Week 10 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Mark Dixon, SoCCE SOFT 131Page 1 17 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 SOFT – Module Introduction.
Designing a Database Unleashing the Power of Relational Database Design.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Entity-relationship diagrams.
Mark Dixon, SoCCE SOFT 131Page 1 22 – Web applications: Writing data to Databases using ASP.
Mark Dixon Page 1 18 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 02 – Queries: Query by Example.
Mark Dixon Page 1 20 – Modular Design in ASP. Mark Dixon Page 2 Session Aims & Objectives Aims –Highlight modular design techniques in ASP Objectives,
Mark Dixon, SoCCE SOFT 131Page 1 18 – Structured Query Language.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 19 – Databases: Multiple Tables.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
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?
Database Relationships Objective 5.01 Understand database tables used in business.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Mark Dixon 1 20 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 5 – Persistent data storage: relational databases.
Database Design Concepts
2.3 Organising Data for Effective Retrieval
Unit 18: Database Modelling
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
PLUG IT IN 3 Fundamentals of Relational Database Operations.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
Mark Dixon Page 1 21 – Persistent data storage: relational databases and MySQL.
Mark Dixon 1 05 – JSP Databases: Multiple Tables.
Mark Dixon 1 06 – JSP Databases: Multiple Tables.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
1 Outline  What is a Primary Key?  AutoNumber primary keys  Single-field primary keys  Composite-field primary key  About Foreign Keys  Database.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Microsoft Access 2013 ®® Tutorial 9 Using Action Queries and Advanced Table Relationships.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon 1 21 – Databases: Multiple Tables. Mark Dixon 2 Questions: Databases How many records are in the following table? How many fields does the.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
1 The Information School of the University of Washington Dec 1fit advdatabases © 2006 University of Washington Advanced Database Concepts INFO/CSE.
Database revision.
Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data.
ENTITY RELATIONSHIP DIAGRAM ENTITY RELATIONSHIP DIAGRAM IS A SPECIALIZED GRAPHIC THAT ILLUSTRATES THE INTERRELATIONSHIPS BETWEEN ENTITIES IN A DATABASE.
Relational Theory and Design
Lesson 2: Designing a Database and Creating Tables.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Web applications: Databases & ASP.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
Extending the biogeographical model Africamuseum 6 (7?) June 2013.
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
Mark Dixon, SoCCE SOFT 131Page 1 12 – Databases: Structured Query Language.
Plan the progression for the databases topic.
Teanna Clarke 6aQ What is a Entity-Relationship Diagram?  An Entity-Relationship Diagram (ERD) is a tool that graphically shows the connections among.
1 Management Information Systems M Agung Ali Fikri, SE. MM.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
18 – Databases: Structured Query Language
Databases A brief introduction….
17 – Persistent data storage: relational databases and ADO
19 – Databases: Multiple Tables
Presentation transcript:

Mark Dixon, SoCCE SOFT 131Page 1 14 – Databases: Multiple Tables

Mark Dixon, SoCCE SOFT 131Page 2 Session Aims & Objectives Aims –To add dealing with multiple tables to your understanding of databases Objectives, by end of this week’s sessions, you should be able to: –identify duplicated data in a single table –split that table to reduce data redundancy –generate SQL statements to (temporarily) join tables, and use these in your code

Mark Dixon, SoCCE SOFT 131Page 3 Record Field Flat files: Data Duplication Track TitleArtist NameCountry ParanoidBlack SabbathUK Falling in LoveAerosmithUS PinkAerosmithUS Love in an ElevatorAerosmithUS Smooth CriminalAlien Ant FarmUS Meaning of LifeDisturbedUS The GameDisturbedUS VoicesDisturbedUS Down with the SicknessDisturbedUS Track

Mark Dixon, SoCCE SOFT 131Page 4 Relations (tables) Track TitleArtist ID Paranoid1 Falling in Love2 Pink2 Love in an Elevator2 Smooth Criminal3 Meaning of Life4 The Game4 Voices4 Down with the Sickness4 Artist ID Artist NameCountry 1Black SabbathUK 2AerosmithUS 3Alien Ant FarmUS 4DisturbedUS Track Artist Primary Key Foreign Key

Mark Dixon, SoCCE SOFT 131Page 5 Normalisation Part of database design Process of breaking data down Codd –7 stages of normalisation Mathematical Difficult to apply stages Most professionals do it instinctively

Mark Dixon, SoCCE SOFT 131Page 6 Question: Prescriptions Identify duplication and separate: DateSurnameForenamesDrug Name 6 Jan 04JonesAlisonCo-codamol 11 Jan 04SmithBobTegretol 18 Jan 04HopeJohnCo-codamol 5 Feb 04JohnsonSallyCo-codamol 8 Feb 04SmithBobTegretol 10 Feb 04SmithBobSorbitol Prescription

Mark Dixon, SoCCE SOFT 131Page 7 Question: Solution DatePatientIDDrugID 6 Jan Jan Jan Feb Feb Feb 0423 Prescription PatientIDSurnameForenames 1JonesAlison 2SmithBob 3HopeJohn 4JohnsonSally Patient DrugIDDrug Name 1Co-codamol 2Tegretol 3Sorbitol Drug

Mark Dixon, SoCCE SOFT 131Page 8 People Database (with Hobbies) IDSurnameForenamesPhone 1DixonMark SmithJohn JonesSally BloggsFred AndersonGenny01752 HobbyIDDescriptionPersonID 1Archery1 2Herpetology1 3Music1 4Football2 5Rugby2 6Hitting people with swords1 Hobby Person

Mark Dixon, SoCCE SOFT 131Page 9 Entity-relationship diagrams Each table in db –stores details of entity shown as rectangular box Relationships between tables –represent relationships between entities shown as line between entities (boxes) PersonHobby

Mark Dixon, SoCCE SOFT 131Page 10 Relationship Types One-to-one One-to-many Many-to-one Many-to-many –(can't be implemented in relational database) ABABABAB

Mark Dixon, SoCCE SOFT 131Page 11 Question: Which relationship type? IDSurnameForenamesPhone 1DixonMark SmithJohn JonesSally BloggsFred AndersonGenny01752 HobbyIDDescriptionPersonID 1Archery1 2Herpetology1 3Music1 4Football2 5Rugby2 6Hitting people with swords1 Hobby Person Hobby

Mark Dixon, SoCCE SOFT 131Page 12 SQL: Joining tables SELECT * FROM [Person], [Hobby] WHERE [Person].[ID] = [Hobby].[PersonID]; Two tables Matching records IDSurnameForenamesPhone HobbyIDDescriptionPersonID 1DixonMark DixonMark DixonMark DixonMark01752 people with swords1 2SmithJohn SmithJohn01752

Mark Dixon, SoCCE SOFT 131Page 13 SQL: Joining tables IDSurname 1Dixon Smith 2 SELECT [ID], [Surname] FROM [Person], [Hobby] WHERE [Person].[ID] = [Hobby].[PersonID];

Mark Dixon, SoCCE SOFT 131Page 14 SQL: DISTINCT records SELECT DISTINCT [ID], [Surname] FROM [Person], [Hobby] WHERE [Person].[ID] = [Hobby].[PersonID]; IDSurname 1Dixon 2Smith

Mark Dixon, SoCCE SOFT 131Page 15 Tutorial Exercise: Music Task 1: Create the Music database (from the lecture) with the Track and Artist tables. Task 2: Create a web page to display a list of Artists. Task 4: Change that web page, so that each artist name is a link to another page, which displays all the tracks by that artist. Use query strings to pass the artist ID.

Mark Dixon, SoCCE SOFT 131Page 16 Tutorial Exercise: Prescriptions Task 1: Create the Prescription database (from the lecture) with the Prescription, Patient, and Drug tables. Task 2: Create a web page to display a list of Drugs. Task 4: Change that web page, so that each drug name is a link to another page, which displays all the people using that drug.