1 What is database 2? What is normalization? What is SQL? What is transaction?

Slides:



Advertisements
Similar presentations
1 Başar Öztayşi 2011 END 213E Data Processing in Industrial Systems SQL Structured Query Language.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Accounting System Design
Introduction to Structured Query Language (SQL)
Transaction Management and Concurrency Control
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
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”
Introduction to Structured Query Language (SQL)
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Design Overview. 2 Database DBMS File Record Field Cardinality Keys Index Pointer Referential Integrity Normalization Data Definition Language.
1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Database Lecture # 1 By Ubaid Ullah.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
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.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
“INTRODUCTION TO DATABASE AND SQL”. Outlines 2  Introduction To Database  Database Concepts  Database Properties  What is Database Management System.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
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,
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Transaction Management and Concurrent Control
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
SQL Introduction to database and SQL. Chapter 1: Databases and Database Users 6 Introduction to Databases Databases touch all aspects of our lives. Examples:
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
SQL Basics Review Reviewing what we’ve learned so far…….
Lecturer: Eng. Mohamed Adam Isak PH.D Researcher in CS. M.Sc. and B.Sc. of Information Technology Engineering Senior Lecturer in University of Somalia,
Normalisation Unit 6: Databases. Just to recap  What is an Entity  What is an Attribute?
SQL Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database.
Relational Databases – Further Study I think we’ve covered all you need to know for GCSE about relational databases I’m not aware of any practical coursework.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
“Introduction To Database and SQL”
Introduction to Structured Query Language(SQL)
“Introduction To Database and SQL”
STRUCTURED QUERY LANGUAGE
Teaching slides Chapter 8.
Structured Query Language
Introduction To Structured Query Language (SQL)
SQL Queries Chapter No 3.
SQL .. An overview lecture3.
Introduction To Structured Query Language (SQL)
Structured Query Language
Relational Database Design
DATABASE Purpose of database
Presentation transcript:

1 What is database 2? What is normalization? What is SQL? What is transaction?

2 Data Redundancy & Inconsistency Data Redundancy: a lot of data is „unnecessarily” being duplicated Inconsistency :lack of internal unity

3 Anomaly of updated data Anomaly of deleted data Anomaly of inserted data The solution to this problem is to use a database that consists of several tables - a relational database Anomalies in database

4 Normalization The process of refining the structure of a database to minimise redundancy and improve integrity is called normalisation. When a database has been normalised, it is said to be in normal form. There are three normal forms:

5 First Normal Form A database is in first normal form if there are no repeated fields. That means that there must only be one field for each item of data you want to register. A database is in first normal form if there are no repeated fields. That means that there must only be one field for each item of data you want to register. Each line has a primary key from which the other data belongs. Each line has a primary key from which the other data belongs. (First normal form not only facilitates searching, but is also more space efficient.) (First normal form not only facilitates searching, but is also more space efficient.)

6 Second Normal Form Second Normal Form is already in first normal form is already in first normal form has no fields that aren't dependent on the whole of the key has no fields that aren't dependent on the whole of the key That is to say that all fields are dependent on the whole of the key (where there is a compound key) That is to say that all fields are dependent on the whole of the key (where there is a compound key) A database is said to be in second normal form if it:

7 Third Normal Form Third Normal Form A database is in third normal form if it: is already in second normal form it has no non-key dependencies (By non-key dependencies, we mean that there are no fields that are dependent on other fields that are not part of the key )

8 But forget all that! It still sounds a bit complicated to me. Don't try to start at first normal form, and then go to second normal form, and then to third. Once you've got the hang of it, you'll knock out databases in third normal form without even thinking about it. The key thing is to think about what your entities (or tables) are going to be - if you pick the right ones it'll normalise itself.

9 So, to get to third normal form, your non- repeating fields (first normal form) need to be dependent on the whole of the key (second normal form), and nothing other than the key (third normal form). It works for me! Well, don't forget it all, however, because you may be asked about normalisation in an exam. Here's a little tip to remember the three stages. - we call it the Normalisation Oath: Each attribute is dependent on the key, the whole key, and nothing but the key!

10 Testing software and test score database I. Entities: Entities: Class Teacher Students Score Grade Test Question Correct answer Software Student answer

11 Testing software and test score database II. Class Student Subject Enrolled Name Id Has Score Has Grade Teacher Name teaches Creates Test

12 Testing software and test score database III. Student Test gives Date Subject Has Student answer Question Has Corresct answer A,B,C.. Number Answer choices

13 Testing software and test score database IV. Software Student answerCorrect answer compare formula generates Score % value correlates Grade A,B,C..

14 What is SQL? SQL is a standard computer language for accessing and manipulating databases. SQL is a standard computer language for accessing and manipulating databases.

15 Notes SQL stands for Structured Query Language SQL stands for Structured Query Language SQL allows you to access a database SQL allows you to access a database SQL is an ANSI standard computer language SQL is an ANSI standard computer language SQL can execute queries against a database SQL can execute queries against a database SQL can retrieve data from a database SQL can retrieve data from a database SQL can insert new records in a database SQL can insert new records in a database SQL can delete records from a database SQL can delete records from a database SQL can update records in a database SQL can update records in a database SQL is easy to learn SQL is easy to learn

16 SQL is a Standard SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems. SQL statements are used to retrieve and update data in a database. SQL works with database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, etc

17 SQL Data Definition Language (DDL) The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can also define indexes (keys), specify links between tables, and impose constraints between database tables. The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can also define indexes (keys), specify links between tables, and impose constraints between database tables.

18 The most important DDL statements in SQL are: CREATE TABLE - creates a new database table CREATE TABLE - creates a new database table ALTER TABLE - alters (changes) a database table ALTER TABLE - alters (changes) a database table DROP TABLE - deletes a database table DROP TABLE - deletes a database table CREATE INDEX - creates an index (search key) CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index DROP INDEX - deletes an index

19 SQL Data Manipulation Language (DML) SQL (Structured Query Language) is a syntax for executing queries. But the SQL language also includes a syntax to update, insert, and delete records. SQL (Structured Query Language) is a syntax for executing queries. But the SQL language also includes a syntax to update, insert, and delete records. These query and update commands together form the Data Manipulation Language (DML) part of SQL: These query and update commands together form the Data Manipulation Language (DML) part of SQL:

20 The most important DML statements in SQL are: SELECT - extracts data from a database table SELECT - extracts data from a database table UPDATE - updates data in a database table UPDATE - updates data in a database table DELETE - deletes data from a database table DELETE - deletes data from a database table INSERT INTO - inserts new data into a database table INSERT INTO - inserts new data into a database table

21 The SELECT Statement The SELECT statement is used to select data from a table. The tabular result is stored in a result table (called the result-set). The SELECT statement is used to select data from a table. The tabular result is stored in a result table (called the result-set). Syntax Syntax SELECT column_name(s) FROM table_name SELECT column_name(s) FROM table_name

22 SQL The WHERE Clause The WHERE clause is used to specify a selection criterion. The WHERE clause is used to specify a selection criterion. Ex: Ex: SELECT * FROM Persons WHERE City='Sandnes‘ SELECT * FROM Persons WHERE City='Sandnes‘ SELECT * FROM Persons WHERE Year>1965 SELECT * FROM Persons WHERE Year>1965

23 The INSERT INTO Statement The INSERT INTO statement is used to insert new rows into a table. The INSERT INTO statement is used to insert new rows into a table. Syntax Syntax INSERT INTO table_name VALUES (value1, value2,....) INSERT INTO table_name VALUES (value1, value2,....) INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....) INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

24 The Update Statement The UPDATE statement is used to modify the data in a table. The UPDATE statement is used to modify the data in a table. Syntax Syntax UPDATE table_name SET column_name = new_value WHERE column_name = some_value UPDATE table_name SET column_name = new_value WHERE column_name = some_value We want to add a first name to the person with a last name of "Rasmussen": We want to add a first name to the person with a last name of "Rasmussen": UPDATE Person SET FirstName = 'Nina' WHERE LastName = 'Rasmussen' UPDATE Person SET FirstName = 'Nina' WHERE LastName = 'Rasmussen'

25 The Delete Statement The DELETE statement is used to delete rows in a table. The DELETE statement is used to delete rows in a table. Syntax Syntax DELETE FROM table_name WHERE column_name = some_value DELETE FROM table_name WHERE column_name = some_value

26 What is a Transaction? Logical unit of work Logical unit of work Must be either entirely completed or aborted Must be either entirely completed or aborted No intermediate states are acceptable No intermediate states are acceptable

27 Examine current account balance SELECT ACC_NUM, ACC_BALANCE FROM CHECKACC WHERE ACC_NUM = ‘ ’; Register credit sale of 100 units of product X to customer Y for $500 UPDATE PRODUCT SET PROD_QOH = PROD_QOH – 100 WHERE PROD_CODE = ‘X’; UPDATE ACCT_RECEIVABLE SET ACCT_BALANCE = ACCT_BALANCE WHERE ACCT_NUM =‘Y’; Consistent state only if both transactions are fully completed

28 TransactionTransaction Properties Transaction Atomicity Atomicity –All transaction operations must be completed –Incomplete transactions aborted Durability Durability –Permanence of consistent database state Serializability Serializability –Conducts transactions in serial order –Important in multi-user and distributed databases Isolation Isolation –Transaction data cannot be reused until its execution complete