Data.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
JDBC CS-328. JDBC Java API for accessing RDBMS Allows use of SQL for RDBMS programming Can be used for: –embedded SQL –execution of stored queries.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
CSC 2720 Building Web Applications Database and SQL.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
1 CSE 480: Database Systems Lecture 9: SQL-DDL Reference: Read Chapter of the textbook.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College.
Training - Day 3 OJB. What is OR Mapping? OR Mapping is the mapping of relational database tables to objects (Java Objects in our case) Many OR Mapping.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
Hive : A Petabyte Scale Data Warehouse Using Hadoop
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
CSC 2720 Building Web Applications Database and SQL.
CSc-340 3b1 Intermediate SQL Chapter 4 [2 of 2] Phase 1 of Student Projects SQL Data Types & Schemas Authorization.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
Visual Programing SQL Overview Section 1.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
Sql DDL queries CS 260 Database Systems.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
JDBC Part II CS 124. More about JDBC Types Statement versus PreparedStatement Timeout NULL values Meta-data close() methods Exceptions Transactions JDBC.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Working with MySQL A290/A590, Fall /07/2014.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CHAPTER 9 File Storage Shared Preferences SQLite.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
Introduction to Database Programming with Python Gary Stewart
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
Introduction to SQL. Relational databases  Practical level: A data storage that can effectively been queried with SQL query language  A database consists.
Notice: MySQL is a registered trademark of Sun Microsystems, Inc. MySQL Conference & Expo 2011 Michael “Monty” Widenius Oleksandr “Sanja”
3 A Guide to MySQL.
Fundamentals of DBMS Notes-1.
CPSC-310 Database Systems
CS320 Web and Internet Programming SQL and MySQL
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
Lecture 6 Data Model Design (continued)
Principles of Software Development
What is Database Administration
Translation of ER-diagram into Relational Schema
Design and Implementation of Software for the Web
DATABASE MANAGEMENT SYSTEM
From ER to Relational Model
Teaching slides Chapter 8.
Database systems Lecture 2 – Data Types
CIS 136 Building Mobile Apps
Intro to Relational Databases
CMPT 354: Database System I
CS3220 Web and Internet Programming SQL and MySQL
Physical Data Modeling – Implementation
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
Database Instructor: Bei Kang.
JDBC II IS
Presentation transcript:

Data

Java E-Commerce © Martin Cooke, 2003 Plan Issues in data-handling Relational database and SQL refresher XML vs relational databases Next lecture: Java database connectivity API (JDBC) 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Issues in data handling on the web

Java E-Commerce © Martin Cooke, 2003 persistent? structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Granting immortality to your data instances Persistence = data living beyond the immediate lifecycle of the processes manipulating it A relational database is the primary tool for persistence, and has been for decades Can be handled automatically using an appropriate ‘container’ (see EJBs) structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Free text Most of the web Tabular Vast amounts of existing data (forced into tabular form?) Tree-structured Marked up content eg XML Tedious to handle relationally Arbitrary object Images, sound files Tricky to handle relationally Object-relational or object database structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Free text Most of the web Tabular Vast amounts of existing data (forced into tabular form?) Tree-structured Marked up content eg XML Tedious to handle relationally Arbitrary object Images, sound files Tricky to handle relationally Object-relational or object database structure? portable? available? concurrent access? secure? transactionally safe? Our focus in this lecture is on tabular data 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Vast volumes of data must be … searched rapidly … available 24x7 (eg credit card checking) … accessible by many concurrent users Rely on optimised database engines which have been honed over the years structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Modification Dirty reads and writes Pessimistic vs optimistic concurrency Efficiency How to manage multiple connections? Expensive to create Limited in number for typical databases structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? To maintain consistency, it often makes sense to carry out a group of changes (a transaction) to data credit card db and order db If one statement in the transaction fails, data can be left in an inconsistent state must be able to unwind (rollback) the transaction structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Just how secure are files left lying around the place? Again, rely on existing secure solution in relational database Introduces its own layer of authentication structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 persistent? Java may be portable, but what about its dependence on existing databases? Ideally, no vendor tie-in avoid legacy data problems in future Tricky in practice since industry standard (SQL) is not as standard as it seems structure? portable? available? concurrent access? secure? transactionally safe? 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Relational database and SQL refresher Nobody fails the databases course

(Relational) data model student module lecturer 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 id name 1 Java 2 Databases … student stud/mod module sid mid 1 2 id name SSID 1 B Black 12456541 2 J Brown 97625516 … lecturer 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 SQL CREATE command student stud/mod module id name SSID 1 B Black 12456541 2 J Brown 97625516 … lecturer CREATE TABLE student ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(4), SSID INT DEFAULT 0 ) CREATE TABLE student ( id INT, name TEXT, SSID INT ) 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 SELECT statement id name 1 Java 2 Databases … student stud/mod module sid mid 1 2 id name SSID 1 B Black 12456541 2 J Brown 97625516 … lecturer SELECT module.name FROM module,student,studMod WHERE module.id = mid AND student.name = ‘B Black’ AND student.id = studMod.sid; SELECT name FROM student WHERE id = 2; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 CREATE and INSERT CREATE TABLE student ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50) NOT NULL, SSID INT DEFAULT 0 ); INSERT INTO student VALUES(1,'Joe Bloggs',12345678); INSERT INTO student VALUES(20,'Bob Black',null); INSERT INTO student VALUES(4,'Gill Brown',23267656); 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 SELECT SELECT * FROM student; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 UPDATE UPDATE student SET name = ‘Gill Bloggs’ WHERE id = 4; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 JOIN Find all modules taken by Bob Black 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Other SQL DELETE Deletes rows from a table DELETE FROM student WHERE name=‘fred’; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Other SQL DELETE Deletes rows from a table DELETE FROM student WHERE name=‘fred’; DROP Permanently remove database or table from the system DROP DATABASE studs; DROP TABLE student; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Other SQL DELETE Deletes rows from a table DELETE FROM student WHERE name=‘fred’; DROP Permanently remove database or table from the system DROP DATABASE studs; DROP TABLE student; DESCRIBE Give information about a table or column DESCRIBE student; 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Other SQL DELETE Deletes rows from a table DELETE FROM student WHERE name=‘fred’; DROP Permanently remove database or table from the system DROP DATABASE studs; DROP TABLE student; DESCRIBE Give information about a table or column DESCRIBE student; SHOW Display information about system SHOW DATABASES SHOW TABLES [FROM db] 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Datatypes SQL2 BIT, TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, CHAR, VARCHAR, LONGVARCHAR, DATE, TIME, TIMESTAMP, BINARY, VARBINARY, LONGVARBINARY emphasis on Primitive types Storage size SQL3 BLOB, CLOB, ARRAY, REF, STRUCT 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 More on datatypes Different database engines support their own types internally and loosely translate to an SQL2 type Big mismatch between rich Java type possibilities and SQL datatypes Care needed, though JDBC helps (later) 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Choices and integrations Relational data vs XML Choices and integrations

Persistence is not the issue Need to consider questions of data representation and persistence separately Can store/retrieve XML as a string on a relational database 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Which to use? pros cons XML Good for complex data Reasonably good fit to object-based software Storage-hungry Slow to build and search documents Relational data Good for tabular data Optimised for memory and speed, especially for multi-factor searches Tricky for tree-structured data Very tricky for arbitrary objects: needs transformation 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Complementary aspects Store XML together with some search terms Convert SQL to XML Represent SQL query in XML 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Resources

Java E-Commerce © Martin Cooke, 2003 Book Yarger, Reese and King (1999) MySQL and mSQL, O’Reilly, 1-56592-434-7 Check if later version 14/04/2019 Java E-Commerce © Martin Cooke, 2003

Java E-Commerce © Martin Cooke, 2003 Online documents An online SQL interpreter http://www.dcs.napier.ac.uk/~andrew/sql/ 14/04/2019 Java E-Commerce © Martin Cooke, 2003