IMS 6217: Primary Key Reference 1 Dr. Lawrence West, MIS Dept., University of Central Florida Primary Keys Uniqueness of Table Rows Identifier.

Slides:



Advertisements
Similar presentations
Relational Database Design UNIT II 1. 2 Advantages of Using Database Systems Centralized control of a firm’s data Redundancy can be reduced (avoid keeping.
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Advanced Data Modeling
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 6 Advanced Data Modeling.
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 6 Advanced Data Modelling
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
The Relational Database Model:
Chapter 5 Normalization of Database Tables
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Database – Part 2a Dr. V.T. Raja Oregon State University.
Copyright ©2014 Pearson Education, Inc. Chapter 3 Requirements and Business Rules Chapter3.1.
IMS 4212: Distributed Databases 1 Dr. Lawrence West, Management Dept., University of Central Florida Distributed Databases Business needs.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Module Title? DBMS E-R Model to Relational Model.
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
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 System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
IMS 4212: Data Modeling—Super-Type/Sub-Type Entities 1 Dr. Lawrence West, Management Dept., University of Central Florida Super-Type.
CSCI 3140 Module 2 – Conceptual Database Design Theodore Chiasson Dalhousie University.
Concepts and Terminology Introduction to Database.
DATABASES Pindaro Demertzoglou – Lally School of Management and Technology.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
IMS 6217: Relationships 1 Dr. Lawrence West, MIS Dept., University of Central Florida Database Design--Topics DB Design Steps Identify.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
SQL Structured Query Language Programming Course.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
IMS 4212: Introduction to Data Modeling 1 Dr. Lawrence West, Management Dept., University of Central Florida Introduction to Data Modeling—Topics.
IMS 4212: Database Implementation 1 Dr. Lawrence West, Management Dept., University of Central Florida Physical Database Implementation—Topics.
IMS 4212: Data Modeling—Attributes 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains Nonkey.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
IMS 4212: Data Modeling—More Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Data Modeling—Topics.
IMS 4212: Introduction to Data Modeling—Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Relationships—Topics.
1 Functional Dependencies and Normalization Chapter 15.
Normalization of Database Tables
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
IMS 4212: Data Modeling—Attributes and Domains 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains.
Database Basics BCIS 3680 Enterprise Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
IMS 4212: Database Implementation 1 Dr. Lawrence West, Management Dept., University of Central Florida Physical Database Implementation—Topics.
IMS 6217: Relational Data Model 1 Dr. Lawrence West, MIS Dept., University of Central Florida Introduction to Databases—Topics Information.
Ch 7: Normalization-Part 1
Database Design. Database Design Process Data Model Requirements Application 1 Database Requirements Application 2 Requirements Application 4 Requirements.
IMS 4212: Data Modeling—Business Rules 1 Dr. Lawrence West, Management Dept., University of Central Florida Business Rules—Topics Intro.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
IMS 6217: Database Design & Entities 1 Dr. Lawrence West, MIS Dept., University of Central Florida Database Design--Topics DB Design.
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.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Logical Database Design and Relational Data Model Muhammad Nasir
IMS 6217: Introduction to Data Modeling 1 Dr. Lawrence West, MIS Department, University of Central Florida Introduction to Data Modeling—Topics.
Database Planning Database Design Normalization.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Implementing an REA Model in a Relational Database
Database Constraints Ashima Wadhwa.
Attributes and Domains
Primary Keys Uniqueness of Table Rows
Primary Keys—Topics Uniqueness of Table Rows
Session 2 Welcome: The fifth learning sequence
Attributes and Domains
Database Management system
Presentation transcript:

IMS 6217: Primary Key Reference 1 Dr. Lawrence West, MIS Dept., University of Central Florida Primary Keys Uniqueness of Table Rows Identifier Attributes and Primary Keys Composite Identifiers Natural and Artificial Identifiers and Autogenerated Primary Keys Candidate Keys and Alternate Keys Problem Keys Diagraming Tables with Key Attributes

IMS 6217: Primary Key Reference 2 Dr. Lawrence West, MIS Dept., University of Central Florida Uniqueness of Table Rows Remember our twin goals of minimizing storage space and reducing data redundancy A duplicate record (occurrence) in a table violates this rule Because any record represents one real world occurrence of the thing the entity defines if there is a duplicate record there must be a duplicate occurrence But each occurrence is unique so duplicate records are wasted space—one record is enough

IMS 6217: Primary Key Reference 3 Dr. Lawrence West, MIS Dept., University of Central Florida Uniqueness of Table Rows and Update Anomalies An “update anomaly” occurs when data is not updated correctly Duplicate records affect data accuracy through update anomalies and processing efficiency –Occur when duplicate data exists and not all matching records are updated when a change is needed May be two records for the same customer with different addresses –All records must be checked (since there could be duplicates) instead of stopping when the matching record is found

IMS 6217: Primary Key Reference 4 Dr. Lawrence West, MIS Dept., University of Central Florida A Theory for the Importance of Primary Keys If a subset of attributes (including a single attribute) can be guaranteed to have unique values in a single table… …then each record in the table is guaranteed to be unique… …even if there are duplicates for the values of other attributes –Student ID is unique to each student –Roommates will share address attribute values

IMS 6217: Primary Key Reference 5 Dr. Lawrence West, MIS Dept., University of Central Florida Identifier Attributes Identifier Attribute(s): An attribute or set of attribute(s) whose value(s) uniquely identify each occurrence of an entity Identifier Attributes are forced to be unique within a table –SSN for student or faculty –VIN for an automobile –SKU for a retail product We will refer to Identifier Attributes at design time and these will become Primary Keys upon implementation (after some analysis)

IMS 6217: Primary Key Reference 6 Dr. Lawrence West, MIS Dept., University of Central Florida Identifier Attributes Define Entities A Vehicle Identification Number (VIN) identifies one and only one instance of an automobile Since only an automobile can be identified by a VIN, an entity with VIN as an identifier attribute can only contain occurrences of automobiles The VIN then identifies a car but also defines the entity What entities do these attributes define? –Social Security Number –Radio Call Letters (WMFE) –Universal Product Code (UPC) Identifier attributes can never, ever be null

IMS 6217: Primary Key Reference 7 Dr. Lawrence West, MIS Dept., University of Central Florida Composite Identifiers Some entities need more than one attribute to form a unique value –DepartmentCode & CourseNumber Both attributes combine to be unique and identify each occurrence and define the entity Duplicates are allowed within each attribute –Any MIS course has an “ISM” prefix –There can be an English course with “4212” as the course number The combination of values (“ISM 4212”) must be unique

IMS 6217: Primary Key Reference 8 Dr. Lawrence West, MIS Dept., University of Central Florida Composite Identifiers (cont) What is the natural PK of our section of this course? Of the fact that you are enrolled in this course? What entities are identified by the following values? –RegisterNumber & StartTime (DateTime value) –VIN and SSN –Building & RoomNumber (UCF database) –AptNum & StartDate –ProductID & SaleID

IMS 6217: Primary Key Reference 9 Dr. Lawrence West, MIS Dept., University of Central Florida “Natural” and “Artificial” Identifiers Most PKs are “artificial” or “generated” –SSN– StudentID –VIN– CourseNum –SerialNumber– LicensePlateNum & State Some PKs are (more) “natural” –MagazineTitle & PublicationDate –Section Identifier PK The distinction isn’t particularly important

IMS 6217: Primary Key Reference 10 Dr. Lawrence West, MIS Dept., University of Central Florida Autogenerated PKs An important class of artificial PKs are the anuogenerated, autonumber, or “Identity” attributes DBMS can be configured to automatically generate a unique sequential number for each new record added to a table –Identity attribute value unique within any table –Global Unique Identifier (GUID) unique anywhere in the world By definition these values are unique and so can be a PK

IMS 6217: Primary Key Reference 11 Dr. Lawrence West, MIS Dept., University of Central Florida Candidate Keys Some entities may have more than one attribute or sets of attributes that can serve as a PK –VIN –ParkingDecalNum & Year –State & TagNum How is a house identified? Often a “natural” PK is cumbersome and an artificial PK, especially an autonumber, is introduced One candidate key is selected to be the PK Nonselected candidate keys become “alternate keys”

IMS 6217: Primary Key Reference 12 Dr. Lawrence West, MIS Dept., University of Central Florida Some Problem PKs People’s names are horrible choices for PKs (Is there a “natural” PK for a person?) Avoid PKs that change frequently ( ) Phone numbers (not unique, change) All things being equal, choose the simplest candidate key to be the PK Always ensure that your PK defines the entity that you have in mind (Can a SSN change?)

IMS 6217: Primary Key Reference 13 Dr. Lawrence West, MIS Dept., University of Central Florida A Data Model Segment

IMS 6217: Primary Key Reference 14 Dr. Lawrence West, MIS Dept., University of Central Florida Documenting Identifier Attributes (cont.) Identifier attributes are underlined in an ER diagram

IMS 6217: Primary Key Reference 15 Dr. Lawrence West, MIS Dept., University of Central Florida PKs and Other Attributes in SQL Server Diagram Composite PK Single-attribute PK