Relational Database Basics Review

Similar documents
CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

ISM 318: Database Systems. Objectives. Database. Dr. Hamid R. Nemati

Relational Database Concepts

ICOM 6005 Database Management Systems Design. Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 August 23, 2001

Normalization. CIS 3730 Designing and Managing Data. J.G. Zheng Fall 2010

David M. Kroenke and David J. Auer Database Processing 11 th Edition Fundamentals, Design, and Implementation. Chapter Objectives

Data Modeling Basics

DATABASE MANAGEMENT SYSTEMS. Question Bank:

full file at

SQL, PL/SQL FALL Semester 2013

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Introduction. Introduction: Database management system. Introduction: DBS concepts & architecture. Introduction: DBS versus File system

Introduction: Database management system

Database Systems. Lecture 1: Introduction

David M. Kroenke and David J. Auer Database Processing 12 th Edition

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

Course MIS. Foundations of Business Intelligence

Database Design and Programming

Database Management. Chapter Objectives

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Introduction to Databases

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

Foundations of Business Intelligence: Databases and Information Management

Chapter 6 FOUNDATIONS OF BUSINESS INTELLIGENCE: DATABASES AND INFORMATION MANAGEMENT Learning Objectives

Databases and BigData

Database Design. Adrienne Watt. Port Moody

COMP5138 Relational Database Management Systems. Databases are Everywhere!

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Foundations of Information Management

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

Data. Data and database. Aniel Nieves-González. Fall 2015

1 File Processing Systems

Fundamentals of Database Design

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Foundations of Business Intelligence: Databases and Information Management

Concepts of Database Management Seventh Edition. Chapter 9 Database Management Approaches

Basic Concepts of Database Systems

Introduction to Database Systems

Foundations of Business Intelligence: Databases and Information Management

Database Design - 2nd Edition

DATABASE MANAGEMENT SYSTEM

ACSG 552 Assignment #1 Spring 2009 Diana Oboikovitz. Due in class on Thursday, Jan. 22:

3. Relational Model and Relational Algebra

MySQL for Beginners Ed 3

Foundations of Business Intelligence: Databases and Information Management

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

Principles of Database. Management: Summary

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 1 Outline

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

The Relational Model. Why Study the Relational Model?

Overview of Data Management

Foundations of Business Intelligence: Databases and Information Management

BCA. Database Management System

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

ECS 165A: Introduction to Database Systems

IT2305 Database Systems I (Compulsory)

A Brief Introduction to MySQL

Oracle Database 10g Express

Types & Uses of Databases

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

Files. Files. Files. Files. Files. File Organisation. What s it all about? What s in a file?

Overview. Introduction to Database Systems. Motivation... Motivation: how do we store lots of data?

7. Databases and Database Management Systems

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè.

Introduction. Chapter 1. Introducing the Database. Data vs. Information

Lesson 8: Introduction to Databases E-R Data Modeling

The Entity-Relationship Model

Oracle Architecture, Concepts & Facilities

2. Background on Data Management. Aspects of Data Management and an Overview of Solutions used in Engineering Applications

Overview of Database Management

2. Basic Relational Data Model

IT2304: Database Systems 1 (DBS 1)

Oracle Business Intelligence Server Administration Guide. Version December 2006

Release: 1. ICADBS502A Design a database

Databases in Organizations

Databases and DBMS. What is a Database?

Database Concepts. Database & Database Management System. Application examples. Application examples

Doing database design with MySQL

Tutorial on Relational Database Design

Introduction to normalization. Introduction to normalization

Chapter 1 Databases and Database Users

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Topics. Database Essential Concepts. What s s a Good Database System? Using Database Software. Using Database Software. Types of Database Programs

Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types

Chapter 1. Database Systems. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel

CSE 132A. Database Systems Principles

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Study Notes for DB Design and Management Exam 1 (Chapters 1-2-3) record A collection of related (logically connected) fields.

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

Ursuline College Accelerated Program

DATABASE INTRODUCTION

Database Management. Technology Briefing. Modern organizations are said to be drowning in data but starving for information p.

Chapter 14: Databases and Database Management Systems

10. Creating and Maintaining Geographic Databases. Learning objectives. Keywords and concepts. Overview. Definitions

5.5 Copyright 2011 Pearson Education, Inc. publishing as Prentice Hall. Figure 5-2

Introduction to Database Systems. Chapter 1 Introduction. Chapter 1 Introduction

Transcription:

Relational Database Basics Review IT 4153 Advanced Database J.G. Zheng Spring 2012

Overview Database approach Database system Relational model Database development 2

File Processing Approaches Based on file systems Data are record in various types of files organized in folders (directories) File types Sequential data files Name-value pair files Spreadsheets or list files XML files 3

Files Processing Problems Loose and weak structure (a general structure may be imposed but not enforced) Difficult to handle complex data Low data quality: redundancy and inconsistency No central management Difficult to maintain and share in multi-user environments Limited security Not scalable: cannot handle large quantity of data efficiently Lack of specialized and standardized data management and processing capabilities 4

Database Approach Database is a structured and self-describing collection of data Structured: structures and rules are consistently and rigorously defined and enforced (integrity) Self-describing: the description of data (data definition, or metadata) is contained within the database Centralized management Managed and controlled by specialized programs, called database management systems (DBMS), which provides rich data management functionalities 5

Advantages and Disadvantages Advantages High data quality, integrity, and consistency Reduced data redundancy and application maintenance Easy access and sharing Scalable Improved security Specialized and productive management tool Major disadvantages Increased complexity Greater impact of failure 6

Database System A database system is a complete information system Basic layers of a database system 7

Database A database is a storage place for data What s in the database? Data (tables) Metadata Other data and structures 8

Metadata Metadata are data that describe data (data definitions) Metadata Defines Data Metadata is always a part of a database. Metadata defines tables, columns, data types, keys (relationships), constraints, etc. 9

Database Management System DBMS serves as a controller (gatekeeper) for databases DBMS provides common functionalities and interfaces for managing and controlling database activities, such as creating and maintaining databases and other structures reading, updating and deleting data data backup and recovery controlling concurrency, consistency, and enforcing other rules providing security 10

Enterprise Database System Sales Management Applications SQL (Structured Query Language) is the standard relational database command language used by DBMS. Business Intelligence Applications E-Commerce Applications 11

Relational Model Edgar F. Codd (IBM), 1970 One sentence to summarize relational database model (extremely brief): Data are organized in relations (tables), which are linked by keys (constraints) 12

Relation A relation is a two-dimensional table that has some specific characteristics: 1. The table consist of rows and columns 2. Rows contain data about entity instances 3. All values in a row describes the same entity instance 4. Columns contain data about attributes of the entity 5. All values in a column are of the same kind 6. Each row is distinct 7. A cell of the table holds a single value 8. Each column has a unique name 9. The order of the rows is unimportant 10. The order of the columns is unimportant 13

Terminology Contrast Database industry Table Row Column Academic Relation Tuple Attribute File processing File Record Field 14

Key A key is one or more columns of a relation that is used to uniquely identify a record Primary key Candidate key Alternate key Surrogate key Composite key Foreign key 15

Candidate Key/Primary Key Candidate key The minimum set of column(s) that uniquely identifies a single record (row) Each value in this column is unique in this relation Primary key Primary key is a column/attribute that is used to uniquely identify a record Is one of the candidate keys chosen to be the identifying key; others become alternate keys Each value of this key column uniquely identifies a single record (row) There is only ONE primary key for a table 16

Composite Key Composite key A composite key contains two or more attributes (columns) All keys can be composite keys Example: FirstName + LastName FirstName + LastName + BirthDate FirstName + LastName + BirthDate + BirthCity 17

Artificial Primary Key/Surrogate Key Sometimes it is difficult to find a natural attribute as a primary key, or it is difficult to use a composite key. A column is created arbitrarily and assign each record a unique number/id Product Number, Product Id, Movie Id, Actor Id, etc. Surrogate Primary Key: the id does not really mean anything. Often such IDs will be generated by database systems. 18

PK Selection Guidelines Do not use a field whose value is frequently changed as PK Look for single-attribute PK first If a PK contains more than 3 columns, consider a surrogate key Don t be limited to sample data; think beyond and consider possible scenarios and requirements 19

Relationship and Foreign Key (FK) Relationship is how tables (relations) are linked It is defined by the foreign key (FK) constraint A foreign key references a primary key (or any other unique keys) in another table This pair of keys are of the same kind (may be of different name) 20

Relationship and FK Example Primary Key (PK) Primary Key (PK) Foreign Key 1 (FK 1) Composite primary key: OrderNumber+SKU Foreign Key 2 (FK 2) 21

Foreign Key Example Department DeptID DeptName Location Primary Key Foreign Key Employee EmpID EmpName Department Primary Key and Foreign Key are of the same type (string, number, etc.) and length, but they do not necessarily have the same name. 22

Relationship in SQL Server Database Primary Key (PK) is indicated by a key symbol Note: in SQL Server, the line ends do not exactly point to the right column Foreign Key (FK) side is indicated by a infinite loop symbol. 23

Schema in Relational Databases Schema is the structure described in a formal language supported by the database management system (DBMS) It s a kind of metadata Relational database schema commonly defines Tables: name, primary key Columns: name, data type, size, value range, etc. Constraints: all kinds of keys Other structures 24

Database Development Plan Analysis Design Requirements Analysis Conceptual Design Logical Design Physical Design 3 Level Database Design Implementation: creating the database using a DBMS software Maintenance 25

Requirement Analysis Requirements describe what a system should be or do Functional vs. non-functional requirements Process vs. data requirements Issues in requirements engineering How to obtain requirements? How to record/represent requirements? 26

3 Level Database Design Creating an conceptual data model and associated data dictionary Conceptual Design Transforming the conceptual model to a logical data model which applies to a general type of data management approaches. Logical Design Creating a physical data model based on a specific DBMS product. Physical Design 27

Data Model A model is a general and abstract representation of something more complicated and detailed Process model Data model UML model A data model is a general and abstract representation of the structure of data Conceptual Logical Physical 28

Conceptual Modeling/Design Conceptual data model A high level representation of the reality based on human understanding It is abstract, simple, yet meaningful Not tied to any computing technologies Examples Entity Relationship Diagram (ERD) Semantic data model Concept diagram Data structure diagram 29

Logical Modeling/Design Logical data model A specific data structure that organizes data following specific rules (logics); for example, mathematical or computing rules It is more detailed, structured, actionable and has specific rules Yet it is implementation (product) independent Examples Relational data model Object-oriented data model Hierarchical data model (XML) 30

Physical Modeling/Design Physical data model Based on a specific implementation (a software product), which implements the corresponding logical data model and adds more operational details In database design More details are added to relational models that directly support the creation of the database in a certain database product DBMS product specific: data types, storage methods, DBMS capability, proprietary functions and rules, etc. Including lower level details and other DBMS structure, such as index, partition, cluster, storage, etc. 31

A Practical Process for Relational Database Design based on the Three-Data Model Approach Analyzing requirements Create an Entity Relationship Diagram (ERD) and associated data dictionary to represent the reality and capture business data requirements Conceptual Design Transform ERD to the relational model: tables, keys (constraints), etc. Logical Design Normalize/de-normalize tables if necessary Create the database and other supporting structures based on a specific DBMS Physical Design Generate data definition scripts 32

Summary Key concepts and terms File processing vs. database processing Database features, advantages, and disadvantages Database, database system, DBMS, database application Data, metadata, database schema Oracle, SQL Server, DB2, MySQL Relation (and its 10 features) Row, column, record, field, attribute Key, primary key, candidate key, surrogate key, composite key, foreign key SQL Key concepts Three data models and examples Conceptual, logical, physical ERD Relational model Three-level database design method Conceptual design Logical design Physical design Key skills Identify/design the primary key, composite primary key, candidate keys, and foreign keys of a given table/relation. 33

Good Readings and Resources Database system http://en.wikipedia.org/wiki/database http://en.wikipedia.org/wiki/database_management_system Relational model http://en.wikipedia.org/wiki/relational_model The database development life cycle http://openlearn.open.ac.uk/mod/oucontent/view.php?id=399373 Data modeling 101 http://www.agiledata.org/essays/datamodeling101.html Data model http://en.wikipedia.org/wiki/data_model The database report: latest database industry news http://www.tdan.com/featured_columns/db_report.php 34