1 Lecture 28 Introduction to Databases II - Database Design, SQL and JDBC Overview  Objectives of this Lecture  Logical Database Models  ER Model, Hierarchical.

Slides:



Advertisements
Similar presentations
Three-Step Database Design
Advertisements

The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Extended Learning Module C
Management Information Systems, Sixth Edition
ETEC 100 Information Technology
Oct 31, 2000Database Management -- Fall R. Larson Database Management: Introduction to Terms and Concepts University of California, Berkeley School.
Client/Server Databases and the Oracle 10g Relational Database
3-1 Chapter 3 Data and Knowledge Management
1 Database Systems (Part I) Introduction to Databases I Overview  Objectives of this lecture.  History and Evolution of Databases.  Basic Terms in Database.
“DOK 322 DBMS” Y.T. Database Design Hacettepe University Department of Information Management DOK 322: Database Management Systems.
Attribute databases. GIS Definition Diagram Output Query Results.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
IST Databases and DBMSs Todd S. Bacastow January 2005.
PHASE 3: SYSTEMS DESIGN Chapter 7 Data Design.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
COMPUTING FOR BUSINESS AND ECONOMICS-III. Lecture no.6 COURSE INSTRUCTOR- Ms. Tehseen SEMESTER- Summer 2010.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
6-1 DATABASE FUNDAMENTALS Information is everywhere in an organization Information is stored in databases –Database – maintains information about various.
Database Programming in Java Corresponds with Chapter 32, 33.
Web-Enabled Decision Support Systems
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Chapter 1Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Introduction to SQL Steve Perry
STORING ORGANIZATIONAL INFORMATION— DATABASES CIS 429—Chapter 7.
Database System Concepts and Architecture Lecture # 2 21 June 2012 National University of Computer and Emerging Sciences.
Concepts and Terminology Introduction to Database.
2005 SPRING CSMUIntroduction to Information Management1 Organizing Data John Sum Institute of Technology Management National Chung Hsing University.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
GUS: 0262 Fundamentals of GIS Lecture Presentation 3: Relational Data Model Jeremy Mennis Department of Geography and Urban Studies Temple University.
SQL Structured Query Language Programming Course.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
Relational Databases Database Driven Applications Retrieving Data Changing Data Analysing Data What is a DBMS An application that holds the data manages.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Storing Organizational Information - Databases
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
C-1 Management Information Systems for the Information Age Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Extended Learning Module.
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
1 Database & DBMS The data that goes into transaction processing systems (TPS), also goes to a database to be stored and processed later by decision support.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
WXGE 6101 DATABASE CONCEPTS & IMPLEMENTATIONS. Lesson Overview The Relational Model Terminology of relational model. Properties of database relations.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
Assoc. Prof. Dr. Ahmet Turan ÖZCERİT.  The concept of Data, Information and Knowledge  The fundamental terms:  Database and database system  Database.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
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.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Introduction to Database Programming with Python Gary Stewart
CSCI-100 Introduction to Computing
Databases and Information Management
Database Design Hacettepe University
Presentation transcript:

1 Lecture 28 Introduction to Databases II - Database Design, SQL and JDBC Overview  Objectives of this Lecture  Logical Database Models  ER Model, Hierarchical and Network data Model and Relational Model  JDBC  SQL  Preview: Data Communications and Networks

2 Lecture 28 Objectives of this Lecture  Understand the use of data modeling  Understand the different types of logical data models  Learn about Relational Data Model in detail  Understand the concept of JDBC  Learn about SQL

3 Lecture 28 Why to model data?  A model highlights the important aspects of a subject and obscures unimportant aspects of it.  A data model emphasizes features of interest to the user and makes its interaction with a DBMS transparent.  Physical data models show how the data structures are organized so that their resources are optimized.  Logical data models interprete the data in the context of the application.  The modeling phase of database design is crucial to assure an accurate representation of the user's perspective of the business.

4 Lecture 28 Logical Data Models  A logical data model is a design tool used in the design of a database system to emphasize features of interest to the user and makes interaction with a DBMS transparent.  A good logical data model is independent of the DBMS and can be moved from one management system to another.  Popular approaches to logical data models include:  1. Entity-Relationship model  2. Hierarchical and Network models.  3. Relational model.  Next we briefly discuss the Relational model.

5 Lecture 28 Relational Model  The most popular logical data model in use today is the relational model which is noted for its consistency, simplicity and data independence.  It is composed of relations, attributes, domains, keys, tuples and their representations.  A relation is a table of rows and columns. Each column of the table is an attribute.  The domain of each attribute is the collection of values that can be assigned to a particular attribute.  A principal key is one or more attribute values that uniquely identify an entity instance.  A tuple is an ordered sequence of elements. Example the sequence (p,q,r,s,t,u) is a 6-tuple. Each row is an entity instance represented by a tuple.

6 Lecture 28 Components of Relational Model Relational modeling has many interchangeable terms for its components as shown below:  Relation, table, file A two-dimensional table consisting of columns and rows; created from the entities of the object model.  Attribute, column, field The columns of the table, usually defined from the attributes of the object model.  Tuple, row, record The rows of the table; derived from the entity occurrences of the object model. Relations: A Relation is a two-dimensional table containing a set of related data. The true requirements of a relation are that:  Each cell must be atomic (contain only one value).  Each attribute contains the same type of physical and semantic information in all its cells.  Each tuple is unique; there can be no duplicate rows of data.  The order of columns and rows is not significant.

7 Lecture 28 Relation  Typically, relations have a representation consisting the relation name, followed by a list of attributes in form of a tuple with the principal key highlighted. e.g., ADVISOR (AdvId, Adv-Name, Adv-Phone)  The following shows a typical relational data model called an instance table. RELATION = ADVISORprimary key: AdvId AdvId Adv Name Adv Phone Sahalu Al-Ghamdi Sadiq Badhusha

8 Lecture 28 Relations (cont.)  The following table defines another relation for the entity Student with attributes StuID, StuName, StuPhone and AdvId. RELATION = STUDENT  In relational databases, new relations can be generated from others. For example, the relation “is advised by” can be defined between the relations STUDENT and ADVISOR. StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Fathah

9 Lecture 28 Definitions of Relational Terms  Primary key Primary keys are essential in relational modeling; one should be specified for each relation. A primary key uniquely identifies a record (or row) in a table; in other words, a particular primary key value returns a record that is identical to no other. A primary key is composed of one column (simple primary key) or a combination of columns (composite primary keys) that provide this unique identification. The best possibilities for primary keys are attributes that seldom change and are familiar to users. The primary key should contain the fewest columns needed to uniquely identify a record. Simple primary key:  Consider the relation ADVISOR where each value of Advisor ID returns a unique record. Simple primary key AdvId uniquely identifies records. AdvId AdvName AdvPhone Sahalu Al-Ghamdi Sadiq Badhusha

10 Lecture 28 Definitions of Relational Terms Composite primary key:  Consider the relation STUDENT where each student can take more than one course. Student ID, Class, or Grade alone does not return a unique record; however, a composite primary key of Student ID-Class does. Composite primary key Student ID-Course defines unique records.  Foreign key A foreign key is an attribute in a relation that is also a primary key in another relation. This foreign key-primary key match allows references between relations in order to locate information. StudentIDCourseGrade 1001COE ENG COE COE ICS COE10292

11 Lecture 28 Definitions of Relational Terms Foreign key Example :  Relation ADVISOR where AdvID is the primary key.  Relation STUDENT where StuID is the primary key and AdvID is a foreign key. RELATION = ADVISOR RELATION = STUDENT AdvId Adv Name Adv Phone Sahalu Al-Ghamdi Sadiq Badhusha StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal

12 Lecture 28 Communication with DB from Java Application  To communicate with the DB from Java application, we need the following. 1.An interface which connects Java application and the DBMS (JDBC - Drivers) 2.A language to communicate (SQL: Structured Query Language) 1.JDBC  JDBC TM API provides universal data access from the Java programming language. The JDBC API is a Java API for accessing virtually any kind of tabular data from relational databases.  To use the JDBC API with a particular database management system, you need a JDBC technology-based driver to mediate between JDBC technology and the database. The latest Java SDK includes a JDBC-ODBC Bridge driver that makes most Open Database Connectivity (ODBC) drivers available to programmers using the JDBC API. Java Application JDBC-ODBC Bridge Driver MS Access DBMS Engine DB Sending query Result of the query

13 Lecture 28 Communication with DB from Java Application 2.SQL  Structured Query Language is used to write queries to the database in order to get information from the database and to update the information to the DB  Here we will see some simple queries [their format and some simple examples]  SELECT  UPDATE  INSERT  SELECT  Format:  SELECT FROM [WHERE ] [GROUP BY ] [ORDER BY ]  Explanation:  For  a * is used to select all the columns of the specified table(s).  Individual columns can be selected by specifying the column names separated by comas.  If columns from different table are needed, then tablename.columnname is specified.

14 Lecture 28 Communication with DB from Java Application  For  A table name or list of table name is used  For  The operators are relational and logical and the operands are the column names  For and ]  List of columns are specified  Example:  SELECT StuId, StuName FROM STUDENT WHERE AdvId = “66102”  The table Result of the query Al-Quasim Al-Helal StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal

15 Lecture 28 Communication with DB from Java Application  UPDATE  Format  UPDATE SET = [WHERE ]; --if the Where clause is left out, all rows will be updated according to the Set statement.  Example  UPDATE STUDENT SET AdvId = “66109” WHERE StuId = “993421”  The table before update The table after update StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal

16 Lecture 28 Communication with DB from Java Application  INSERT  Format  INSERT INTO [( )] VALUES ( );  Example  INSERT INTO STUDENT VALUES (“994433”,”Al-Ghamdi”,” ”,”66105”)  The table before insert The table after insert StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal StuIdStuNameStuPhoneAdvId Al-Amer Al-Quasim Al-Ali Al-Helal Al-Ghamdi