By Anil Kumar.

Slides:



Advertisements
Similar presentations
By RUPESH KUMAR.  Database? Types? Abstraction?  Database Models?  Database Integrity?  ACID?  RDBMS?  Normalization?  Data Warehouse?  Database.
Advertisements

Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Lecture # 1 By Ubaid Ullah.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden Date:
Database Technical Session By: Prof. Adarsh Patel.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Relational Database. Database Management System (DBMS)
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Chapter 3: Relational Databases
1 A Very Brief Introduction to 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.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Welcome: To the fifth learning sequence “ Data Models “ Recap : In the previous learning sequence, we discussed The Database concepts. Present learning:
SQL Basics Review Reviewing what we’ve learned so far…….
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
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.
Introduction to Structured Query Language (SQL) By Techandmate.comTechandmate.com Learn SQL Server With US.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Getting started with Accurately Storing Data
Databases and DBMSs Todd S. Bacastow January
Introduction to DBMS Purpose of Database Systems View of Data
CompSci 280 S Introduction to Software Development
Fundamentals of DBMS Notes-1.
Logical Database Design and the Rational Model
Chapter 4 Logical Database Design and the Relational Model
The Basics of Data Manipulation
 2012 Pearson Education, Inc. All rights reserved.
Database Management:.
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Teaching slides Chapter 8
Lecture 2 The Relational Model
Chapter 4 Relational Databases
“Introduction To Database and SQL”
Introduction to Database Management System
DATABASE MANAGEMENT SYSTEM
STRUCTURED QUERY LANGUAGE
Chapter 2 Database Environment Pearson Education © 2009.
Basic Concepts in Data Management
Chapter 2 Database Environment.
Normalization Referential Integrity
Database Fundamentals
Database management concepts
The Basics of Data Manipulation
LECTURE 34: Database Introduction
Data Model.
Introduction to DBMS Purpose of Database Systems View of Data
Database management concepts
Relational Database Design
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
Chapter 11 Managing Databases with SQL Server 2000
DATABASE Purpose of database
LECTURE 33: Database Introduction
Chapter 2 Database Environment Pearson Education © 2009.
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

By Anil Kumar

Objectives Review database theory and history Review relational database concepts Learn about the evolution of data access technologies By Anil Kumar

Agenda Databases Relational Databases By Anil Kumar

Databases Databases Virtually all interesting applications require a structured, persistent data store E-Commerce: placing an order, fulfilling an order HR: Personnel data Sales CRM: Customer data Games Database needs vary with the type of application Transaction Processing/OLTP Business Intelligence/Data Warehouse/OLAP By Anil Kumar

Databases Database Requirements Can store, view and modify data Can move, copy and transform data Can backup and restore data Enforces data integrity rules Is scaleable and available High number of users Lots of data High throughput with low response time Is secure Facilitates application development By Anil Kumar

Databases Evolution of Database Technology File-based Hierarchical Network Relational (RDBMS) Object-oriented XML By Anil Kumar

Agenda Databases Theory and History Relational Databases By Anil Kumar

Relational Databases Tables Table (relation, entity) A collection of data about a specific type of thing Organized in rows and columns Column (attribute, field) Describes part of an entity (e.g. FirstName) Has a data type (e.g. integer, character, binary) Can be null Row (tuple, record) A single instance of data in a table Each row is unique AuthID FirstName LastName 1 Joe Smith 2 Diane Jones By Anil Kumar

Relational Databases Relating Data Tables can be related through primary/foreign key relationships (e.g., a book has an author) Primary key Guarantees the uniqueness of a row Can be composed of one or more columns Ensures entity integrity Foreign key Establishes logical relationship between tables One or more columns of a table that match the primary or alternate key of another table Referential integrity Relational databases do NOT get there name because they can relate data. They get their name from set theory: a relation is the set-theoretic term for a table. Primary/foreign key relationships are THE way data is related in a relational database. By Anil Kumar

Relational Databases Relating Data Schema diagram depicts tables, columns, primary keys, foreign keys Books BookID AuthID Title Type Authors AuthID FirstName LastName 1 ∞ Schema Diagram By Anil Kumar By Anil Kumar

Relational Databases Relating Data Books Table Primary Key BookID AuthID Title Type 1 2 My Life as a DBA Autobiography Database Handbook Reference PK/FK Relationship Foreign Key AuthID FirstName LastName 1 Joe Smith 2 Diane Jones Authors Table By Anil Kumar

Relational Databases Types of Relationships One-to-One (1:1) One row in table X matches one row in table Y A book has at most one Library of Congress entry One-to-Many (1:M) One row in table X matches 0+ rows in table Y A publisher publishes one or more books Many-to-Many (M:N) 1+ rows in table X matches 1+ rows in table Y An author writes one or more books; a book is written by one or more authors 1 1 Books LoC Entries Publishers 1 M Books M Authors N Books By Anil Kumar

Relational Databases M:N Relationships More complex Can result in very large tables (repeated data) Difficult to ensure data integrity The remedy: Create a third table The third table contains the primary key of the two original tables in a composite key Data is repeated in the third table, but not in the two original tables Authors 1 M BookAuth M 1 Books By Anil Kumar

Relational Databases M:N Relationships 1 ∞ Data is duplicated here 1 1 ∞ ∞ By Anil Kumar

Relational Databases Normalization/Denormalization The process of breaking large tables into multiple smaller tables Goal: minimize redundant data, maximize correctness Improves performance for updates Desirable in transaction-based applications Denormalization The process of combining smaller tables into fewer larger tables Goal: improve performance Introduces redundant data Improves performance for reads Desirable in data warehouse applications By Anil Kumar

Relational Databases Joins A join is a way of combining data in multiple tables, usually by resolving primary key/foreign key relationships Product table Vendor table Product Cost Vendor Vendor State Contact Widget $10 Acme Acme MA Linda A. Thingy $5 Acme Blecco WA Adam P. Widget $8 Blecco Foobar $25 Blecco By Anil Kumar

Relational Databases Joins Result of a natural join Product Cost Vendor State Contact Widget $10 Acme MA Linda A. Thingy $5 Acme MA Linda A. Widget $8 Blecco WA Adam P. Foobar $25 Blecco WA Adam P. By Anil Kumar

Relational Databases Structured Query Language (SQL) Standard language for accessing a relational database, standardized by American National Standards Institute (ANSI); SQL-92 Open, but not really Common functions are mostly the same across products Most vendors have proprietary extensions Subsets of SQL Data Definition Language (DDL) Data Manipulation Language (DML) Data Control Language (DCL) By Anil Kumar

Relational Databases DDL Examples Used to create and modify database objects CREATE DATABASE Bookstore CREATE TABLE tBooks ( BookID INT IDENTITY(1,1) PRIMARY KEY, Title VARCHAR(30) NOT NULL, PubDate DATE NOT NULL, [Description] VARCHAR(50), Category INT NOT NULL ) By Anil Kumar

Relational Databases DML Examples Select data to view SELECT * FROM tAuthors SELECT AuthID, FirstName, LastName FROM tAuthors SELECT AuthID, FirstName, LastName, Phone FROM tAuthors WHERE City = ‘Boston’ SELECT FirstName, LastName, Phone FROM tAuthors WHERE AuthID = 249 By Anil Kumar

Relational Databases DML Examples Using SELECT to join tables SELECT AuthID, FirstName, LastName, Phone, BookID, Title, PubDate, Description FROM tAuthors, tBooks WHERE tAuthors.AuthID = tBooks.AuthID SELECT AuthID, FirstName, LastName, Phone, BookID, Title, PubDate, Description FROM tAuthors INNER JOIN tBooks ON tAuthors.AuthID = tBooks.AuthID By Anil Kumar

Relational Databases DML Examples Insert, update and delete data INSERT INTO tBooks (Title, PubDate, [Description], Category) VALUES (‘Database Design’, GETDATE(), ‘How to design a database’, 3) UPDATE tAuthors SET Phone = ‘617-555-1234’ WHERE AuthID = 5 DELETE FROM tAuthors WHERE AuthID = 5 By Anil Kumar

Relational Databases DCL Examples Set security options on database objects GRANT INSERT, UPDATE, DELETE ON tAuthors TO Mary, John REVOKE CREATE TABLE FROM Joe DENY ALL ON tAuthors, tBooks TO Sally By Anil Kumar

Relational Databases Views A view is a virtual table Abstracts the underlying table structures Abstracts a (possibly complex) query Provides security abstraction from table In SQL Server 2000, a view can be Indexed Updated and inserted into By Anil Kumar

Relational Databases View Definition Example CREATE VIEW vwCustomerOrders AS SELECT o.OrderId, c.CompanyName FROM Customers c INNER JOIN Orders o ON c.CustomerID = O.CustomerID ORDER BY o.OrderId By Anil Kumar

Relational Databases View Usage Example SELECT * FROM vwCustomerOrders WHERE CompanyName = 'My Favorite Customer' OrderId CompanyName 101 My Favorite Customer 137 … By Anil Kumar

Relational Databases Stored Procedures A group of SQL statements that runs within the database Not part of SQL standard Provides greater performance Can control access to data Can accept parameters Can return data Output parameters Return values Result set By Anil Kumar

Relational Databases Stored Procedure Example CREATE PROCEDURE CustOrderHist @CustomerID nchar(5) AS SELECT ProductName, Total=SUM(Quantity) FROM Products P, [Order Details] OD, Orders O, Customers C WHERE C.CustomerID = @CustomerID AND C.CustomerID = O.CustomerID AND O.OrderID = OD.OrderID AND OD.ProductID = P.ProductID GROUP BY ProductName By Anil Kumar

Relational Databases Stored Procedure Examples exec CustOrderHist 'alfki' ProductName Total Aniseed Syrup 6 Chartreuse verte 21 ... By Anil Kumar

Relational Databases Stored Procedure Examples Use RETURN statement to return status 0 is default in SQL Server Can only be numeric Use OUTPUT parameters to return results RETURN 1 CREATE PROCEDURE MyProcedure @ReturnValue INT OUTPUT ... SELECT @ReturnValue = ColumnName FROM Table By Anil Kumar

Relational Databases Triggers Like stored procedures, triggers are code that runs within a database Not directly called by a user Executed when a specified data modification takes place (INSERT, UPDATE or DELETE) Enforces business rules FOR AFTER: trigger executes after triggering action completes FOR INSTEAD OF: trigger executes in place of triggering action By Anil Kumar

Relational Databases Transactions Transaction: a sequence of SQL statements that constitute a logical unit of work Must adhere to ACID properties Atomic: All statements execute successfully or all fail Consistent: Must leave the data in a consistent state when completed Isolated: Cannot see the modifications made by concurrent transactions Durable: Must be permanent when complete, even in the event of system failure By Anil Kumar

Relational Databases Concurrency Isolation levels Read Uncommitted Read Committed Repeatable Read Serializable Tradeoffs (concurrency vs. data integrity) Locking Ensures transactional integrity/database consistency Prevents users from seeing “phantom” data Can result in deadlocks By Anil Kumar

Thank You By Anil Kumar