Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.

Slides:



Advertisements
Similar presentations
The Relational Model Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Advertisements

IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra.
Greg Riccardi Florida State University. Using SQL to Manipulate Database Content and Structure How to create queries in SQL –Simple select statements.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
D ATABASE S YSTEMS I A DMIN S TUFF. 2 Mid-term exam Tuesday, Oct 2:30pm Room 3005 (usual room) Closed book No cheating, blah blah No class on Oct.
Fall 2001Arthur Keller – CS 1808–1 Schedule Today Oct. 18 (TH) Schemas, Views. u Read Sections u Project Part 3 extended to Oct. 23 (T). Oct.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Databases Dan Otero Alex Loddengaard
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Oracle Data Definition Language (DDL)
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
ASP.NET Programming with C# and SQL Server First Edition
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
1 11/3/05CS360 Windows Programming Databases and Data Representation.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
CSC 2720 Building Web Applications Database and SQL.
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
Visual Programing SQL Overview Section 1.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
Lu Chaojun, SJTU Relational Data Model 1. Lu Chaojun, SJTU What’s a Data Model? A notation (collection of conceptual tools) for describing data as seen.
Sql DDL queries CS 260 Database Systems.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CMPT 258 Database Systems The Relationship Model (Chapter 3)
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Databases : SQL-Schema Definition and View 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey.
The Relational Model of Data Prof. Yin-Fu Huang CSIE, NYUST Chapter 2.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
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.
Introduction to Database Programming with Python Gary Stewart
Standards and Conventions
Web Systems & Technologies
More SQL: Complex Queries,
Relational Data Model Lu Chaojun, SJTU.
CS320 Web and Internet Programming SQL and MySQL
Module 2: Intro to Relational Model
Chapter 2: Relational Model
Chapter 2: Intro to Relational Model
Structured Query Language
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
CS3220 Web and Internet Programming SQL and MySQL
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.

 What is a Database?  A collection of organized information that persists over a long period of time  Such information (or data) is managed by a DataBase Management System  DBMS:  Software used to create and manage large amounts of data efficiently and securely

 A typical DBMS is expected to:  Provide a means by which users can create databases and specify their schemas  Give users the ability to query the database (and efficiently return results)  Store huge amounts of data  Support durability and reliability, recovering from failures and errors  Control user access to data (i.e. security)

 Database schemas abstract elements of the real world; to do so, we use a data model  A data model describes:  Structure of the data  Operations on the data (reads and writes)  Constraints on the data

 Transactional (and other) databases must meet the ACID test:  Atomicity: all-or-nothing execution  Consistency: relationships between data elements must adhere to defined constraints  Isolation: each transaction appears as if it occurs without other database activity  Durability: the data itself is durable in the sense that the data must never be lost

 A relation is a two-dimensional data structure that consists of a set of attributes and (zero or more) tuples or rows of data  Each attribute takes only simple values  i.e. strings, numbers, boolean values, dates, etc. attribute1attribute2attribute3attribute4 MarkGoldbergAE 1086 MukkaiKrishnamoorthyLally SibelAdaliLally 3136 firstnamelastnameofficenuttiness

 The relation schema consists of:  The name of the relation  The set of attributes  The name (and type) of each attribute  Other constraints  An example: Profs( firstname, lastname, office, nuttiness )

 A relation contains a set of tuples  Each tuple contains values for all the attributes in the relation schema that are drawn from the domain of that attribute  Example tuples: possibly empty ( 'Mark', 'Goldberg', 'AE 108', 6 ) ( 'Mukkai', 'Krishnamoorthy', 'Lally 305', 30 ) ( 'Sibel', 'Adali', 'Lally 313', 6 ) As a set, tuple order is not significant.

 A key for a relation is a set of attributes such that no pair of tuples has the same value for the key  Examples:  Social Security Number  RIN (Rensselaer ID Number)  First and last name (would this one work???) Given the key, we can query the relation and expect exactly one result (or zero!). Profs( firstname, lastname, office, nuttiness )

 In practice, keys are used to improve efficiency of queries using such keys  And note that not all keys provide “uniqueness”  Since relations may have multiple keys, a primary key is selected  The primary key might be a separate (unused?) numeric field What would be the use of this?

 To store a relation, we can use SQL to create a table in a relational database system  Example attribute (data) types include:  CHAR, VARCHAR, TEXT  BIT, INT, INTEGER, FLOAT, DOUBLE, REAL  DECIMAL, NUMERIC  DATE, DATETIME, TIMESTAMP  BLOB, MEDIUMBLOB, LONGBLOB

create table tablename ( attribute1_name attribute1_type, attribute2_name attribute2_type,... attributeN_name attributeN_type, constraints ); might also have table options here other attribute constraints might be included here

create table student ( id int, name varchar(255), major char(4), gender char(1), dob date, constraint student_pk primary key (id) ); student_pk is an arbitrary name why did we specify these attribute types?

 Removing a table from the schema:  Adding a new attribute to a table:  Removing an attribute from a table: drop table tablename; truncate table tablename; what’s the difference? alter table tablename add attributename attributetype; alter table tablename drop attributename;

 Relational algebra consists of a set of simple operators that can be used to query the database  Each operator takes as input two relations and produces as output a relation  Think of a relation as a set of tuples  The input and output relations all must have the same schema

 Given two relations R and S that have the same schema, set operators include:  Union: ▪ R  S  { tuples that are in R or S (or both) }  Intersection: ▪ R  S  { tuples that are in both R and S }  Set difference: ▪ R – S  { tuples that are in R but not in S } remember that a set does not contain duplicates

 The projection of a relation R on attributes A 1, A 2,..., A n is given by:    A 1,...,A n (R) = { t | t is a tuple in R and t only contains values for attributes A 1, A 2,..., A n iff the schema of R contains attributes A 1, A 2,..., A n }  We use projection to remove existing attributes from R (by selecting a subset of them) duplicate tuples are omitted!

 Find and select all tuples from relation R that satisfy some set of conditions  Forms the basis of querying a database  The selection  C (R) is based on Boolean condition C over attributes of relation R  Example conditions include: ▪ A = e, A > e, A >= e, A e ▪ A 1 = A 2, A 1 <> A 2 ▪ Any combination of conditions using AND, OR, NOT A, A 1, and A 2 are attributes e is a constant or expression

 Selection selects a subset of tuples in relation R (with the schema unchanged)    C (R) = { t | t is a tuple in R and t satisfies the condition C on relation R }  Selection conditions can only refer to attributes in the given relation R  For conditions spanning multiple relations, we first must combine those relations (i.e. join)

 Download and install both the Oracle and MySQL database packages noted on the course Web site

 Design a full schema to store information about celebrities, including:  Basic information  Relationships (e.g. marriages, flings, etc.)  Issues (e.g. drugs, affairs, addictions, etc.)