Many-to-many (M:M) relationship M:M Concept: A Shipment can contain many types of Materials and a type of Material can be sent in many different shipments.

Slides:



Advertisements
Similar presentations
Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.
Advertisements

ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
Dimensional Modeling.
Designing tables from a data model (Chapter 6) One base table for each entity.
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
Extended Learning Module C
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
--The Entity Relationship Model(3)--1 Outline  ER model  Overview  Entity types Attributes, keys  Relationship types  Weak entity types  Uses Crows.
Accounting System Design
© Steven Alter, 2007, all rights reserved Database concepts Difference between a database and the Internet Reason for having a defined data structure Relational.
Set operators Union Minus Intersect match ALL COLUMNS must have same ID, column names.
© Ron McFadyen1 Many-to-one-to-many We need information that can only be obtained by accessing two fact tables through a common dimension … drilling across.
© 2008 Prentice Hall Business Publishing Accounting Information Systems, 11/e Romney/Steinbart1 of 121 C HAPTER 16 Implementing an REA Model in a Relational.
Access A Relational Database Management System. Prof. Leighton2 Database ► A database is a collection of data that’s related to a particular topic ► A.
Extended Learning Module J (Office 2007 Version) Implementing a Database with Microsoft Access McGraw-Hill/Irwin Copyright © 2010 by the McGraw-Hill Companies,
Entity-Relationship Model and Diagrams (continued)
Lecture 10 Conversion to tables Database Design Concepts INFO1408.
Accounting Databases Chapter 2 The Crossroads of Accounting & IT
CSEN 5314 Quiz 3.
Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 18-1.
Database – Part 2a Dr. V.T. Raja Oregon State University.
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases1 Seminar 1: Revisiting Databases and SQL Purpose To refresh basic concepts.
Entity/Relationship Modelling
Database Relationships Objective 5.01 Understand database tables used in business.
 An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database.  An Entity Relationship.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
More on E-R Diagrams After this lecture, you should be able to:
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 1.
Entity / Attributes Entity represents a person / thing Entity represents an Access table Attributes describe facets of an entity Attributes represents.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
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 /
6.8 Case Study: E-R for Supplier-and-Parts Database
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Converting ER model Into Relational Table
Introduction to SQL Steve Perry
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
PLUG IT IN 3 Fundamentals of Relational Database Operations.
BTEC National Extended Diploma1 IT Systems Analysis and Design Entity Relationship Diagrams.
One-to-many relationship Relational databases link several entities based on relationships that exist (based on modeling reality) 1:m relationship example:
What we’ve learnt Doc 5.69 Doc 5.70 Section 1-3. A simple database Related objects Tables hold the data Forms, reports, queries to access the data.
Customer Order Order Number Date Cust ID Last Name First Name State Amount Tax Rate Product 1 ID Product 1 Description Product 1 Quantity Product 2 ID.
Overview of Database Development Data Modeling and Relational Database Design.
DAY 14: MICROSOFT ACCESS – CHAPTER 1 Madhuri Siddula October 1, 2015.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved ©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin.
Database revision.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
ENTITY RELATIONSHIP DIAGRAM ENTITY RELATIONSHIP DIAGRAM IS A SPECIALIZED GRAPHIC THAT ILLUSTRATES THE INTERRELATIONSHIPS BETWEEN ENTITIES IN A DATABASE.
Quiz questions. 1 A data structure that is made up of fields and records? Table.
COMP3030 Database Management System Final Review
Extending the biogeographical model Africamuseum 6 (7?) June 2013.
Xin 27 October,  Excel  Access  Query  Table  Practice ◦ Create a Class table for different semesters  Select the data with a query  Change.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
* 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.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2007 Version) Implementing.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 18-1.
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
Advanced Database and Client Server Applications Susan Curtis, Paul Crowther, Alan Houldcroft, Peter Lake, John Whitfield.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
Database Management Systems II
COP 4540 Database Management
Generalization.
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Bookstore DB Requirements
Entity Relationship Model
Presentation transcript:

Many-to-many (M:M) relationship M:M Concept: A Shipment can contain many types of Materials and a type of Material can be sent in many different shipments M:M is converted into two 1:M relationships - Intersection entity/table is created The intersection table must have two foreign keys One for each of the entities in the m:m relationship A foreign key can also be part of the primary key for the intersection table 1

3 Tables 2 Shipment ID Shipment Sent Shipment Received 40019/1/20119/9/ /3/20119/23/ /22/20119/29/ /2/201110/15/ /21/2011 Material ID CategoryHazardous 1ElectronicsFalse 2CompositesFalse 3MachineryFalse 4SolventsTrue 5PetrochemicalsTrue ShipmentItems Shipment ID Lineno Material ID

Model Extended to include Suppliers 3

4 Tables (to be used for queries) 4 Material ID CategoryHazardous 1ElectronicsFalse 2CompositesFalse 3MachineryFalse 4SolventsTrue 5PetrochemicalsTrue ShipmentItems Shipment ID Lineno Material ID Shipment ID Shipment Sent Shipment Received Supplier ID 40019/1/20119/9/ /3/20119/23/ /22/20119/29/ /2/201110/15/ /21/20114 Supplier ID Supplier Name CityState Delivery EffRank Cost EffRank 1VanguardNew OrleansLouisiana23 2SmithfieldHoustonTexas14 3BlackstoneJacksonvilleFlorida51 4CommodoreNorfolkVirginia45 5LakeshoresLong BeachCalifornia32

Querying across 3 tables List the material categories, the shipment ID, Line #, and date received for all items received on 9/9/2011 SELECT Category, Shipment.ShipmentID, Lineno, ShipmentReceived FROM Shipment, ShipmentItems, Material Where Shipment.ShipmentID = ShipmentItems.ShipmentID AND ShipmentItems.MaterialID = Material.MaterialID AND ShipmentReceived = #9/9/2011#; 5 Category Shipment ID Lineno Shipment Received Machinery400119/9/2011 Solvents400129/9/2011 Petrochemicals400139/9/2011

Model Further Extended to include Employees & Clients 6 If you can SQL using 2 or 3 tables – you have the skills to run SQL using 1,000 tables

All Tables 7 Material ID CategoryHazardous 1ElectronicsFalse 2CompositesFalse 3MachineryFalse 4SolventsTrue 5PetrochemicalsTrue ShipmentItems Shipment ID Lineno Material ID Shipment ID Shipment Sent Shipment Received Supplier ID Client ID 40019/1/20119/9/ /3/20119/23/ /22/20119/29/ /2/201110/15/ /21/ Supplier ID Supplier Name CityState Delivery EffRank Cost EffRank 1VanguardNew OrleansLouisiana23 2SmithfieldHoustonTexas14 3BlackstoneJacksonvilleFlorida51 4CommodoreNorfolkVirginia45 5LakeshoresLong BeachCalifornia32 Client ID Client Name Client Services Client City Client State Client Revenue Emp ID 1BK AssociatesCommercialPortlandOregon$210, BlalocIndustrialKansas CityMissouri$330, Bankton ElectricGovernmentNew York $210, BickIndustrialRaleighNorth Carolina$550, TX ElectricGovernmentHoustonTexas$160, CrowCommercialDallasTexas$270, GRBIndustrialAtlantaGeorgia$180, H&PIndustrialDenverColorado$90, LB&BIndustrialBostonMassachusetts$211, CongroIndustrialAtlantaGeorgia$122, Moss EnterprisesCommercialPhoenixArizona$33, RubyIndustrialSan AntonioTexas$344, Silver IndustriesIndustrialOmahaNebraska$218, TPHCommercialAnnaheimCalifornia$166, Employee Emp ID Emp first Name Emp last name Emp status Emp Rate 1DanPiercefull time$ SeanSmithfull time$ LauraJohnsonfull time$ MikeLucasfull time$ LarryWilsonfull time$ KeithEthridgepart time$25.00