Introduction to Database Systems

Similar documents
Introduction to Database Systems

E-R Diagram Example. E-R Diagram for Everfail. Translating E-R Diagrams into Relations. The Complete Relations for EverFail. Car. Customer.

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

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

Database Management Systems,

Computing for Medicine (C4M) Seminar 3: Databases. Michelle Craig Associate Professor, Teaching Stream

SQL Data Definition and Data Manipulation Languages (DDL and DML)

Simple SQL. Peter Y. Wu. Dept of Computer and Information Systems Robert Morris University

Chapter 3: Introduction to SQL

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

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

Working with Databases and Java

Introduction to Databases

Relational model and basic SQL

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

HKTA TANG HIN MEMORIAL SECONDARY SCHOOL SECONDARY 3 COMPUTER LITERACY. Name: ( ) Class: Date: Databases and Microsoft Access

Relational databases and SQL

Basic SQL. Basic SQL. Basic SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

CSCB20 Week 4. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

Database Management Systems,

COMM 391. Objectives. Introduction to Microsoft Access. What is in an Access database file? Introduction to Microsoft Access 2010

CSCB20 Week 3. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

Handout 6 CS-605 Spring 18 Page 1 of 7. Handout 6. Physical Database Modeling

CGS 3066: Spring 2017 SQL Reference

SQL Data Definition Language: Create and Change the Database Ray Lockwood

CS143: Relational Model

Chapter 3: Introduction to SQL

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

Database Logical Design

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

Normalization in DBMS

Database: Introduction

COGS 121 HCI Programming Studio. Week 03 - Tech Lecture

COMP 430 Intro. to Database Systems

Introduction to SQL Server 2005/2008 and Transact SQL

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Database Logical Design

MySQL Creating a Database Lecture 3

Data types String data types Numeric data types Date, time, and timestamp data types XML data type Large object data types ROWID data type

Database Technology Introduction. Heiko Paulheim

QQ Group

DATABASE PART 2. Components and Functions

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

Introduction. Who wants to study databases?

King Fahd University of Petroleum and Minerals

CMPT 354: Database System I. Lecture 2. Relational Model

The SQL data-definition language (DDL) allows defining :

Principles of Data Management

Chapter 1: Introduction

Database Management Systems MIT Introduction By S. Sabraz Nawaz

Chapter 9: Working with MySQL

Course Logistics & Chapter 1 Introduction

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #2: The Relational Model and Relational Algebra

CS425 Fall 2016 Boris Glavic Chapter 1: Introduction

A Flat file database. Problems with a flat file database (data redundancy)

1 INTRODUCTION TO EASIK 2 TABLE OF CONTENTS

Database and table creation

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

CSC 355 Database Systems

Database Management Systems MIT Lesson 01 - Introduction By S. Sabraz Nawaz

Accounting Information Systems, 2e (Kay/Ovlia) Chapter 2 Accounting Databases. Objective 1

Introduction to Databases and SQL

DB2 MOCK TEST DB2 MOCK TEST I

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017

A practical introduction to database design

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

COMP 430 Intro. to Database Systems. Encapsulating SQL code

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

Explain in words what this relational algebra expression returns:

Chapter 1: Introduction

SQL: Data Definition Language

UNIT 4 DATABASE SYSTEM CATALOGUE

SQL Server 2008 Tutorial 3: Database Creation

CS2300: File Structures and Introduction to Database Systems

MIT Database Management Systems Lesson 01: Introduction

Review. Objec,ves. Example Students Table. Database Overview 3/8/17. PostgreSQL DB Elas,csearch. Databases

Data, Databases, and DBMSs

File Processing Approaches

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Today's Party. Example Database. Faloutsos/Pavlo CMU /615

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.)

CHAPTER 11. Data Normalization

SQL OVERVIEW. CS121: Relational Databases Fall 2017 Lecture 4

Introduction To Computers

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

Rapid Application Development

COMP 430 Intro. to Database Systems

Normalization (1) IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

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

Lecture 3: SQL Part II

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

12 Rules Defined by Dr.Codd for a Relational Database Management System

Introduction to Data Management. Lecture #6 E-Rà Relational Mapping (Cont.)

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

Transcription:

Introduction to Database Systems Introduction to Database Systems So, what is a database, anyway? An integrated, self-describing collection of data about related sets of things and the relationships among them 1

If you burned down all our plants, and we just kept our people and our information files, we should soon be as strong as ever. Thomas Watson, Jr. Former chairman of IBM Visual Basic and Database Management Systems Simple text files as shown in chapter 9 are: Fine for small amounts of data But impractical for large amounts of data Businesses must maintain huge amounts of data A database management system (DBMS) is the typical solution to the data needs of business Designed to store, retrieve, & manipulate data Visual Basic can communicate with several DBMS Tells DBMS what data to retrieve or manipulate 2

Layered Approach to Using a DBMS Applications that work with a DBMS use a layered approach VB application is topmost layer VB sends instructions to next layer, the DBMS DBMS works directly with data Programmer need not understand the physical structure of the data Just need to know how to interact with the database Why not just use the file system? Day8-21.txt 8,drive to work 9,teach class 10, Day8-22.txt 8,drive to work 9,eat donut 10, Could write programs to operate on this text file data. 3

File Storage Problems Sharing data Same data may be duplicated many times Need to write custom programs to manipulate the data (e.g search, print) As file systems become more complex, managing files gets more difficult Making changes in existing file structures is important and difficult. Security, data integrity (redundancy, inconsistency, anomalies) features are difficult to implement and are lacking. File Storage Problems - Dependence Structural Dependence: A change in the file s structure requires the modification of all programs using that file. Data Dependence: A change in any file s data characteristics requires changes of all data access programs. 4

Solution: DBMS Logically related data are stored in a single data repository. The database represents a change in the way end user data are stored, accessed, and managed efficiently. Easier to eliminate most of the file system s data inconsistency, data anomalies, and data structural dependency problems. Store data structures and relationships DBMS takes care of defining all the required access paths. Disadvantages of DBMS Cost of software and implementation Higher cost of processing routine batches Increase magnitude of potential disaster Lack of database technical capability 5

Relational Database Model Introduced in the 60 s and 70 s and is the most common type of DBMS today Data elements stored in simple tables (related) General structure good for many problems Easy to understand, modify, maintain Examples: MySQL, Access, Oracle, SQL Server We will focus on relational databases using Microsoft Access in our course The Relational Model Views entities as two-dimensional tables Records are rows Attributes (fields) are columns Tables can be linked Supports one-to-many, many-to-many, and one-to-one relationships 6

Terminology Database: a collection of interrelated tables Table: a logical grouping of related data A category of people, places, or things For example, employees or departments Organized into rows and columns Field: an individual piece of data pertaining to an item, an employee name for instance Record: the complete data about a single item such as all information about an employee A record is a row of a table Database Table Each table has a primary key Uniquely identifies that row of the table Emp_Idis the primary key in this example Serves as an index to quickly retrieve the record Columns are also called fields or attributes Each column has a particular data type Row (Record) Emp_Id First_Name Last_Name Department 001234 Ignacio Fleta Accounting 002000 Christian Martin Computer Support 002122 Orville Gibson Human Resources 003400 Ben Smith Accounting 003780 Allison Chong Computer Support Column Field 7

VB and SQL Server Data Types VB data types must match table data types SQL Server and VB have similar data types SQL Type Usage Visual Basic Type Bit True/false values Boolean DateTime Dates and times Date, DateTime Decimal, Money Financial values Decimal Float Real-number values Double Int Integer values Integer Smallint Integers -32,768 to 32,767 Short Varchar(n) Variable length strings String Text Strings more than 8000 char String Choosing Column Names Define a column for each piece of data Allow plenty of space for text fields Avoid using spaces in column names For the members of an organization: Column Name Type Remarks Member_ID int Primary key First_Name varchar(40) Last_Name varchar(40) Phone varchar(30) Email varchar(50) Date_Joined smalldatetime Date only, no time values Meeings_Attended smallint Officer Yes/No True/False values 8

Issues with Redundant Data Database design minimizes redundant data In the following employee table: ID First_Name Last_Name Department 001234 Ignacio Fleta Accounting 002000 Christian Martin Computer Support 002122 Orville Gibson Human Resources 00300 Jose Ramirez Research & Devel 003400 Ben Smith Accounting 003780 Allison Chong Computer Support Same dept name appears multiple times Requires additional storage space Causes problems if misspelled What if a department needs to be renamed? Eliminating Redundant Data Create a department table Dept_ID Dept_Name Num_Employees 1 Human Resources 10 2 Accounting 5 3 Computer Support 30 4 Research & Development 15 Reference department table in employee table ID First_Name Last_Name Dept_ID 001234 Ignacio Fleta 2 002000 Christian Martin 3 002122 Orville Gibson 1 003000 Jose Ramirez 4 003400 Ben Smith 2 003780 Allison Chong 3 9

One-to-Many Relationships The previous changes created a one-to-many relationship Every employee has one and only one dept Every department has many employees DeptIDin department table is a primary key DeptIDin employee table is a foreign key One-to-many relationship exists when primary key of one table is specified as a field of another table Normalization The previous example illustrated a technique used to make complex databases more efficient called Normalization Break one large table into several smaller tables Eliminates all repeating groups in records Eliminates redundant data Another example 10

Redundant Data Student ID# Student Name Campus Address Major Phone Course ID Course Title Instructor Name A121 Joy Egbert 100 N. State Street MIS 555-7771 MIS 350 Intro. MIS Van Deventer T240C A121 Joy Egbert 100 N. State Street MIS 555-7771 MIS 372 Database Hann A121 Joy Egbert 100 N. State Street MIS 555-7771 MIS 375 Elec. Comm. Chatterjee A121 Joy Egbert 100 N. State Street MIS 555-7771 MIS 448 Strategic MIS Chatterjee A121 Joy Egbert 100 N. State Street MIS 555-7771 MIS 474 Telecomm Gilson A123 Larry Mueller 123 S. State Street MIS 555-1235 MIS 350 Intro. MIS Van Deventer T240C A123 Larry Mueller 123 S. State Street MIS 555-1235 MIS 372 Database Hann A123 Larry Mueller 123 S. State Street MIS 555-1235 MIS 375 Elec. Comm. Chatterjee A123 Larry Mueller 123 S. State Street MIS 555-1235 MIS 448 Strategic MIS Chatterjee A124 Mike Guon 125 S. Elm MGT 555-2214 MIS 350 Intro. MIS Van Deventer A124 Mike Guon 125 S. Elm MGT 555-2214 MIS 372 Database Hann A124 Mike Guon 125 S. Elm MGT 555-2214 MIS 375 Elec. Comm. Chatterjee A124 Mike Guon 125 S. Elm MGT 555-2214 MIS 474 Telecomm Gilson A126 Jackie Judson 224 S. Sixth Street MKT 555-1245 MIS 350 Intro. MIS Van Deventer A126 Jackie Judson 224 S. Sixth Street MKT 555-1245 MIS 372 Database Hann A126 Jackie Judson 224 S. Sixth Street MKT 555-1245 MIS 375 Elec. Comm. Chatterjee A126 Jackie Judson 224 S. Sixth Street MKT 555-1245 MIS 474 Telecomm Gilson........................ Instructor Location T240F T240E T240F T240C T240F T240E T240C T240F T240E... Instructor Phone 555-2222 555-2224 555-2228 555-2228 555-2226 555-2222 555-2224 555-2228 555-2228 555-2222 555-2224 555-2228 555-2226 555-2222 555-2224 555-2228 555-2226... Term... Grade A B C + A B C + B A... Normalized Data Student Table Student ID# Class Table Course ID MIS 350 MIS 372 MIS 375 MIS 448 MIS 474 Student Name...... Course Title Intro. MIS Database Elec. Comm. Strategic MIS Telecomm Campus Address Instructor Table Instructor Name Chatterjee Gilson Hann Valacich Major Phone A121 Joy Egbert 100 N. State Street MIS 555-7771 A123 Larry Mueller 123 S. State Street MIS 555-1235 A124 Mike Guon 125 S. Elm MGT 555-2214 A126 Jackie Judson 224 S. Sixth Street MKT 555-1245............... Van Deventer T240C Teaching Assignment Course ID MIS 350 MIS 372 MIS 375 MIS 448 MIS 474 Instructor Location T240E T240F Term......... Instructor Name Instructor Phone 555-2228 555-2226 555-2224 555-2223 555-2222 Van Deventer Hann Chatterjee Chatterjee Gilson Enrolled Table Student ID# A121 A121 A121 A121 A121 A123 A123 A123 A123 A124 A124 A124 A124 A126 A126 A126 A126 Course ID MIS 350 MIS 372 MIS 375 MIS 448 MIS 474 MIS 350 MIS 372 MIS 375 MIS 448 MIS 350 MIS 372 MIS 375 MIS 474 MIS 350 MIS 372 MIS 375 MIS 474 Term Grade A B C + A B C + B A............ 11

Associations Relationships among the entities in the data structures Three types One-to-one One-to-many Many-to-many Relationships set by placing primary key from one table as foreign key in another Creates acceptable redundancy Association Examples One-to-one (1:1) EMPLOYEE One-to-many (1:M) FACULTY SPOUSE ADVISEE Many-to-many ( :M) FACULTY COURSE 12

Associations Order (Order #, Order_Date, Customer) M 1 M Product(Prod #, Prod_Description, Qty) 1 Product_Order(Order #, Prod #, Customer) Foreign key Microsoft Access is Unique Provides DBMS functions Not industrial-strength, designed for: Individuals Small workgroups External application programs work with Access We will use VB.NET and the Structured Query Language (SQL) later Provides built-in tools for reporting and for application development Forms Reports Code modules using Visual Basic for Applications (VBA) which is similar to VB.NET but not the same Provides flexibility Small, simple all-in-one environment Data can be easily transferred to full-fledged DBMS 13

Introduction to Access Sample databases Northwind Included with every version of Access since 2.0 Demonstration of Access Startup Create tables Link table relationships Create queries/reports In this class you won t have to create your own databases, but I ll give you a database to work with Access 2007 Example Student ID Last Name First Name DOB Address 1 Mock Kenrick 4-18-1968 123 Somewhere Ave 2 Cue Barbie 3-21-1970 567 A Street 3 Obama Barack 8-04-1961 123 Somewhere Ave 14

Access 2007 Example CS 111 Table CS 201 Table Student ID Grade Student ID Grade 1 A 2 B 3 B 1 B 2 A 3 C 15