Database Management systems and Standardized Query Language The easy way to handle data.

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
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.
CIT 613: Relational Database Development using SQL Introduction to SQL.
Introduction to Structured Query Language (SQL)
Database Management: Getting Data Together Chapter 14.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
1 Database Systems (Part I) Introduction to Databases I Overview  Objectives of this lecture.  History and Evolution of Databases.  Basic Terms in Database.
1 Lecture 31 Introduction to Databases I Overview  Objectives of this lecture  History and Evolution of Databases  Basic Terms in Database and definitions.
Introduction to Structured Query Language (SQL)
CSC 2720 Building Web Applications Database and SQL.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Data Definition, Relational Manipulation and Data Control Using SQL.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Database Lecture # 1 By Ubaid Ullah.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
The Relational Model These slides are based on the slides of your text book.
6-1 DATABASE FUNDAMENTALS Information is everywhere in an organization Information is stored in databases –Database – maintains information about various.
Chapters 17 & 18 Physical Database Design Methodology.
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.
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.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
SQL Server 7.0 Maintaining Referential Integrity.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 SQL Constraints and Programming. 2 Agenda Constraints in SQL Systems aspects of SQL.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
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.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
CS453: Databases and State in Web Applications (Part 2) Prof. Tom Horton.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Session 1 Module 1: Introduction to Data Integrity
CIT 613: Relational Database Development using SQL Introduction to SQL DeSiaMorePowered by DeSiaMore 1.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
IT420: Database Management and Organization Triggers and Stored Procedures 24 February 2006 Adina Crăiniceanu
Oracle 10g Database Administrator: Implementation and Administration Chapter 10 Basic Data Management.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Databases Introduction - concepts. Concepts of Relational Databases.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
BTM 382 Database Management Chapter 8 Advanced SQL Chitu Okoli Associate Professor in Business Technology Management John Molson School of Business, Concordia.
SQL Basics Review Reviewing what we’ve learned so far…….
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
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.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
1 Section 9 - Views, etc. u Part 1: Views u Part 2:Security Issues u Part 3:Transaction Management u Part 4:Set Operations u Part 5:Triggers and Stored.
Understanding Core Database Concepts Lesson 1. Objectives.
Applied CyberInfrastructure Concepts Fall 2017
Chapter 8 Advanced SQL Pearson Education © 2014.
SQL 101.
Lesson Objectives Aims You should know about: 1.3.2: (a) indexing (d) SQL – Interpret and Modify (e) Referential integrity (f) Transaction processing,
Understanding Core Database Concepts
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:

Database Management systems and Standardized Query Language The easy way to handle data

Before the Database Management Systems The programmer had to handle all details of data storage and retrieval  Low level programming  A new wheel invented all the time  All data in flat files with different format  Hard to maintain data integrity  Hard to handle simultaneous data access

What is a Database Management System (DBMS)? A system for storing data in a standardized manner A system for retrieving data easily A system for protecting data against failure and unauthorized access A tool for simplifying system development Relieves the programmer of physical data storage

Different kind of DBMS Hierarchical DBMS, 60s Relation DBMS, RDBMS, 70s Object DBMS, 80s Object-relational DBMS, 90s Most databases today are RDBMS or Object- relational DBMS

Relational Database Systems Started in the 70s at IBM by Cod Several implementations by companies like Oracle, Sybase, Upright and Microsoft Highly optimized systems Proven and mature technology Several international standards Most systems today uses a RDBMS

The Relational Model All data is stored in tables with rows and columns pnr*namesurnamesex 1FredrikÅlundMale 2EvaLarssonFemale

The Relational Model Relations between tables and data pnr*car 1Volvo pnr*name 1Fredrik 2Eva

The Relational Model Each column contains atomic data Views is an alternative view of a table Normalization is used to make the data model as flexible as possible  No column should depend on any other column in the row  No redundant data  Several levels of normalization and the third normal form is the most used

Query Languages No standardized languages in the beginning One query in Oracle would not work in Mimer Hard for the developer to know many languages No portability Locked into one vendor

Standardized Query Language, SQL SQL is a ISO standard supported by basically all vendors, more or less SQL 92, SQL 99 and the new SQL 200x SQL is used to create the data model SQL is used to query the database SQL is used to perform updates Powerful language created to manipulate data

SQL Basics Tables can be created with the create command  CREATE TABLE PERSON(pnr int, namn char(10), surname char(10), sex char(6))  CREATE TABLE PERSON_CARS(pnr int, car char(7)) Primary keys are defined in the create statement  CREATE TABLE PERSON(pnr int, namn char(10), surname char(10), sex char(6), primary key(pnr))

SQL Basics Foreign keys can also be defined in the create statement  CREATE TABLE PERSON_CARS(pnr int, car char(7), foreign key(pnr) references PERSON(pnr) on delete cascade)

SQL Basics A column can have restrictions and default values  CREATE TABLE PERSON(pnr int, name char(10) default ‘Unknown’, surname char(10), sex char(6) not null, primary key(pnr))

SQL Basics A table can be altered after has been created  ALTER TABLE PERSON_CARS ADD CONSTRAINT person_car_pk PRIMARY KEY(pnr, car)  ALTER TABLE PERSON ADD COLUMN AGE INT

SQL Basics Data is retrieved with the SELECT statement  SELECT * FROM PERSON  SELECT PNR, NAME FROM PERSON  SELECT * FROM PERSON WHERE AGE > 25 AND SEX=‘Male’ Tables are joined in the SELECT statement  SELECT PERSON.NAME, PERSON_CARS.CAR FROM PERSON, PERSON_CARS WHERE PERSON.PNR = PERSON_CARS.PNR

SQL Basics Joins can also be performed with the JOIN condition  SELECT PERSON.NAME, PERSON_CARS.CAR FROM PERSON LEFT OUTER JOIN PERSON_CARS ON PERSON.PNR=PERSON_CARS.PNR  Gives all person and their car. If they don’t have a car, null is returned in that columns instead. In our case, Fredrik, Volvo and Eva, null

SQL Basics SELECT PERSON.NAME, PERSON_CARS.CAR FROM PERSON RIGHT OUTER JOIN PERSON_CARS ON PERSON.PNR=PERSON_CARS.PNR  Gives all person and their car only if they have a car In our case, Fredrik, Volvo SELECT PERSON.NAME, PERSON_CARS.CAR FROM PERSON NATURAL JOIN PERSON_CARS  The same result as above

SQL Basics Data is inserted with the INSERT statement  INSERT INTO PERSON(pnr, name, surname,sex, age) VALUES(3, ‘Eva’, ‘Larsson’, ‘Female’, ’27’)  INSERT INTO PERSON_CARS(pnr, car) VALUES(3,’Toyota’)

SQL Basics Data can be update with the UPDATE statements  UPDATE PERSON SET AGE=22 WHERE PNR=1 Update Fredriks age to 22  UPDATE PERSON_CAR SET CAR=‘Volvo’ Updates all cars to Volvo

SQL Basics Data is deleted with the DELETE statement  DELETE FROM PERSON WHERE ID=3 Deletes the row with Eva Larsson

SQL Basics Views are created with a combination of a CREATE and a SELECT  CREATE VIEW VOLVO_OWNERS(pnr, name, surname, sex, age) as SELECT p.pnr, name, surname, sex, age FROM PERSON p, PERSON_CARS pc WHERE pc.pnr=p.pnr AND pc.cars=‘Volvo’ Only show Volvo users SELECT * FROM VOLVO_OWNERS

Advanced SQL Stored Procedures  A precompiled query in the database. Entire systems can be built with Stored Procedures. Triggers  Certain events can trigger actions, for example a stored procedure might be started when a row is deleted Both Stored Procedures and Triggers are part of SQL 99

Transactions Transactions is the way that the RDBMS keeps the data consistent  A transaction is supposed to have the ACID property Atomic Consistent Isolated Durable

Transactions The classic example is the cash machine  If the cash machine gives out the money, but the reduce balance doesn’t finnish, we have too much mony  If the balance is reduced but we don’t get any money we have too little Check balance Okej, give the money Reduce balance Cash machine Bank

Transactions in SQL A transaction is started with START A transaction is commited with COMMIT  If ok, everything is secured and well A transaction is rolled back (undone) with ROLLBACK  All operations are undone