LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © 2007-9 by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.

Slides:



Advertisements
Similar presentations
C6 Databases.
Advertisements

IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
The database approach to data management provides significant advantages over the traditional file-based approach Define general data management concepts.
Management Information Systems, Sixth Edition
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 10 Managing a Database.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Database Management: Getting Data Together Chapter 14.
Living in a Digital World Discovering Computers 2010.
Information Technology in Organizations
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Access Lecture 1 Database Overview and Creating Tables Create an Employee Table.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Data at the Core of the Enterprise. Objectives  Define of database systems  Introduce data modeling and SQL  Discuss emerging requirements of database.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
COMPUTING FOR BUSINESS AND ECONOMICS-III. Lecture no.6 COURSE INSTRUCTOR- Ms. Tehseen SEMESTER- Summer 2010.
Data at the Core of the Enterprise. Objectives  Define of database systems.  Introduce data modeling and SQL.  Discuss emerging requirements of database.
5.1 © 2007 by Prentice Hall 5 Chapter Foundations of Business Intelligence: Databases and Information Management.
Chapter 5 Lecture 2. Principles of Information Systems2 Objectives Understand Data definition language (DDL) and data dictionary Learn about popular DBMSs.
1 Intro to Info Tech Database Management Systems Copyright 2003 by Janson Industries This presentation can be viewed on line at:
Discovering Computers Fundamentals, 2012 Edition Your Interactive Guide to the Digital World.
Objectives Overview Define the term, database, and explain how a database interacts with data and information Define the term, data integrity, and describe.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Chapter 6: Foundations of Business Intelligence - Databases and Information Management Dr. Andrew P. Ciganek, Ph.D.
LeongHW, SoC, NUS (UIT2201: Database) Page 1 © Leong Hon Wai, Animation of SQL Queries To illustrate three SQL queries: –Q1: simple select (one.
2005 SPRING CSMUIntroduction to Information Management1 Organizing Data John Sum Institute of Technology Management National Chung Hsing University.
Organizing Data and Information AD660 – Databases, Security, and Web Technologies Marcus Goncalves Spring 2013.
Database Organization and Design
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
Objectives Overview Define the term, database, and explain how a database interacts with data and information Describe the qualities of valuable information.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Database A database is a collection of data organized to meet users’ needs. In this section: Database Structure Database Tools Industrial Databases Concepts.
Oleh Munawar Asikin. Principles of Information Systems, Seventh Edition 2  Database management system (DBMS): group of programs that manipulate database.
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
Instructor: Dema Alorini Database Fundamentals IS 422 Section: 7|1.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Database Fundamentals CSC105 Furman University Peggy Batchelor.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Information Systems Today: Managing in the Digital World TB3-1 3 Technology Briefing Database Management “Modern organizations are said to be drowning.
1 Chapter 9 Database Management. Objectives Overview Define the term, database, and explain how a database interacts with data and information Describe.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
6.1 © 2007 by Prentice Hall Chapter 6 (Laudon & Laudon) Foundations of Business Intelligence: Databases and Information Management.
Fundamentals of Information Systems, Sixth Edition Chapter 3 Database Systems, Data Centers, and Business Intelligence.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
1 Management Information Systems M Agung Ali Fikri, SE. MM.
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.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Copyright © 2013 Dorling Kindersley (India) Pvt. Ltd. Management Information Systems: Managing the Digital Firm, 12eAuthors: Kenneth C. Laudon and Jane.
Fundamentals of Information Systems, Sixth Edition
CS320 Web and Internet Programming SQL and MySQL
Information Systems Today: Managing in the Digital World
Fundamentals & Ethics of Information Systems IS 201
Database – Info Storage and Retrieval
Chapter 4 Relational Databases
Translation of ER-diagram into Relational Schema
Databases and Information Management
MANAGING DATA RESOURCES
Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4)
Databases and Information Management
CS3220 Web and Internet Programming SQL and MySQL
Syllabus Introduction Website Management Systems
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info storage and Retrieval;  Database Organization;  DBMS, Query and Query Processing;  Work some simple exercises;  Concurrency Issues (in Database)  Readings:  [SG] --- Ch 13.3  Optional:  Some experiences with MySQL, Access

LeongHW, SOC, NUS (UIT2201:3 Database) Page 2 Copyright © by Leong Hon Wai Outline  What is a Database and Evolution…  Organization of Databases  Foundations of Relational Database  DBMS and Query Processing  Concurrency Issue in Database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 3 Copyright © by Leong Hon Wai What is a Database  First attempt…  A collection of data  Examples:  Employee database  Jobs Database  LINC Database  Inventory Database  Recipe Database  Database of Hotels  Database of Restaurants  MP3 Database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 4 Copyright © by Leong Hon Wai What is a Database (2)  Combination of “Databases”  Can do more…  eg: Employee Database + CIA Database  eg: Inventory Database + Recipe Database  Database is …  A combination of a variety of data collections into a single integrated collection

LeongHW, SOC, NUS (UIT2201:3 Database) Page 5 Copyright © by Leong Hon Wai Evolution of Databases…  From separate, independent database  One Course-DB per NUS dept/faculty (in the 90’s)  Inherent Problem: uincompatability, uinconvenience, slow, error prone  To Integrated Database  One integrated DB or DB schema uServing the needs of all depts/faculty uBetter data compatability, fasters,… uCF: NUS CORS Online Registration uCF: IRAS e-filing (Online Tax Submission)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 6 Copyright © by Leong Hon Wai DBMS and DBA  With Integrated Database, we need  To ensure data consistency  Provide services to all depts uDifferent services to diff dept, uDifferent interface  To provide different views of the same data uEg: CEO, CFO, Proj Mgr, Programmer uEg: Dean, Heads, Professors, AOs, Students  to decide how to Organize data (schemas) uUsually organized into tables  DBMS = DB Management System  DBA = Database Administrator

LeongHW, SOC, NUS (UIT2201:3 Database) Page 7 Copyright © by Leong Hon Wai Outline  What is a Database and Evolution…  Organization of Databases  Foundations of Relational Database  DBMS and Query Processing  Concurrency Issue in Database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 8 Copyright © by Leong Hon Wai Database (with 3 Tables (Relations)) S CHEDULE-DB CourseDayHour UIT2201Tue1000 UIT2201Tue1100 CS1101Wed1300 CS1101Wed1400 G RADES-DB CourseStud-IDGrade UIT2201U071024A UIT2201U081337C UIT2201U072007B CS1101U072007A S TUDENTS-DB Stud-IDNameAddressPhone U071024Albert Zan23 Sheares Hall4358 U081337Betty Yeo89 PGP6177 U072007Cathy Xin37 Raffles Hall1388

LeongHW, SOC, NUS (UIT2201:3 Database) Page 9 Copyright © by Leong Hon Wai Figure 13.3: Data Organization Hierarchy Database Organization (Overview)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 10 Copyright © by Leong Hon Wai Data Organization (A Bottom-Up View)  Bit  A binary digit, (0 or 1)  Byte  A group of eight (8) bits  Stores the binary rep. of a character / small integer  A single unit of addressable memory  Field  A group of bytes used to represent a string

LeongHW, SOC, NUS (UIT2201:3 Database) Page 11 Copyright © by Leong Hon Wai Data Organization (continued)  Record  A collection of related fields  Data File  Related records are kept in a data file  Database  Related files make up a database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 12 Copyright © by Leong Hon Wai Figure 13.4: Records and Fields in a Single File Database Files or Database Table Eg: S CHEDULE-DB Table and Record S CHEDULE-DB CourseDayHour UIT2201Tue1000

LeongHW, SOC, NUS (UIT2201:3 Database) Page 13 Copyright © by Leong Hon Wai Outline  What is a Database and Evolution…  Organization of Databases  Foundations of Relational Database  DBMS and Query Processing  Concurrency Issue in Database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 14 Copyright © by Leong Hon Wai Database (with 3 Tables (Relations)) S CHEDULE-DB CourseDayHour UIT2201Tue1000 UIT2201Tue1100 CS1101Wed1300 CS1101Wed1400 G RADES-DB CourseStud-IDGrade UIT2201U071024A UIT2201U081337C UIT2201U072007B CS1101U072007A S TUDENTS-DB Stud-IDNameAddressPhone U071024Albert Zan23 Sheares Hall4358 U081337Betty Yeo89 PGP6177 U072007Cathy Xin37 Raffles Hall1388

LeongHW, SOC, NUS (UIT2201:3 Database) Page 15 Copyright © by Leong Hon Wai Foundations of Relational DB  Table (Relation) : information about an entity  A set of records (eg: Schedule-DB Table)  Record (Tuple): data about an instance of the entity  A row in the table; A tuple; Eg: (UIT2201, Tue, 10 AM)  Attribute (Fields): category of information/data  Columns in the table (eg: Course, Day, Stud-ID, Grades)  Schema: A set of Attributes  {Course, Day, Time} – S CHEDULE-DB  Database: A set of tables (relations)  { S CHEDULE-DB, G RADES-DB, S TUDENTS-DB }

LeongHW, SOC, NUS (UIT2201:3 Database) Page 16 Copyright © by Leong Hon Wai Relational-DB Operations  Insert (S CHEDULE-DB, (CS1102, Thu, 1100))  Delete (S CHEDULE-DB, (UIT2201, Tue, 1100))  Delete (S CHEDULE-DB, (UIT2201, *, * ))  Delete (S CHEDULE-DB, ( *, Tue, * ))  Lookup (S CHEDULE-DB, ( *, Wed, * )) S CHEDULE-DB CourseDayHour UIT2201Tue1000 UIT2201Tue1100 CS1101Wed1300 CS1101Wed1400

LeongHW, SOC, NUS (UIT2201:3 Database) Page 17 Copyright © by Leong Hon Wai Typical Operations…  Insert a new Record  Deleting Records  Delete a specific record  Delete all records that match the specification X  Searching Records  Look up all records that match the given specification X  Display some attributes (‘projection’)  Join Operation

LeongHW, SOC, NUS (UIT2201:3 Database) Page 18 Copyright © by Leong Hon Wai Relational-DB and Abstract Algebra  Foundation of Relational DB is  Relational Algebra (in abstract mathematics)  Tables are modelled as Relations (algebra)  Specified by schema (conceptual model)  Operations on a Tables are  modelled by Relational Operations  Typical Operations  Insert, Delete, Lookup, Project, etc (If interested, read article from course web-site)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 19 Copyright © by Leong Hon Wai Outline  What is a Database and Evolution…  Organization of Databases  Foundations of Relational Database  DBMS and Query Processing  Concurrency Issue in Database

LeongHW, SOC, NUS (UIT2201:3 Database) Page 20 Copyright © by Leong Hon Wai Database Management Systems  DBMS (Database Mgmt Systems)  Software system, maintains the files and data  Relational Database Model (and Design)  Database specified via schema (conceptual models)  Database Query Processing  To query the database (to get information)  SQL (Structured Query Language) u Specialized query language  Relationships between tables  Established via primary keys and foreign keys

LeongHW, SOC, NUS (UIT2201:3 Database) Page 21 Copyright © by Leong Hon Wai Database for Rugs-for-You

LeongHW, SOC, NUS (UIT2201:3 Database) Page 22 Copyright © by Leong Hon Wai Query Processing with SQL  SQL is a DB Query Language  Supported by many of the common DBMS  Provides easier means to insert/delete records  Quite simple to use/learn on your own  SQL Queries (format)  SELECT FROM WHERE ;

LeongHW, SOC, NUS (UIT2201:3 Database) Page 23 Copyright © by Leong Hon Wai Query Processing (simple, using SQL) SELECT ID, LastName, FirstName, PayRate FROM EMPLOYEES WHERE (LastName = ‘KAY’); Output of SQL Query ID LASTNAME FIRSTNAME PAYRATE 116 Kay Janet $ Kay John $17.80 SQL Query

LeongHW, SOC, NUS (UIT2201:3 Database) Page 24 Copyright © by Leong Hon Wai Query Processing (simple, using SQL) SELECT ID, LastName, FirstName, HoursWorked FROM EMPLOYEES WHERE (HOURSWORKED > 200); SELECT * FROM EMPLOYEES WHERE (PAYRATE > 15.00);

LeongHW, SOC, NUS (UIT2201:3 Database) Page 25 Copyright © by Leong Hon Wai In SQL (a Query Language)….  Simple SQL Queries  SELECT * FROM SCHEDULE-DB WHERE (DAY=“Wed”)  SELECT Day, Hour FROM SCHEDULE-DB WHERE (COURSE=“UIT2201”)  SELECT Course, Hour FROM SCHEDULE-DB S CHEDULE-DB CourseDayHour UIT2201Tue1000 UIT2201Tue1100 CS1101Wed1300 CS1101Wed1400

LeongHW, SOC, NUS (UIT2201:3 Database) Page 26 Copyright © by Leong Hon Wai Figure 13.8: Three Tables in the Rugs-For-You Database Primary Keys and Foreign Keys (Readings: Primary & Foreign Keys, [SG3] Section 13.3)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 27 Copyright © by Leong Hon Wai SQL with Multiple Relations  In SQL, combining two or more tables  that share common data (via keys)  SQL uses a Join operation. SELECT ID, LastName, FirstName, PlanType, DateIssued FROM EMPLOYEES, INSURANCEPOLICIES WHERE (LastName = “Takasano”) AND (ID = EmployeeID); key

LeongHW, SOC, NUS (UIT2201:3 Database) Page 28 Copyright © by Leong Hon Wai Joins Operation (of Two Relations) SCHEDULE-DB CourseDayHour UIT2201Tue10 AM UIT2201Tue11 AM CS1101Wed1 PM CS1101Wed2 PM VENUE-DB CourseRoom UIT2201SR5 CS1101LT15 CourseDayHourRoom UIT2201Tue10 AMSR5 UIT2201Tue11 AMSR5 CS1101Wed1 PMLT15 CS1101Wed2 PMLT15 JOIN Operation (SCHEDULE-DB.course = VENUE-DB.course)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 29 Copyright © by Leong Hon Wai More about JOIN operation  Check out animation of Join Op  Running time: O(mn) row operations  Join is an expensive operation!  May produce huge resultant tables;  Exercise great care with JOINs (See examples in Tutorial)

LeongHW, SOC, NUS (UIT2201:3 Database) Page 30 Copyright © by Leong Hon Wai QP: Declarative vs Procedural  SQL is a declarative language  SQL query declare “what” you want  DBMS+SQL auto-magically processes query u to get the results in an efficient manner  “How” does SQL do the job? [not given in query]  Procedural Query Processing  The “how” of query processing  Based on three basic primitives (from relational-alg)  Primitives: e-project, e-select, e-join  Specified “like” an algorithm  [This is not covered in [SG3]. Read my notes

LeongHW, SOC, NUS (UIT2201:3 Database) Page 31 Copyright © by Leong Hon Wai Three basic primitives T1  e-select from SCHEDULE-DB where (DAY=“Tue”); T4  e-select from SCHEDULE-DB where (HOUR=1200);  Basic Primitive Operation 1 – e-select  e-select from where ;  (a row/record selector)  includes all columns  Basic Primitive Operation 2 – e-project  e-project from ;  (a column/field selector)  includes all rows P1  e-project COURSE, DAY from SCHEDULE-DB; P6  e-project COURSE, HOUR from T1;

LeongHW, SOC, NUS (UIT2201:3 Database) Page 32 Copyright © by Leong Hon Wai Basic primitives operations (2) P1  e-project Course, Day from SCHEDULE-DB; S CHEDULE-DB CourseDayHour UIT2201Tue1000 UIT2201Tue1100 CS1101Wed1300 CS1101Wed1400 P1 CourseDay UIT2201Tue UIT2201Tue CS1101Wed CS1101Wed S1  e-select from SCHEDULE-DB where (Day=“Tue”); S1 CourseDayHour UIT2201Tue1000 UIT2201Tue1100 In e-project, all rows are included In e-select, all columns are included

LeongHW, SOC, NUS (UIT2201:3 Database) Page 33 Copyright © by Leong Hon Wai Basic primitives operation – e-join B1  e-join SCHEDULE-DB and VENUE-DB where (SCHEDULE-DB.Course = VENUE-DB.Course); W3  e-join P6 and VENUE-DB where (P6.Course = VENUE-DB.Course);  Basic Primitive Operation 3 – e-join  e-join from where ;  Specify join conditions using primary/foreign keys;  Two (2) tables at a time! (basic join operation)  Includes all “satisfying” rows and columns

LeongHW, SOC, NUS (UIT2201:3 Database) Page 34 Copyright © by Leong Hon Wai Example of e-join SCHEDULE-DB CourseDayHour UIT2201Tue10 AM UIT2201Tue11 AM CS1101Wed1 PM CS1101Wed2 PM VENUE-DB CourseRoom UIT2201SR5 CS1101LT15 (SCHEDULE-DB.course = VENUE-DB.course) B1  e-join SCHEDULE-DB and VENUE-DB where (SCHEDULE-DB.Course = VENUE-DB.Course);

LeongHW, SOC, NUS (UIT2201:3 Database) Page 35 Copyright © by Leong Hon Wai Why not store everything in one Table?  Problems:  Duplication of data;  Deletion Problem; u What if Cathy Xin drops CS1101? STUDENT-SCHEDULE-DB Stud-IDNamePhoneCourseDayHour… 1024Albert Zan4358UIT2201Tue10 AM… 1024Albert Zan4358UIT2201Tue11 AM… 1337Cathy Xin1388CS1101Wed1 PM… 1337Cathy Xin1388CS1101Wed2 PM… 2007Betty Yeo6177UIT2201Tue10 AM 2007Betty Yeo6177UIT2201Tue11 AM

LeongHW, SOC, NUS (UIT2201:3 Database) Page 36 Copyright © by Leong Hon Wai Database for use in Tutorials STUDENT-INFO Student-ID Name NRIC-ID Address Tel-No Faculty Major U STueS SOC CS U RTueS FASS Econs... COURSE-INFO Course-ID Name Day Hour Venue Instructor UIT2201 CSITR Tue 1000USP-SR5 LeongHW CS6234 Adv. Alg Wed 1600SR5(com1) Panos... ENROLMENT Student-ID Course-ID U S UIT2201 U X MA

LeongHW, SOC, NUS (UIT2201:3 Database) Page 37 Copyright © by Leong Hon Wai Other Issues: (for your reading)  Other Considerations in Databases  Read Section (pp )

LeongHW, SOC, NUS (UIT2201:3 Database) Page 38 Copyright © by Leong Hon Wai Thank you!

LeongHW, SOC, NUS (UIT2201:3 Database) Page 39 Copyright © by Leong Hon Wai What to modify/add for future…  Value added Services:  Data Mining – frequent patterns  Targeted marketing (Database marketing)  Credit-card fraud,  Handphone acct churning analysis