Fundamentals/ICY: Databases 2012/13 Week 4 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.

Slides:



Advertisements
Similar presentations
Fundamentals/ICY: Databases 2013/14 WEEK 4: Monday Intro to tables, etc. John Barnden Professor of Artificial Intelligence School of Computer Science University.
Advertisements

Fundamentals/ICY: Databases 2013/14 Week 6: Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Murali Mani The Relational Model. Murali Mani Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Relational Model Stores data as tables –Each column contains values about the same attribute –Each column has a distinct name –Each row contains values.
Chapter 14 Getting to First Base: Introduction to Database Concepts.
Concepts of Database Management Seventh Edition
July 14, 2015ICS 424: recap1 Relational Database Design: Recap of ICS 324.
Database Architecture The Relational Database Model.
Fundamentals/ICY: Databases 2012/13 WEEK 11 (relational operators & relational algebra) John Barnden Professor of Artificial Intelligence School of Computer.
The Relational Database Model
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of.
Fundamentals/ICY: Databases 2013/14 REVISION WEEK John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
Relational Model Session 6 Course Name: Database System Year : 2012.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
Fundamentals/ICY: Databases 2010/11 WEEK 5 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Fundamentals/ICY: Databases 2012/13 REVISION WEEK John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2012/13 WEEK 5 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Fundamentals/ICY: Databases 2012/13 WEEK 7 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
Fundamentals/ICY: Databases 2013/14 Week 10 –Monday –Normalization, contd John Barnden Professor of Artificial Intelligence School of Computer Science.
The Relational Database Model
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
Fundamentals/ICY: Databases 2012/13 WEEK 3 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Concepts of Database Management Eighth Edition Chapter 6 Database Design 2: Design Method.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Fundamentals/ICY: Databases 2012/13 WEEK 10 (maths, normalization) John Barnden Professor of Artificial Intelligence School of Computer Science University.
Fundamentals/ICY: Databases 2010/11 WEEK 3 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Fundamentals/ICY: Databases 2012/13 WEEK 11 – 4 th Normal Form (optional material) John Barnden Professor of Artificial Intelligence School of Computer.
C-1 Management Information Systems for the Information Age Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Extended Learning Module.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Fundamentals/ICY: Databases 2013/14 WEEK 9 –Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
IMS 4212: Introduction to Data Modeling—Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Relationships—Topics.
Fundamentals/ICY: Databases 2013/14 WEEK 9 –Friday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2010/11 REVISION WEEK John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2013/14 Week 5: Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Fundamentals/ICY: Databases 2013/14 Week 4: Friday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Intro to Maths for CS: 2012/13 Sets (end, week 3) John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2013/14 Week 11 – Monday – relations, ended. John Barnden Professor of Artificial Intelligence School of Computer Science University.
April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading
Fundamentals/ICY: Databases 2012/13 WEEK 9 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
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.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Quiz Which of the following is not a mandatory characteristic of a relation? Rows are not ordered (Not required) Each row is a unique There is a.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
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.
Revised: 2 April 2004 Fred Swartz
Entity-Relationship Model
Fundamentals/ICY: Databases 2010/11 WEEK 6
Getting to First Base: Introduction to Database Concepts
Getting to First Base: Introduction to Database Concepts
Getting to First Base: Introduction to Database Concepts
John Barnden Professor of Artificial Intelligence
Presentation transcript:

Fundamentals/ICY: Databases 2012/13 Week 4 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK

Reminder of Week 3

ENTITIES, RELATIONSHIPS & ATTRIBUTES (Introduction)

Entities uBasically, entities are just things of the “important types” that we judged above to merit tables. So we had entity types such as: l People l Employing Organizations l Phone Stations (as opposed to just phone numbers as such) uSo what the entity types are in a given working environment are partly a matter of judgment, as explained earlier. But we’ll see that in designing a DB we may need to introduce new, not immediately obvious, entity types. u“Entities” are, or should be, the things of a type: e.g., individual people. An entity is represented by a row in the appropriate table.

Entity Terminology uUnfortunately: “entity” is often used to mean entity type. “entity set” is often used for entity type. “entity occurrence” is often used to mean individual entity.

New for Week 4

Relationships uThese are the relationships between entity types, such as l A person being employed by an organization l A person having a phone station uHave to think about both directions of a relationship: e.g., both employed-by and employs. uCAUTION: Tables are also called “relations” [hence “relational” DB] (much more on this later). This is to do with the internals of tables/entities rather than with “relationships” between entities.

Relationship Connectivity uRelationships are importantly categorized as to uniqueness or multiplicity of entities at either end – “connectivity.” Has big effect on DB design. l 1:1 (“one to one”): e.g., the people/phone-stations relationship, if each person has at most one phone station and each phone station is assigned to at most one person. l M:N (“many to many”): e.g., the employs relationship, assuming a person may have more than one employing organization (or none) and an organization may have more than one employee (or none). (Don’t take “many” seriously – just means possibly more than one.) l 1:M (“one to many”): e.g., the employs relationship, if an organization may have more than one employee (or none) but a person has at most one employing-org.

Relationship Cardinality uRelationships can be further specified as to “how many entities allowed or required at either end” – cardinality. Also has significant effect on DB design. uIn a relationship from entity type A to entity type B, a minimum and a maximum can be specified for the number of B entities for each A entity. uA maximum greater than 1 can only be specified if the relationship from A to B is 1:M or M:N. (So the notions of connectivity and cardinality are not properly separated). l E.g., could be specified that a person can only be employed by up to five organizations. uMost normally, the important choice for the minimum is between none and one. E.g., the minimum for employed-by could be none, but the minimum for employs could be one. But the minimum number of wheels for a car could be specified to be three. uIf the minimum is none, then B is optional for A. Otherwise, it is mandatory for A.

Attributes uAttributes of entities of a given type are the names of the different pieces of information that need to be stored for entities of that type. So they’re just the column names for the table for the entity type. l E.g., entities of the type “people” could have the following attributes: person ID number, last name, first name, phone number, age. uNote: Attributes include artificial ones like the employer identity numbers (EMPL. NUM.) that we introduced in an example above. These may have no significance outside the DB itself. uRelationships are represented by associative linking by means of shared attributes. (For now, will always assume that the same attribute name is used in each of the tables involved.)

Attribute Determination uREMEMBER: Rows in a table are uniquely determined (picked out) by the values in some set of columns, i.e. the values of some collection of attributes. That is, given some values for those attributes, there is at most one entity that has those values for those attributes. uHence, that collection of attributes determines all the other attributes. uThat is, given some values for the determining attributes, there’s at most one value for each of the other attributes.

Attribute Determination, contd. uMore generally, a collection of one or more attributes determines another attribute A if only one value for A is possible given the values for the former attributes. E.g., the collection DAY-NUMBER, MONTH and YEAR specifying birth-date in a table about people could determine DAY-NAME, even though it doesn’t determine other attributes such as NATIONALITY: several people could have the same birth-date but be of different nationalities. uWe alternatively say that DAY-NAME is functionally dependent on DAY-NUMBER, MONTH and YEAR.

Attribute Determination, contd. uThe determining collection of attributes is called the determinant in the determination. uWrite determination as: DAY-NUMBER, MONTH, YEAR  DAY-NAME uDetermination does not mean that you have at hand an algorithm for working out a dependent attribute from the determinant, although you may do. E.g. Consider a “father” attribute.

Keys uA key for a table is a collection of one or more attributes that determines at least some other attribute(s) in that same table. l CAUTION: But sometimes people use “key” as a sloppy abbreviation for “primary key” (see below) or other notions. uA superkey for a table is a collection of one or more attributes that determines all the other attributes in the table, i.e. determines a whole row. l Trivially, the collection of all the attributes is a superkey. uA candidate key is a minimal superkey (i.e., you can’t remove attributes from it and still have a superkey.) It does NOT necessarily mean a numerically smallest superkey.

Superkeys & Candidate Keys: Example uSuppose a “day” entity type has attributes DAY-NAME, DAY-NUMBER, MONTH, YEAR, IS-HOLIDAY, … uThen DAY-NAME, DAY-NUMBER, MONTH, YEAR would be a superkey for the day type. uBut it’s not a candidate key because DAY-NUMBER, MONTH, YEAR is also a superkey. uThis smaller collection is a candidate key because no sub- collection of it uniquely identifies a day.

Primary Keys uA primary key for a table (entity type) is a candidate key that the DB designer has chosen as being the main way of uniquely identifying a row (entity). Extra restriction: Its attributes are not allowed to have null values. l It could be that there’s only one candidate key in practice anyway, such as a person’s ID number. uPrimary keys are the main way of identifying target entities in entity relationships, e.g., the way to identify someone’s employing organization. uFor efficiency reasons, the simpler that primary keys are, the better. l Identity numbers (of people, companies, products, courses, etc.), or combinations of them with one or two other attributes, are the typical primary keys in examples in the textbook and handouts.

Relationships and Foreign Keys uStandardly, a relationship is represented by means of foreign keys. T U U uA foreign key in a table T is a chosen collection of attributes intended to match the attributes that constitute (usually) the primary key in another table, U, and thereby to refer to entities in U. TU T Intuitively, the foreign key in T is U’s “ambassador” [my word] in T.

Primary & Foreign Keys PERS-IDNAMEPHONEEMPL. IDAGE Chopples E Blurp E Rumpel E EMPL. IDEMPL. NAMEADDRESSNUM. EMPLSSECTOR E48693BTBT House, London, … 1,234,5678Private TCOM E85704Monmouth School for Girls Hereford Rd, Monmouth, … 245Private 2E E22561University of Birmingham Edgbaston Park Rd, …. 4023Public HE PHONETYPESTATUS officeOK homeFAULT homeOK mobileUNPAID Foreign keys are in italics Primary keys are underlined

Composite Primary and Foreign Keys PERS-IDNAMEAREA CODEPHONE BODYEMPL IDAGE Chopples E Blurp E Rumpel E AREA CODEPHONE BODYTYPESTATUS officeOK homeFAULT homeOK mobileUNPAID Phones People

1:1 Connectivity between Tables PERS-IDNAMEPHONEEMPL IDAGE Chopples E Blurp E Rumpel E BigglesE PHONETYPESTATUS officeOK homeFAULT homeOK mobileUNPAID Note: the representation is still asymmetric in that the People table mentions phones but not vice versa – symmetry would create extra redundancy. NB: Biggles has no phone listed, and has no person recorded. Suggests a possible reason for not combining such tables. 1:1: that is, no more than one phone allowed per person, and vice versa. People Phones

1:M Connectivity between Tables PERS-IDNAMEPHONEEMPL IDAGE Chopples E Blurp E Rumpel E Dunston E EMPL IDEMPL NAMEADDRESSNUM EMPLSSECTOR E48693BTBT House, London, … 1,234,5678Private TCOM E85704Monmouth School Hereford Rd, Monmouth, … 245Private 2E E22561University of Birmingham Edgbaston Park Rd, …. 3023Public HE People Organizations More than one employee allowed per organization, but no more than one employer per person. NOTE direction of use of the foreign key. Why so??