A Very Brief Introduction to Relational Databases

Slides:



Advertisements
Similar presentations
BIM211 – Visual Programming Database Operations 1.
Advertisements

A Brief Introduction to Relational Databases
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Attribute databases. GIS Definition Diagram Output Query Results.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Introduction to database systems
CIS 103 — Applied Computer Technology Last Edited: September 17, 2010 by C.Herbert Using Database Management Systems.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
IST 210: ORGANIZATION OF DATA Chapter 1. Getting Started IST210 1.
CSC 2720 Building Web Applications Database and SQL.
Instructor: Dema Alorini Database Fundamentals IS 422 Section: 7|1.
Component 4: Introduction to Information and Computer Science Unit 6a Databases and SQL.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
Chapter 10 Database Management. Data and Information How are data and information related? p Fig Next processing data stored on disk Step.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
Chapter 1. Getting Started IST 210: Organization of Data IST2101.
Introduction to Database Programming with Python Gary Stewart
1 SQL SERVER 2005 Express CE-105 SPRING 2007 Engr. Faisal ur Rehman.
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
Prepared By: Bobby Wan Microsoft Access Prepared By: Bobby Wan
Databases.
CS320 Web and Internet Programming SQL and MySQL
Databases Key Revision Points.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Databases Chapter 16.
Information Systems Today: Managing in the Digital World
Relational Databases.
CIS 155 Table Relationship
Access Creating a Database
Chapter 4 Relational Databases
Access Creating a Database
Microsoft Access 2003 Illustrated Complete
Database Management  .
RELATIONAL DATABASE MODEL
Translation of ER-diagram into Relational Schema
Databases and Information Management
What is a Database and Why Use One?
Index Structure.
Relational Databases The Relational Model.
Relational Databases The Relational Model.
PHPMyAdmin.
PHP and MySQL.
What is a Database? A collection of data organized in a manner that allows access, retrieval, and use of that data.
Structured Query Language
Database Management Concepts
CMPT 354: Database System I
Databases and Information Management
Introduction To Databases GCSE Computer Science
Access: Access Basics Participation Project
Database Design Hacettepe University
Chengyu Sun California State University, Los Angeles
Introduction to Access
CS3220 Web and Internet Programming SQL and MySQL
Introduction To Databases GCSE Computer Science
CMPE/SE 131 Software Engineering March 9 Class Meeting
DATABASES WHAT IS A DATABASE?
The ultimate in data organization
CS3220 Web and Internet Programming SQL and MySQL
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Microsoft Access Date.
CSC 453 Database Technologies
Database 2.
Presentation transcript:

A Very Brief Introduction to Relational Databases Chuck Cusack Spring 2004

Course Roster File #1 Consider an instructor who wishes to store a list of his courses and students enrolled in those courses. Below is how he might store the information in a file There are several problems with this: Some information is repeated several times Some entries are incomplete It is hard to see who is in what course It is hard to see how many students or courses there are Updating student information can be problematic because of repeats Course CourseName When StudentID Name Major CSCE156 Intro to Computer Science II Spring 2004 111111111 Mary Johnson Computer Engineering CSCE155 Intro to Computer Science I Fall 2003 505555555 Phil Philson Art CSCE310 Data Structures and Algorithms 543210987 John Cusack Theatre 123456789 John Smith Computer Science

Course Roster File #2 He could store the information so it is a little easier to get rosters for each course as shown below There are still several problems with this format Student records are still repeated, making updating tough It is hard to see how many courses a student is enrolled for It is also hard to see how many students there total CSCE156 Intro to Computer Science II Spring 2004 1: 111111111, Mary Johnson, Computer Engineering CSCE155 Intro to Computer Science I Fall 2003 1: 505555555, Phil Philson, Art CSCE310 Data Structures and Algorithms Fall 2003 1: 123456789, John Smith, Computer Science 2: 111111111, Mary Johnson, Computer Engineering CSCE310 Data Structures and Algorithms Spring 2004 Not Enrolled in any courses 1: 543210987, John Cusack, Theatre

Course Roster: A Better Solution It turns out that no matter how you store the information in a simple text file, there will be problems. The bottom line is that sometimes storing things in a simple text file is not the best way A better solution would use a database to store the information. As we will see, the benefits will include Duplication is minimized Updating information is easier Getting information like lists for each course or number of courses or roster for students Getting more complex information can also be easily accomplished

Course Roster Database One way to store the same information in a database is to use the following tables We will discuss the design aspect of the database later Enrollment EnrollID StudentID CourseID 1 111111111 2 3 123456789 4 505555555 Students StudentID FirstName LastName Major 123456789 John Smith Computer Science 111111111 Mary Johnson Computer Engineering 505555555 Phil Philson Art 543210987 Cusack Theatre Courses CourseID Department CourseNumber CourseName Semester Year 1 CSCE 156 Introduction to Computer Science II Spring 2004 2 155 Introduction to Computer Science I Fall 2003 3 310 Data Structures and Algorithms 4

Database Terminology Relational databases store information in a set of tables Each table has a unique name which describes what type of information is stored in the table Each column (field, attribute) of the table stores a single piece of information Each row (record) of the table represents one object One or more columns in each table are the primary key, which uniquely identifies each record, and is indicated by underlining the attribute name Enrollment EnrollID StudentID CourseID 1 111111111 2 3 123456789 4 505555555 Students StudentID FirstName LastName Major 123456789 John Smith Computer Science 111111111 Mary Johnson Computer Engineering 505555555 Phil Philson Art 543210987 Cusack Theatre

Relationships If two entries in different tables are related in some way, foreign keys are used A foreign key is a reference to the primary key in another table We will discuss relationships in more detail later Enrollment EnrollID StudentID CourseID 1 111111111 2 3 123456789 4 505555555 Students StudentID FirstName LastName Major 123456789 John Smith Computer Science 111111111 Mary Johnson Computer Engineering 505555555 Phil Philson Art 543210987 Cusack Theatre Courses CourseID Department CourseNumber CourseName Semester Year 1 CSCE 156 Introduction to Computer Science II Spring 2004 2 155 Introduction to Computer Science I Fall 2003 3 310 Data Structures and Algorithms 4

Database Properties The order of the rows and columns is not meaningful Rows can easily be added and deleted Each attribute has a type, like integer or character or string, and can only store entries of that type Every row in a table must have a unique primary key The value of a foreign key must correspond to the value of some primary key There are often other constraints on the values of attributes, such as The value cannot be NULL. In other words, there has to be a value Enrollment EnrollID StudentID CourseID 1 111111111 2 3 123456789 4 505555555 Students StudentID FirstName LastName Major 123456789 John Smith Computer Science 111111111 Mary Johnson Computer Engineering 505555555 Phil Philson Art 543210987 Cusack Theatre

Database Design Each table should store a specific type of information Each attribute should be a single piece of information For instance, first names and last names, street number and street name, department and course number should be stored as two attributes, not one. If a column exists for course description, it might consist of several sentences describing the course. This is still a single “thing,” so it is O.K. Information should (almost) never be duplicated Results from computations should not be stored in a table Enrollment EnrollID StudentID CourseID 1 111111111 2 3 123456789 4 505555555 Students StudentID FirstName LastName Major 123456789 John Smith Computer Science 111111111 Mary Johnson Computer Engineering 505555555 Phil Philson Art 543210987 Cusack Theatre

Accessing Databases To access a database, you need a database management system (DBMS), like MySQL or Microsoft Access Most DBMSs use SQL (Structured Query Languages) as the interface language SQL is a (mostly) standard language that allows the user to Create, update, and delete tables Add, update, and delete single entries Query the database to extract information The details of SQL are the subject of another set of notes

What’s Next? Before you can do anything useful with databases, you certainly need more details than this. Several sets of notes follow this that will give you more information about the following related topics Given the description of the requirements of a simple software system, develop a database to store the data Create, update, and query databases with SQL Connect to a database from programming languages like PHP and Java

References Hugh E. Williams & David Lane, Web Database Applications with PHP and MySQL, O’Reilly, 2002