MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 3 © Akhilesh Bajaj, 2000, 2002, 2004. All Rights.

Slides:



Advertisements
Similar presentations
© Abdou Illia MIS Spring 2014
Advertisements

Transform an ER Model into a Relational Database Schema
What is a Database By: Cristian Dubon.
Relational Algebra and SQL Exercises
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
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.
Relational Algebra Tim Kaddoura CS157A. Introduction  Relational query languages are languages for describing queries on a relational database  Three.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
1 Lecture 11: Basic SQL, Integrity constraints
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Cross-curricular Assignment Using your case study…
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos E-R diagrams.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts - 6 th Edition SQL Schema Changes and table updates instructor teaches.
Database Systems Relational Model Concepts Toqir Ahmad Rana Database Management Systems 1 Lecture 17.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 3: Introduction.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
FEN  Concepts and terminology  Operations (relational algebra)  Integrity constraints The relational model.
(C) 2000, The University of Michigan 1 Database Application Design Handout #4 January 28, 2000.
10/9/20151 The Relational Data Model TCU Database Systems Last update: September 2004 Reference: Elmasri 4 th edition, chapter 5.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
ITBIS373 Database Development
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003, 2004.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 1 ©Akhilesh Bajaj, 2000, 2002, 2003, All.
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.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj InClass ER Examples.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 4 Mapping an ER model to tables © Akhilesh Bajaj,
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
MIS 7003 MIS Core Course The MBA Program The University of Tulsa Professor: Akhilesh Bajaj Introduction to Database Design All Slides in this presentation.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 5 © Akhilesh Bajaj, 2000, 2002, 2003, All.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Chapter 2 Introduction to Relational Model. Example of a Relation attributes (or columns) tuples (or rows) Introduction to Relational Model 2.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
Database Management Systems, R. Ramakrishnan1 Relational Algebra Module 3, Lecture 1.
Relational Data Model DeSiaMore Powered by DeSiaMore.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004,
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 9 A First Course in Database Systems.
MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 4 © Akhilesh Bajaj, 2000, 2002, 2004, All.
CSI 3317 (LAB 2) Data Manipulation Language. Working With Database INSERT INTO location VALUES (53, 'ADMN', '424', 1); INSERT INTO location VALUES (54,
MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 3 © Akhilesh Bajaj, 2000, 2002, All Rights.
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.
Data Modeling Using the ERD
Relational Algebra Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Databases Relational Algebra (2)
The Relational Model Relational Data Model
CS4222 Principles of Database System
Chapter 2: Intro to Relational Model
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
Presentation transcript:

MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 3 © Akhilesh Bajaj, 2000, 2002, All Rights Reserved.

Review of Lectures 1 & 2 Learnt the basics of the relational model Learnt the notions of superkeys, candidate keys and primary keys Relational algebra - The select operation - The project operation -The assignment operation - The union operation - The set difference operation - The intersect operation - The cartesian product operation - The natural join operation

Goals for Today Practise relational algebra - Discussion in class (questions from you!) - In-class assignment Get started with SQL

Discussion & Questions from You

Relational Schema For Example Relational Algebra Queries Professors (f_id, f_name, f_address, f_specialty, highest_degree) Courses (c_id, c_name, num_credits) Sections (c_id, s_id, time_held, week_days_held, date_began, date_ended, cl_id) Students (st_id, st_name, gender, st_gpa) Grades (st_id, c_id, s_id, grade) Classrooms (cl_id, capacity, location) Teach (f_id, c_id, s_id)

In-Class Assignment Example 1 Information on all Professors who have a Ph.D. degree and specialize in “Databases”.

In-Class Assignment Example 2 Names and number of credits of all courses being completely taught between “Jun ” and “Aug ”. What if the course was at least partially taught between those dates?

date_began >= ‘JUN ’ AND ‘date_ended<= ‘AUG ’ date_ended >= ‘JUN ’ AND ‘date_began<= ‘AUG ’ First Query (only courses completely taught in the period) Second Query (courses that are at least partially taught in the period)   (Course spanned whole summer)  | (Course started before summer but ended in the summer) (Course started in summer but ended after summer) |  | | (Time line for summer) JUN 17, 2003 Aug, 15, 2003

In-Class Assignment Example 3 Names and faculty_ids of all Professors who are teaching or have taught at least once in classrooms that have a capacity of > 100. What if we wanted names and faculty ids of professors who have only ever taught in classrooms with capacity > 100?

In-Class Assignment Example 4 Names and GPAs of all students who have an ‘A’ in MIS3053ASpr2008(c_id=“MIS3053”, s_id = “ASpr2008”) What if we wanted Names and GPAs of all students who have an ‘A’ or a ‘B’ in MIS3053ASpr2008 (c_id=“MIS3053”, s_id = “ASpr2008”)

In-Class Assignment Example 5 Names of all Professors who teach the student ”Johnny Jones”. What if we wanted names of all professors who are only currently teaching “Johnny Jones”.

In-Class Assignment Example 6 Names of all students and Professors who go to class (or have gone to class) at 8:00 am.

In-Class Assignment Example 7 Names of all Professors who have never given a “C” grade. If we look at the schema, we see that names are not unique. What if we had 5 professors called “Bob”, 3 of whom had given a ‘C’ at least once, but 2 had not. Would “Bob” show up in our query?

Why is Relational Algebra Important For Us The backbone relational database query language. The examples so far have hopefully shown how it can be used to ask ad-hoc questions of the database. The things we learnt here are supported in SQL. E.g., the UNION, the INTERSECT, the cartesian product operations. Relational Algebra is a great way to VISUALIZE the query as it is being run. Knowing relational algebra will allow us to get a better understanding of SQL queries, since they are built using relational algebra concepts (and then some more concepts!!)

Structured Query Language (SQL) The standard relational database language Used to query the database (hardest to learn!), defining the relational schema, inserting, deleting and modifying data in the database. Two standards exist: SQL-89 and SQL-92. Most systems support at least SQL-89. SQL is the standard language with which we interact with the relational database system. SQL was invented in the early 1970-s. It has been around for around 25 years, and likely to be around for decades ahead.

Structured Query Language (SQL): Query Part To use SQL for querying, we need a defined relational schema. SQL allows the use of null values. The basic query clause in SQL is the select from where Condition ; clause. Note that the select here is similar to the project in relational algebra. The where here is similar to the select in relational algebra.

Structured Query Language (SQL): Query Part Example: Information on all Professors who have a Ph.D. degree and specialize in “Databases”.