1 11/3/05CS360 Windows Programming Databases and Data Representation.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Database Basics I101 Summer 2006 Copyright 2004, Matt Hottell.
The Relational Model Class 2 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) (From ER to Relational)
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
CSC 2720 Building Web Applications Database and SQL.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
IST Databases and DBMSs Todd S. Bacastow January 2005.
The Relational Model These slides are based on the slides of your text book.
Relational Data Model, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 The Relational Model Chapter 3.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
Database Technical Session By: Prof. Adarsh Patel.
Introduction to SQL Steve Perry
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
Programming using C# Joins SQL Injection Stored Procedures
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
C# Programming in Depth Prof. Dr. Bertrand Meyer March 2007 – May 2007 Chair of Software Engineering Lecture 10: Database Lisa (Ling) Liu.
Visual Programing SQL Overview Section 1.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
CS453: Databases and State in Web Applications (Part 2) Prof. Tom Horton.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
1 11/8/05CS360 Windows Programming Databases and Data Representation.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Mining real world data RDBMS and SQL. Index RDBMS introduction SQL (Structured Query language)
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Database Management Systems.  Instructor: Yrd. Doç. Dr. Cengiz Örencik   Course material.
Jennifer Widom Relational Databases The Relational Model.
Chapter 3: Relational Databases
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Chapter 3 The Relational Model. Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. “Legacy.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Introduction to Database Programming with Python Gary Stewart
CPSC 603 Database Systems Lecturer: Laurie Webster II, Ph.D., P.E.
Fundamentals of DBMS Notes-1.
Database Access with SQL
Insert, Update and the rest…
Database Management  .
Database.
The Relational Model Relational Data Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Presentation transcript:

1 11/3/05CS360 Windows Programming Databases and Data Representation

2 11/3/05CS360 Windows Programming Databases and Data Representation  Database Management System (DBMS)  Provides efficient, convenient, and safe multi- user storage of and access to massive amounts of persistent data  Provides a programming interface that allows a user or program to o - Create new databases and specify their structure o - Query and modify the data  Early DBMSs were ad hoc, with no two the same  Now one approach predominates: relational databases and SQL (Structured Query Language)

3 11/3/05CS360 Windows Programming Databases  A "relation" is a table of data 1ShereenCS DougCS ChrisCS JoshCS

4 11/3/05CS360 Windows Programming Databases  The columns are known as "attributes" 1ShereenCS DougCS ChrisCS JoshCS LectID NameCourse Students

5 11/3/05CS360 Windows Programming Databases  The rows are called "tuples" 1ShereenCS DougCS ChrisCS JoshCS LectID NameCourse Students

6 11/3/05CS360 Windows Programming Databases  It is allowable for some values to be missing 1ShereenCS DougCS ChrisCS JoshCS LectID NameCourse Students

7 11/3/05CS360 Windows Programming Databases  We can add, remove, or update tuples 1ShereenCS DougCS ChrisCS JoshCS MikeCS LectID NameCourse Students

8 11/3/05CS360 Windows Programming Databases  Each attribute has an underlying domain, or data type 1ShereenCS DougCS ChrisCS JoshCS MikeCS LectID NameCourse Students int string int

9 11/3/05CS360 Windows Programming Databases  The structure of the table is referred to as its schema o Lecturers(LectID, Name, Course, Students) 1ShereenCS DougCS ChrisCS JoshCS MikeCS LectID NameCourseStudents

10 11/3/05CS360 Windows Programming Primary Key  Every table must have a primary key o No two tuples can have the same LectID o LectID cannot be null 1ShereenCS DougCS ChrisCS JoshCS MikeCS LectID NameCourseStudents

11 11/3/05CS360 Windows Programming Tables  Suppose that we want to add data about lecturers offices 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectID

12 11/3/05CS360 Windows Programming Tables  But suppose that lecturers can have more than one office.  We can’t add additional rows for the same lecturers without violating the primary key constraint, so we use another table. 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectIDBuildingRoom

13 11/3/05CS360 Windows Programming Multiple Tables  Solution: Add a new table 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectID ShereenStrain203C JoshMarsh324 JoshStrain202 DougStrain201 Building Room

14 11/3/05CS360 Windows Programming Relationships  Better to store LectID 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectID 1Strain203C 4Marsh324 4Strain202 2Strain201 Building Room LectID

15 11/3/05CS360 Windows Programming Relationships  Better to store LectID 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectID 11Strain203C 24Marsh324 34Strain202 42Strain201 Building Room LectID Foreign key Primary key

16 11/3/05CS360 Windows Programming SQL Queries  SELECT returns tuples that satisfy some condition  SELECT Name, Course FROM Lecturers WHERE Students > 15 1ShereenCS DougCS ChrisCS JoshCS MikeCS NameCourseStudentsLectID JoshCS MikeCS NameCourse

17 11/3/05CS360 Windows Programming SQL Queries  SELECT *  FROM Lecturers  WHERE Students > 15 Attributes Relations Tuples

18 11/3/05CS360 Windows Programming SQL Queries  SELECT *  FROM Lecturers  WHERE Students > 15  OR Name = ‘Shereen’

19 11/3/05CS360 Windows Programming SQL Queries  Wildcards: o % matches any number of characters o _ matches any single character o [] matches any single character in set or range o [^] matches any single character not in set or range

20 11/3/05CS360 Windows Programming Database Management Systems  Many examples of DBMSs o Oracle o SQL Server o MySQL 