A step-by-step application development Develop a database recording information about teams, players, and their fans, including –For each team, its name,

Slides:



Advertisements
Similar presentations
COP4540 Database Management System Midterm Review
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,
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
1 Assignment 4 Map entities with relationships to relational schemas. Use DBDL to describe the table schemas.
1 Database Design I: The Entity- Relationship Model Chapter 5.
1 Relationships Entities take part in relationships. We can often identify relationships from verbs or verb phrases. For example – you are attending this.
The Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
1 Presentation by Irina Kogan. November 27, Presentation by Irina Kogan. November 27, 2000.
Database Principles ER to RDM Mapping. Database Principles Mapping from ER to Relational Data Model the next phase Exercise: Give me some suggestions.
Design Principles: Faithfulness
Weak Entity Sets. Occasionally, entities of an entity set need “help” to identify them uniquely. Entity set E is weak if in order to identify entities.
D ATABASE S YSTEMS I A DMIN S TUFF. 2 Mid-term exam Tuesday, Oct 2:30pm Room 3005 (usual room) Closed book No cheating, blah blah No class on Oct.
Representing Data Elements Gayatri Gopalakrishnan.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Entity-Relationship Model and Diagrams (continued)
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
The Entity-Relationship Data Model
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)
5 Chapter 5 Structured Query Language (SQL1) Revision.
Entity/Relationship Modelling
Database Systems Lecture 5 Natasha Alechina
Entity Relationship Model Chapter 6. Basic Elements of E-R Model Entity Object of the real world that stores data. Eg. Customer, State, Project, Supplier,
1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.
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,
Database Design Concepts
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Converting ER model Into Relational Table
Introduction to Accounting Information Systems
INTEGRITY. Integrity constraint Integrity constraints are specified on a database schema and are expected to hold on every valid database state of the.
Functional Dependence An attribute A is functionally dependent on attribute(s) B if: given a value b for B there is one and only one corresponding value.
Conversion from ER diagram to relational model
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
The Relational Model1 ER-to-Relational Mapping and Views.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Btec National - Advanced Databases 1 Advanced Databases Entity Relationship Diagrams.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
E-R to Relational - Basic
ENTITY RELATIONSHIP DIAGRAM ENTITY RELATIONSHIP DIAGRAM IS A SPECIALIZED GRAPHIC THAT ILLUSTRATES THE INTERRELATIONSHIPS BETWEEN ENTITIES IN A DATABASE.
Relational Theory and Design
Order Database – ER Diagram Prepared by Megan Foster Fall Semester 2014.
Mapping E/R Diagrams to Relational Database Schemas
COMP3030 Database Management System Final Review
* 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.
Btec National - IT SYSTEMS ANALYSIS AND DESIGN 1 IT Systems Analysis and Design Entity Relationship Diagrams.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Conversion from ER diagram to relational model 1 ER is a visual model The relational model is a matemathical model.
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
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.
CSCI-100 Introduction to Computing
CSCI 6315 Applied Database Systems – Exercise (1)
Order Database – ER Diagram
Data Modelling Introduction
Databases: An Introduction
CS4222 Principles of Database System
Chengyu Sun California State University, Los Angeles
Presentation transcript:

A step-by-step application development Develop a database recording information about teams, players, and their fans, including –For each team, its name, its players, its team captain (one of its players), and the colors of its uniform. –For each players, his/her name. –For each fan, his/her name, favorite teams, favorite players, and favorite colors.

A step-by-step application development Develop a database recording information about teams, players, and their fans, including –For each team, its name, its players, its team captain (one of its players), and the colors of its uniform. –For each players, his/her name. –For each fan, his/her name, favorite teams, favorite players, and favorite colors.

Step 1 – Entity Types Entity types: –Teams (consists of tuples, each describes a team) –Players (consists of tuples, each describes a player) –Fans (consists of tuples, each describes a fan) –Colors (consists of tuples, each describes a color)

Step 2 – Entity Types and (Their) Attributes Entity types: –Teams: name (might be more!) –Players: name, id –Fans: name, id –Colors: name Assumptions: –Different name for different team –No two players with the same id (otherwise?) –…

Step 3 –.. and Relationship Types Entity types: –Teams: name –Players: name, id –Fans: name, id –Colors: name Relationship Types: –Belongs_to: (Teams, Players, Since) (1:m) –Captain_of: (Teams, Players) (1:1) –Uniform_of: (Teams, Colors) (1:m) –Favorite_of: (Fans, Teams) (n:m) –LikeP: (Fans, Players) (n:m) –LikeC: (Fans, Colors) (n:m)

E/R diagram Fans Favorite_of name Teams name Colors Uniform_of name Belongs_to Captain_of LikeP LikeC Players id since

Adding Constraints Each player plays in only one team –a participation constraint of tuple in the entity type ‘Players’ with respect to the relationship type ‘Belongs_To’ Each team has one captain –a participation constraint of tuple in the entity type ‘Teams’ with respect to the relationship type ‘Captains’

E/R diagram (with Constraints) Fans Favorite_of name Teams name Colors Uniform_of name Belongs_to Captain_of LikeP LikeC Players id since

Relations Entity types –Fans(id, name) –Teams(name) –Players(id, name) –Colors(name) Relationship types –Belongs_to(teamname, playerid, since) (each player plays for one team) –Captain_of(teamname, playerid) (each team has only one captain) –Uniform_of(teamname, colorname) (uniform might have >1 color/one color might be used by many teams) –Favorite_of(fanid, teamname) (1 fan likes > 1 team/1 team has > 1 fan) –LikeP(fanid, playerid) (why?) –LikeC(fanid, colorname) (why?)

Constraints Belongs_to(teamname, playerid, since) Belongs_to(playerid) references Players(id) Captain_of(teamname, playerid) Captain_of(teamname) references Teams(name) Captain_of(playerid) references Players(id) Uniform_of(teamname, colorname) Uniform_of(teamname) references Teams(name) Uniform_of(colorname) references Colors(name)

Constraints Favorite_of(fanid, teamname) Favorite_of(teamname) references Teams(name) Favorite_of(fanid) references Fans(id) LikeP(fanid, playerid) LikeP(fanid) references Fans(id) LikeP(playerid) references Players(id) LikeC(fanid, colorname) LikeC(fanid) references Fans(id) LikeC(colorname) references Colors(name)

Looking back Each team has only one captain: the ‘Captain_of’ relation contains exactly one tuple for each team So, it could be better if we add the captain to the team relation and removes one relation Question: if we also want to record the time when the captain being named, something like, A is the captain of team T since 2003, would it be better for us to keep the ‘Captain_of’ relation?

SQL (DDL) CREATE TABLE teams(name char(40), PRIMARY KEY (name)) CREATE TABLE fans(id integer, name char(40), PRIMARY KEY (id)) CREATE TABLE players(id integer, name char(40), PRIMARY KEY (id)) CREATE TABLE colors(name char(40), PRIMARY KEY (name)) CREATE TABLE belongs_to(pid integer, tname char(40), since date, PRIMARY KEY (pid), FOREIGN KEY (pid) REFERENCES players(id), FOREIGN KEY (tname) REFERENCES teams(name)) ….