Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.

Slides:



Advertisements
Similar presentations
Database Chapters.
Advertisements

MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
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.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
SQLLite and Java CS-328 Dick Steflik. SQLLite Embedded RDBMS ACID Compliant Size – about 257 Kbytes Not a client/server architecture –Accessed via function.
SQLite 1 CS440. What is SQLite?  Open Source Database embedded in Android  SQL syntax  Requires small memory at runtime (250 Kbytes)  Lightweight.
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 SQL  SQL or sequel  It is a standardised language with thousands of pages in the standard  It can be in database system through GUI,
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
MySql In Action Step by step method to create your own database.
Copyright © Curt Hill SQL The Data Definition Language.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
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 8 Part 1 SQL-99 Schema Definition, Constraints, Queries, and Views.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
LIS651 lecture 6 mySQL Thomas Krichel
Introduction to MySQL Lab no. 10 Advance Database Management System.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Overview · What is PL/SQL · Advantages of PL/SQL · Basic Structure of a PL/SQL Block · Procedure · Function · Anonymous Block · Types of Block · Declaring.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
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.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
Visual Programing SQL Overview Section 1.
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
Sql DDL queries CS 260 Database Systems.
SQLite DB Storing Data in Android RAVI GAURAV PANDEY 1.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
CHAPTER 9 File Storage Shared Preferences SQLite.
1 Designing Tables for a Database System. 2 Where we were, and where we’re going The Entity-Relationship model: Used to model the world The Relational.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Introduction to Database Programming with Python Gary Stewart
Phonegap Bridge – Storage CIS 136 Building Mobile Apps 1.
Creating Database Objects
Cosc 5/4730 Sqlite primer.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
CIS 136 Building Mobile Apps
Lecture 6 Data Model Design (continued)
SQL – Data types.
Designing Tables for a Database System
Database systems Lecture 2 – Data Types
CIS 136 Building Mobile Apps
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Data.
MySQL Database System Installation Overview SQL summary
SQLLite and Android.
Creating Database Objects
Database Instructor: Bei Kang.
JDBC II IS
SQL (Structured Query Language)
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Phonegap Bridge – File System CIS 136 Building Mobile Apps 1

Storage Options Storage API 2

3  Implements a simple database application  full-featured database tables accessed via SQL queries  Based on SQLLite database 

Methods 4 openDatabase() –  Creates a new SQLLite database or opens one that has already been created  database is in persistent storage  This method returns a database object that allows manipulation of the data  transaction()–  executes SQL statements  if any statement fails, any changes that have been made are discarded (roll back)  executeSql()-

openDatabase() method 5  Fours parameters  db_name: name of the database – this is the filename given tio the database when its written to memory; text  db_version: version number (usually 1.0); text  db_display_name: display name for the database; text  db_size: amount of space allocated to the database in bytes

6 // Wait for device API libraries to load document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available function onDeviceReady() { var appDB = window.openDatabase(“myDB”,”1.0”,”notes”, 1024*1024); //1MB }

transaction() method 7  three parameters  Transaction SQL: SQL code to execute  Usually contained in a function  Receives a transaction object which is used to execute the SQL statements  Executes a method called executeSql  Error: function to execute if a SQL error occurs  receives two objects  First object – can be used to execute more SQL statements  Second object – error object having a code and message property  Success: function to execute if SQL works (optional)  Does not receive any objects NOTE: error function precedes success function

8 document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var appDB = window.openDatabase(“myDB”,”1.0”,”notes”, 1024*1024); //1MB appDB.transaction(txnSQLn,onTxnError,onTxnSuccess); } function txnSQL() { } function onTxnError() { } function onTxnSuccess() { }

Transaction error() method 9 function onTxnError(sqltext, err) { if (err) { alert (“code: + err.code + “ msg: “ + err.message ) } Else alert(“Unknown error”) }

Transaction Error Codes 10  UNKNOWN_ERR = 0;  DATABASE_ERR = 1;  VERSION_ERR = 2;  TOO_LARGE_ERR = 3;  QUOTA_ERR = 4;  SYNTAX_ERR = 5;  CONSTRAINT_ERR = 6;  TIMEOUT_ERR = 7;

Transaction success() method 11 function onTxnSuccess() { alert (“transaction succeeded”); }

Transaction Sql – you name the function 12  Gets a transaction object  Builds a SQL statement  the instructions for the database action  Create table, Select, Insert, Update, Delete records  Executes the SQL statement using the executeSql() method  executeSql() has four parameters  The SQL statement  The values passed to the SQL statement (if any)  Where to go if the SQL statement works (a Success function)  Where to go if the SQL statement fails ( Error function)

Inside the Transaction SQL function 13 function CreateTable(txn) { var sqlString = ‘CREATE TABLE IF NOT EXISTS STUDENTS (StudentID TEXT, FirstName TEXT, LastName TEXT, TEXT)’; txn.executeSql(sqlString, [], onSqlSuccess(), onSqlError(); }

Syntax for Creating Tables 14  The "CREATE TABLE" command is used to create a new table in an SQLite database  A CREATE TABLE command specifies the following attributes of the new table:  The name of the new table.  The database in which the new table is created  Tables may be created in the main database, the temp database, or in any attached database.  The name of each column (field) in the table.  The declared data type of each column in the table  A default value or expression for each column in the table  A default collation sequence to use with each column  Optionally, a PRIMARY KEY for the table  A set of SQL constraints for each table. SQLite supports UNIQUE, NOT NULL, CHECK and FOREIGN KEY constraints.  Whether the table is a WITHOUT ROWID table (a ROWID uniquely identifies each row )WITHOUT ROWID

Data Types 15  NULL  The value is a NULL value.  INTEGER  The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.  Boolean values are integers 0 and 1  Can store a date as an integer using date/time functions - as Unix Time, the number of seconds since :00:00 UTC.  REAL  The value is a floating point value, stored as an 8-byte IEEE floating point number  Can store a date as a real number using date/time functions  Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar  TEXT  The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF- 16LE)  Can store a date as text using date/time functions ("YYYY-MM-DD HH:MM:SS.SSS").  BLOB. The value is a blob of data, stored exactly as it was input.

Affinities 16  common datatype names from more traditional SQL implementations are converted into affinities INT INTEGER TINYINT SMALLINT MEDIUMINT BIGINT UNSIGNED BIG INT INT2 INT8 INTEGER CHARACTER(20) VARCHAR(255) VARYING CHARACTER(255) NCHAR(55) NATIVE CHARACTER(70) NVARCHAR(100) TEXT CLOB TEXT BLOB REAL DOUBLE DOUBLE PRECISION FLOAT REAL NUMERIC DECIMAL(10,5) BOOLEAN DATE DATETIME NUMERIC

Example 17 CREATE TABLE COMPANY( ID INT PRIMARY KEY ASC NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );