13.11.2015 DAT602 Database Application Development Lecture 2 Review of Relational Database.

Slides:



Advertisements
Similar presentations
Chapter 4 5 6_ SQL SQL Is: Structured Query Language
Advertisements

Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Introduction to Structured Query Language (SQL)
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 © Prentice Hall, 2002 Chapter 7: SQL Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
1 IS 4420 Database Fundamentals Chapter 7: Introduction to SQL Leon Chen.
Introduction to Structured Query Language (SQL)
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Oracle Data Definition Language (DDL)
Overview of SQL Server Alka Arora.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Concepts and Terminology Introduction to Database.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
CSC 2720 Building Web Applications Database and SQL.
Lecturer: Gareth Jones. How does a relational database organise data? What are the principles of a database management system? What are the principal.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
DATABASE TRANSACTION. Transaction It is a logical unit of work that must succeed or fail in its entirety. A transaction is an atomic operation which may.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 Outline  What is a Primary Key?  AutoNumber primary keys  Single-field primary keys  Composite-field primary key  About Foreign Keys  Database.
Relational Database. Database Management System (DBMS)
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
DAT602 Database Application Development Lecture 4 Database Design.
Lec 3- B Database Integrity 1. Overview Define a database using SQL data definition language Work with Views Write single table queries Establish referential.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
Relational Theory and Design
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
SQL Overview Structured Query Language
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Chapter 4 The Relational Model Pearson Education © 2009.
Big Data Yuan Xue CS 292 Special topics on.
Standards and Conventions
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Teaching slides Chapter 8.
Chapter 4 The Relational Model Pearson Education © 2009.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 11 Managing Databases with SQL Server 2000
Creating Database Objects
Microsoft Access Date.
Presentation transcript:

DAT602 Database Application Development Lecture 2 Review of Relational Database

What is relational database ? A relational database is a database that groups data using common attributes found in the data set. Relational databases use Table to organize all data. Database is consisted by tables. Database Application Development - Lecture 2

Tables of simple database of online-shop. Database Application Development - Lecture 2 UserInfo ID Name Password Item ID Name Price Description Transaction ID Date Buyer ItemID Amount

Some basic terms you should be familiar with Table All data in a relational database is explicitly represented at the logical level as values in tables. Row Cells in the same row are members of a group of related items. Column Cells in the same column are members of a set of similar items. Key Each table defines a key made up of one or more columns that uniquely identify each row. Database Application Development - Lecture 2

Database Application Development - Lecture 2 Source : Java Database Programming Bible. by John O'Donahue ISBN:

Primary Keys Each table can have only one primary key, which can be any column or group of columns in the table having a unique value for each row. Primary keys can be simple or composite. A simple key is a key made up of one column, whereas a composite key is made up of two or more columns. Database Application Development - Lecture 2

Primary Keys In practice, the most common type of key is a column of unique integers specifically created for use as the primary key. For example: Customer ID, personal ID, etc. NOTE: Normally, using integers is more efficient than string. Primary key can not be NULL. Database Application Development - Lecture 2

Foreign Keys A foreign key is a column in a table used to reference a primary key in another table. By using primary – foreign keys pair, developers can combine multiple tables together. See following example. Database Application Development - Lecture 2

Database Application Development - Lecture 2 Source : Java Database Programming Bible. by John O'Donahue ISBN:

View A view is a virtual table whose contents are defined by a query. Normally, a view does not exist as a stored set of data values in a database. The rows and columns of data come from tables referenced in the query defining the view and are produced dynamically when the view is referenced. Database Application Development - Lecture 2

Database Application Development - Lecture 2 Example of View

Why we need view ? A view acts as a filter on the underlying tables referenced in the view. The query that defines the view can be from one or more tables or from other views in the current or other databases. Database Application Development - Lecture 2

Index One of purposes of creating index is accelerating retrieval speed. By applying index, query operation does not need to scan all records for getting matched result. Index sorts all records by specific rule. Database Application Development - Lecture 2

Example of index Database Application Development - Lecture 2 Word (index) … Easy File Fish Game Geek Greece Machine … Word … Greece Machine Fish Easy Game File Geek … Un-indexed tableIndexed table

What is transaction ? A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of work must exhibit four properties, called the atomicity, consistency, isolation, and durability (ACID) properties, to qualify as a transaction. Database Application Development - Lecture 2

ACID - atomicity : either all of its data modifications are performed, or none of them is performed. - consistency : When completed, a transaction must leave all data in a consistent state - isolation : Modifications made by concurrent transactions must be isolated from the modifications made by any other concurrent transactions. - durability : After a transaction has completed, its effects are permanently in place in the system. Database Application Development - Lecture 2

Example of Transaction A transaction is a group or sequence of commands, all of which must be executed in order and all of which must completed successfully. Database Application Development - Lecture 2 Select items Confirm select items Pay online Confirm payment Save deal

Roll back Failure of any single step of transaction can cause cancellation of whole transaction. All involved data must be restored. Committed All steps of transaction must be completed to make transaction be committed. Database Application Development - Lecture 2

Relationships Tables can be related in one of three ways: -One-to-one every row in the first table has a corresponding row in the second table. -One-to-many -Many-to-many Database Application Development - Lecture 2

One-to-many Every row in the first table can have zero, one, or many corresponding rows in the second table. But for every row in the second table, there is exactly one row in the first table. Database Application Development - Lecture 2 User_ID User_Name 1Amy 2Bob 3Chase 4Daisy User_IDFlight_NO 1CK912 2LH1908 2SA209 3JD109 3RG94 3TG234 3HG47 Table: User_Info Table: Flight_Info

Many-to-many relationship Many-to-many relationships can't be directly modeled in a relational database. They must be broken into multiple one-to-many relationships. Database Application Development - Lecture 2

Managing Database Users Give different authorities to different kinds of users. Administrators have highest authority, such as create, delete tables. Generally, normal users have limited authority, they can alter data, but can’t delete or create tables. Database Application Development - Lecture 2

Different database systems have different data types. They share some common types. Some useful data type of Microsoft SQL Server float, money, datetime, Smalldatetime, varchar, char, bit, int, image Database Application Development - Lecture 2

Database Application Development - Lecture 2 Type Float, Int moneyCan be negative SmalldatetimeFrom Jan 1, 1900 to Jun 6, 2079, 1 minute accuracy char Fixed-length non-Unicode character data with a maximum length of 8,000 characters varchar Variable-length non-Unicode data with a maximum of 8,000 characters. Text Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters. image Variable-length binary data with a maximum length of 2,147,483,647 bytes bit0 or 1, true of false Some useful data type of Microsoft SQL Server

Literature used “Java Database Programming Bible”, by John O'Donahue ISBN: John Wiley & Sons © 2002 Chapter 1 Database Application Development - Lecture 2