Introduction to Databases

Similar documents
Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

File Processing Approaches

7) To be considered a composite key, a key must contain at least two attributes. Answer: TRUE

Objectives Definition iti of terms List five properties of relations State two properties of candidate keys Define first, second, and third normal for

SQL Server 2008 Tutorial 3: Database Creation

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

Normalization in DBMS

Data, Information, and Databases

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

Handout 4. Logical Database Modeling, Part 1: Relational Data Model. Transforming EER model to Relational.

Vendor: CIW. Exam Code: 1D Exam Name: CIW v5 Database Design Specialist. Version: Demo

Database Logical Design

Introduction to Databases

Modern Systems Analysis and Design Sixth Edition

Database Concepts. Sixth Edition. David M. Kroenke David J. Auer. Instructor s Manual. Prepared by David J. Auer APPENDIX B

TIM 50 - Business Information Systems

Modern Systems Analysis and Design

Figure 1-1a Data in context. Context helps users understand data

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Working with Databases and Java

Introduction to Computer Applications. CISY 1225 Chapter 10. Zahoor Khan, PhD

Introduction to MS Access: creating tables, keys, and relationships

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

Cartesian Product and the Join Operations. Copyright 2008, Oracle. All rights reserved.

Database Logical Design

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation

The Relational Model Constraints and SQL DDL

Database: Introduction

Data about data is database Select correct option: True False Partially True None of the Above

IT360: Applied Database Systems. Slide Set: #2. Relational Model (Chapter 3 Kroenke) The relational model Relational model terminology

ITP 140 Mobile Technologies. Databases Client/Server

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Chapter 2 Introduction to Relational Models

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Relational Database Components

Chapter 1 SQL and Data

Database Applications (15-415)

Course Title: Introduction to Database Management System Course Code: CSIT116 Course Level: UG Course Credits:04 L T P/ S SW/F W

DBM/500 COURSE NOTES

DAVID M. KROENKE AND DAVID J. AUER. Fundamentals, Design, and Implementation

Database in Everyday Life by Assoc. Prof. Dr. Churee Techawut adapted into English by Dr. Prakarn Unachak

Database Concepts. Online Appendix A Getting Started with Microsoft SQL Server 2014 Express. 7th Edition. David M. Kroenke David J.

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 1

DBMS. Relational Model. Module Title?

Introduction to Database Systems

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

CS44800 Practice Project SQL Spring 2019

1D0-541_formatted. Number: Passing Score: 800 Time Limit: 120 min File Version: 1.

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Chapter 4. The Relational Model

3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

DATABASE DEVELOPMENT (H4)

A bit of Databases history

Distributed Database Systems By Syed Bakhtawar Shah Abid Lecturer in Computer Science

CS211 Lecture: Database Design

MySQL Introduction. By Prof. B.A.Khivsara

COPYRIGHTED MATERIAL. Databases

Test Bank Database Processing Fundamentals Designand Implementation 14th Edition Kroenke

ORACLE DATABASE 12C INTRODUCTION

1D D0-541 CIW v5 Database Design Specialist Version 1.7

Introduction to Relational Database Concepts. Copyright 2011, Oracle. All rights reserved.

Database Systems Relational Model. A.R. Hurson 323 CS Building

Objects Meet Relations: On the Transparent Management of Persistent Objects

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

The Relational Data Model. Data Model

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

Visit for more.

Brief History of SQL. Relational Database Management System. Popular Databases

Inf 202 Introduction to Data and Databases (Spring 2011)

Entity Attribute STUDENT TABLE tuples single domain

namib I A U n IVERS I TY

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

These are all examples of relatively simple databases. All of the information is textual or referential.

Oracle and MySQL. A Practical Approach

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

OBJECTIVES DEFINITIONS CHAPTER 1: THE DATABASE ENVIRONMENT AND DEVELOPMENT PROCESS. Figure 1-1a Data in context

Inputs. Decisions. Leads to

8) A top-to-bottom relationship among the items in a database is established by a

22/01/2018. Data Management. Data Entities, Attributes, and Items. Data Entities, Attributes, and Items. ACS-1803 Introduction to Information Systems

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

CISC 3140 (CIS 20.2) Design & Implementation of Software Application II

Introduction to Data Management. Lecture #4 (E-R Relational Translation)

ACS-1803 Introduction to Information Systems. Instructor: Kerry Augustine. Data Management. Lecture Outline 2, Part 2

Database Management Systems,

Data Management Lecture Outline 2 Part 2. Instructor: Trevor Nadeau

Chapter 6. Foundations of Business Intelligence: Databases and Information Management VIDEO CASES

Database Management Systems,

Unit 3 : Relational Database Design

Physical Design of Relational Databases

Full file at

Chapter. Relational Database Concepts COPYRIGHTED MATERIAL

Chapter 1: Introduction

Chapter 6 VIDEO CASES

Consistency The DBMS must ensure the database will always be in a consistent state. Whenever data is modified, the database will change from one

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

Relation Databases. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, PGT CS II Shift Jaipur

Transcription:

Informática y Comunicaciones Chapter 6 Introduction to Databases KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright 2013 Pearson Education, Inc. Publishing as Prentice Hall Introduction to Databases 6-1

Chapter 6: outline 6.1 Getting started 6.2 Entity and Relations Introduction to Databases 6-2

Purpose of a Database The purpose of a database is to keep track of things. Unlike a list or spreadsheet, a database may store information that is more complicated than a simple list. Introduction to Databases 6-3

Problems with Lists: Redundancy In a list, each row is intended to stand on its own. As a result, the same information may be entered several times. For Example: A list of Projects may include the Project Manager s Name, ID, and Phone Extension. If a particular person is managing 10 projects, his/her information would have to be entered 10 times. Introduction to Databases 6-4

Problems with Lists: Multiple Themes In a list, each row may contain information on more than one theme. As a result, needed information may appear in the lists only if information on other themes is also present. For Example: A list of Projects may include Project Manager information (Name, ID, and Phone Extension) and Project information (Name, ID, StartDate, Budget) in the same row. Introduction to Databases 6-5

List Modification Issues Redundancy and multiple themes create modification problems: Deletion problems Update problems Insertion problems Introduction to Databases 6-6

List Modification Issues (Cont d) Introduction to Databases 6-7

Addressing Information Complexities Relational databases are designed to address many of the information complexity issues. Introduction to Databases 6-8

Relational Databases A relational database stores information in tables. Each informational topic is stored in its own table. In essence, a relational database will breakup a list into several parts one part for each theme in the list. A Project List would be divided into a CUSTOMER Table, a PROJECT Table, and a PROJECT_MANAGER Table. Introduction to Databases 6-9

Putting the Pieces Back Together In our relational database, we broke our list into several tables. Somehow the tables must be joined back together. In a relational database, tables are joined together using the value of the data. If a PROJECT has a CUSTOMER, the Customer_ID is stored as a column in the PROJECT table. The value stored in this column can be used to retrieve specific customer information from the CUSTOMER table. Introduction to Databases 6-10

Sounds Like More Work, Not Less A relational database is more complicated than a list. However, a relational database minimizes data redundancy, preserves complex relationships among topics, and allows for partial data. Furthermore, a relational database provides a solid foundation for user forms and reports. Introduction to Databases 6-11

Relational Database Example Introduction to Databases 6-12

A Relational Database Solves the Problems of Lists Introduction to Databases 6-13

The Department, Advisor and Student Tables Introduction to Databases 6-14

The Art Course Database Tables Introduction to Databases 6-15

The Project Equipment Tables Introduction to Databases 6-16

Structured Query Language (SQL) Structured Query Language (SQL) is an international standard for creating, processing and querying databases and their tables. Many database applications use SQL to retrieve, format, report, insert, delete, and/or modify data for users. Introduction to Databases 6-17

SQL Example We can use SQL to combine the data in the three tables in the Art Course Database to recreate the original list structure of the data. We do this by using an SQL SELECT statement. Introduction to Databases 6-18

SQL Example (Cont d) SELECT CUSTOMER.CustomerLastName, CUSTOMER.CustomerFirstName, CUSTOMER.Phone, COURSE.CourseDate, ENROLLMENT.AmountPaid, COURSE.Course, COURSE.Fee FROM CUSTOMER, ENROLLMENT, COURSE WHERE CUSTOMER.CustomerNumber = ENROLLMENT.CustomerNumber AND COURSE.CourseNumber = ENROLLMENT.CourseNumber; Introduction to Databases 6-19

SQL Example Results Introduction to Databases 6-20

Database Systems The four components of a database system are: Users Database Application Database Management System (DBMS) Database Introduction to Databases 6-21

Components of a Database System Introduction to Databases 6-22

Users A user of a database system will use a database application to track things; use forms to enter, read, delete and query data; and produce reports. Introduction to Databases 6-23

The Database A database is a self-describing collection of related records. The database itself contains the definition of its structure. Metadata is data describing the structure of the database data. Tables within a relational database are related to each other. Introduction to Databases 6-24

Example Database Metadata: A Relationship Diagram Introduction to Databases 6-25

Database Contents Introduction to Databases 6-26

Database Management System (DBMS) A database management system (DBMS) serves as an intermediary between database applications and the database. The DBMS manages and controls database activities. The DBMS creates, processes and administers the databases it controls. Introduction to Databases 6-27

Functions of a DBMS Create databases Create tables Create supporting structures Read database data Modify database data (insert, update, and delete) Maintain database structures Enforce rules Control concurrency Provide security Perform backup and recovery Introduction to Databases 6-28

Referential Integrity Constraints The DBMS will enforce many constraints. Referential integrity constraints ensure that the values of a column in one table are valid based on the values in another table. If a 5 was entered as a CustomerID in the PROJECT table, a Customer having a CustomerID value of 5 must exist in the CUSTOMER table. Introduction to Databases 6-29

Database Applications A database application is a set of one or more computer programs that serves as an intermediary between the user and the DBMS. Introduction to Databases 6-30

Functions of Database Applications Create and process forms Process user queries Create and process reports Execute application logic Control database applications Introduction to Databases 6-31

Database Applications: Example Data Entry Form Introduction to Databases 6-32

Database Applications: Example Query Introduction to Databases 6-33

Database Applications: Example Report Introduction to Databases 6-34

Personal Database Systems Personal database systems typically have one application. have only a few tables. are simple in design. involve only one computer. support one user at a time. Introduction to Databases 6-35

Personal Database Systems Introduction to Databases 6-36

Personal Database Systems: An SQL Query in Microsoft Access Introduction to Databases 6-37

Personal Database Systems: SQL Query Results in Microsoft Access Introduction to Databases 6-38

Enterprise-Class Database Systems Enterprise-Class database systems typically: support several users simultaneously, include more than one application, involve multiple computers, are complex in design, have many tables, and have many databases. Introduction to Databases 6-39

Organizational Database Systems Introduction to Databases 6-40

Commercial DBMS Products Example of Desktop DBMS Products Microsoft Access Examples of Organizational DBMS Products Microsoft s SQL Server Oracle s Oracle Sun Microsystem s MySQL IBM s DB2 Introduction to Databases 6-41

Chapter 6: outline 6.1 Getting started 6.2 Entity and Relations Introduction to Databases 6-42

Entity An entity is something of importance to a user that needs to be represented in a database. An entity represents one theme or topic. In an entity-relationship model, entities are restricted to things that can be represented by a single table. Introduction to Databases 6-43

Relation A relation is a two-dimensional table that has specific characteristics. The table dimensions, like a matrix, consist of rows and columns. Introduction to Databases 6-44

Characteristics of a Relation 1. Rows contain data about an entity. 2. Columns contain data about attributes of the entity. 3. Cells of the table hold a single value. 4. All entries in a column are of the same kind. 5. Each column has a unique name. 6. The order of the columns is unimportant. 7. The order of the rows is unimportant. 8. No two rows may be identical. Introduction to Databases 6-45

A Sample Relation EmployeeNumber FirstName LastName 100 Mary Abernathy 101 Jerry Cadley 104 Alex Copley 107 Megan Jackson Introduction to Databases 6-46

A Nonrelation Example Cells of the table hold multiple values EmployeeNumber Phone LastName 100 335-6421, Abernathy 454-9744 101 215-7789 Cadley 104 610-9850 Copley 107 299-9090 Jackson Introduction to Databases 6-47

Example of a Nonrelational Table No two rows may be identical EmployeeNumber Phone LastName 100 335-6421 Abernathy 101 215-7789 Cadley 104 610-9850 Copley 100 335-6421 Abernathy 107 299-9090 Jackson Introduction to Databases 6-48

Terminology Synonyms Table Row Column File Record Field Relation Tuple Attribute Introduction to Databases 6-49

A Key A key is one (or more) column(s) of a relation that is (are) used to identify a row. Introduction to Databases 6-50

Uniqueness of Keys Unique Key Nonunique Key Data value is unique for each row. Consequently, the key will uniquely identify a row. Data value may be shared among several rows. Consequently, the key will identify a set of rows. Introduction to Databases 6-51

A Composite Key A composite key is a key that contains two or more attributes. For a key to be unique, it must often become a composite key. Introduction to Databases 6-52

Composite Key Characteristics To identify a family member, you need to know a FamilyID, a FirstName, and a Suffix (e.g., Jr.). The composite key is: (FamilyID, FirstName, Suffix). One needs to know the value of all three columns to uniquely identify an individual. Introduction to Databases 6-53

A Candidate Key A candidate key is called candidate because it is a candidate to become the primary key. A candidate key is a unique key. Introduction to Databases 6-54

A Primary Key A primary key is a candidate key chosen to be the main key for the relation. If you know the value of the primary key, you will be able to uniquely identify a single row. Introduction to Databases 6-55

A Surrogate Key A surrogate key is a unique, numeric value that is added to a relation to serve as the primary key. Surrogate key values have no meaning to users and are usually hidden on forms, queries, and reports. A surrogate key is often used in place of a composite primary key. Introduction to Databases 6-56

Surrogate Key Example If the Family Member primary key is FamilyID, FirstName, Suffix, it would be easier to append and use a surrogate key of FamMemberID. FamilyID, FirstName and Suffix remain in the relation. Introduction to Databases 6-57

Relationships Between Tables A table may be related to other tables. For example An Employee works in a Department A Manager controls a Project Introduction to Databases 6-58

A Foreign Key To preserve relationships, you may need to create a foreign key. A foreign key is a primary key from one table placed into another table. The key is called a foreign key in the table that received the key. Introduction to Databases 6-59

Foreign Key Example I Project ProjID ProjName MgrID Primary Key Foreign Key Manager MgrID MgrName Introduction to Databases 6-60

Foreign Key Example II Department DeptID DeptName Location Primary Key Foreign Key Employee EmpID DeptID EmpName Introduction to Databases 6-61

Referential Integrity Referential integrity states that every value of a foreign key must match a value of an existing primary key. Example (see previous slide): If EmpID = 4 in EMPLOYEE has a DeptID = 7 (a foreign key), a Department with DeptID = 7 must exist in DEPARTMENT. The primary key value must exist before the foreign key value is entered. Introduction to Databases 6-62

Referential Integrity (Cont d) Another perspective The value of the Foreign Key EmployeeID in EQUIPMENT must exist in The values of the Primary Key EmployeeID in EMPLOYEE Introduction to Databases 6-63

The Null Value A Null value means that no data was entered. This is different from a zero, space character, or tab character. Introduction to Databases 6-64

The Problem of Null Values A Null is often ambiguous. It could mean The column value is not appropriate for the specific row. The column value is not decided. The column value is unknown. Each may have entirely different implications. Introduction to Databases 6-65

Functional Dependency Functional Dependency A relationship between attributes in which one attribute (or group of attributes) determines the value of another attribute in the same table Illustration The price of one cookie can determine the price of a box of 12 cookies. (CookiePrice, Qty) BoxPrice Introduction to Databases 6-66

Determinants The attribute (or attributes) that we use as the starting point (the variable on the left side of the equation) is called a determinant. (CookiePrice, Qty) BoxPrice Determinant Introduction to Databases 6-67

Candidate/Primary Keys and Functional Dependency By definition A candidate key of a relation will functionally determine all other attributes in the row. Likewise, by definition A primary key of a relation will functionally determine all other attributes in the row. Introduction to Databases 6-68

Primary Key and Functional Dependency Example (EmployeeID) (EmpLastName, EmpPhone) (ProjectID) (ProjectName, StartDate) Introduction to Databases 6-69

Chapter 6: summary basic concepts relational databases SQL entities relations keys Introduction to Databases 6-70