SQLite Database. References. Overview. Structured Databases

Size: px
Start display at page:

Download "SQLite Database. References. Overview. Structured Databases"

Transcription

1 SQLite Database References Android Developers Article Android SQLite Package Reference Android SQLiteDatabase Class Reference SQLite Wikipedia Article The SQLite Language Overview Android provides every app access to a SQLite database. This database provides persistent storage for structured data while the app is installed on the mobile device. Per the SQLite Wikipedia page, SQLite implements most of the SQL-92 standard for SQL but it lacks some features. The database is stored in a single file and uses a set of function calls to access the file rather than a DBMS running in a separate process. Structured Databases Structured databases use tables to store information. Each table typically models an entity in application. For example, if you are writing a messaging app that allows users to send messages to other users, you may have one table to store data about the users and a separate table to store messages. Each table has a set of columns, each with a type and name. The set of columns in a table will often be correspond to the set of fields in an entity class in your app. The types of each column must be TEXT, NUM, INT, REAL or have no type. The types are described here:

2 Consider the following User class. public class User { private String username; private String password; private String ;... A SQLite table that stores information about users may conceptually look like the following: Row username (TEXT) Password (TEXT) (TEXT) 1 Ayo Ou812 ayo@cstome.net 2 Babak pearl_jam! bb@tigo.co.tz When a table mirrors an entity class in an app, each row in the table corresponds to a different instance of the class. Defining Schema via Contracts A schema is a formal declaration that describes how a database is organized. Android recommends we implement classes, called contracts, that each define the columns in a table. Since a contract represents a table, I like to end the name of my contract classes with _T to differentiate them from my entity classes. A contract for the user table might look like the following:

3 public final class Users_T implements BaseColumns { private Users_T() { // Makes class non-instantiable public static final String TABLE_NAME = "users"; /* Columns */ // The BaseColumn interface provides a field named _ID public static final String USERNAME = "username"; public static final String PASSWORD = "password"; public static final String = " "; /* SQL Statements */ public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY, " + USERNAME + " TEXT NOT NULL, " + PASSWORD + " TEXT NOT NULL, " + + " TEXT NOT NULL UNIQUE)";

4 public static final String DELETE_TABLE = "DELETE TABLE IF EXISTS " + TABLE_NAME; public static final String GET_PASSWORD = "SELECT " + PASSWORD + " FROM " + TABLE_NAME + " WHERE " + + "=?"; public static final String GET_USER = "SELECT *" + " FROM " + TABLE_NAME + " WHERE " + + "=?"; Notice the following properties of the class: 1. The class is public final. This enforces that it is visible outside its package but is not modifiable. 2. The class name is Users_T. This differentiates it from the entity class named Users. 3. The constructor is private. Since it is never called in the class, the class is never instantiated.

5 4. All of the fields are public static final making them visible outside the class, accessible without an instance of the class, and constant respectively. 5. All of the field names are capitalized and use underscores to separate words. This makes it easy to distinguish them from entity class field names. 6. The fields hold the name of the table, the column names and SQLite statements. 7. The values of table and column fields ( users, user_name, ) are identifiers used by the SQLite database library. The only restriction to these identifiers is that they cannot begin with sqlite_. In fact, though poor practice, they can include keywords, symbols and the empty string. Since the fields in the contract class are public and static they can be used throughout the application without creating an instance of the class. For example, to use the name of the table we use Users_T.TABLE_NAME and the use the GET_USER SQL statement we would use Users_T.GET_USER. A Little Lesson on SQL This isn t a course on databases, so we ll only use basic SQL (structured query language) statements; those to add tables, delete tables, add entries to a table, delete entries from a table and simple queries. Creating Tables public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + USERNAME + " TEXT NOT NULL, " + PASSWORD + " TEXT NOT NULL, " + + " TEXT NOT NULL PRIMARY KEY)";

6 The above statement is a SQL statement that creates a table in the database if a table with the same name does not yet exist in the database. Within the parenthesis are column expressions that define each of the columns in the table. Each column has a column name followed by the type of data allowed in the column followed by other parameters that restrict what data can be stored in the column. The key words NOT NULL indicate that empty strings cannot be stored in the column. The key words PRIMARY KEY specify that no two rows in the table can have the same value (among other things). Querying Tables public static final String GET_PASSWORD = "SELECT " + PASSWORD + " FROM " + TABLE_NAME + " WHERE " + + "=?"; The SQL statements that we we ll use aren t actually complete SQL statements. The SQLite method that we ll use to send this query to the database has two parameters, a query statement and a value. The method will replace the? in the query with the value passed in the second parameter (more on this later). The above query will return a set of password values from the rows that have a value in the column that match the value after the equal sign. Since we defined the column as being UNIQUE, at most 1 row will be selected and returned. public static final String GET_USER = "SELECT *" + " FROM " + TABLE_NAME + " WHERE " + + "=?";

7 The above query will return all of the column data (*) from the rows that have a value in the column that match the value after the equal sign (? will be replaced by an actual address). A LocalDB Class It s helpful to create a separate class that will contain ALL of the code necessary to CRUD (create, read, update and delete) tables in the database. We ll name this class LocalDB. The class has 4 purposes: Define private fields and public constants Provide a private inner class that extends SQLiteOpenHelper Provide methods for opening and closing the database Provide public methods to CRUD tables Private Fields and Public Constants public class LocalDB { // ERROR LOGGING TAG private static final String TAG = "LocalDB"; // DB INFO private static final String DATABASE_NAME = "Messager_DB"; private static final int DATABASE_VERSION = 1; // DB OBJECTS private static DatabaseHelper dbhelper = null; private static SQLiteDatabase db = null;

8 // RETURN CODES FOR USER METHODS public static final int FAILURE = -1; public static final int SUCCESS = 0; public static final int _ALREADY_EXISTS = 1;... The TAG field is used when printing messages to the console via the Log methods. Logging to the console is an invaluable tool for debugging sqlite code. See below for example uses of the Log methods. The fields DATABASE_NAME and DATABASE_VERSION are used when creating the database in the DatabaseHelper class given below. We don t want to keep the database open all of the time as it takes up system resources, so we use the static fields dbhelper and db to determine if the database is open or closed. If db is null the database is closed. The last set of fields (FAILURE, SUCCESS, _ALREADY_EXISTS) are used to determine if we were successfully able to add a user to the database. Creating a Private Inner Helper Class private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION);

9 @Override public void oncreate(sqlitedatabase _db) { public void onupgrade(sqlitedatabase _db, int oldversion, int newversion) { Log.w(TAG, "Upgrading application's database from version " + oldversion + " to " + newversion + ", which will destroy all old data!"); _db.execsql(users_t.delete_table); oncreate(_db); The DatabaseHelper class provides methods to create the database (and tables) and upgrade the database should the value of DATABASE_VERSION change. Methods for Opening and Closing the Database public static void opendb(context c) { if (db == null) {

10 dbhelper = new DatabaseHelper(c); db = dbhelper.getwritabledatabase(); public static void closedb() { db = null; dbhelper.close(); The opendb() and closedb() methods are used to open and close the database. Before we call any of the user methods defined below we must call opendb() and after we are finished calling the user methods we must close the database by calling closedb(). User Methods public static int adduser(user user) { assert(db!= null); if ( exists(user.get ())) return _ALREADY_EXISTS;

11 ContentValues values = new ContentValues(3); values.put(users_t.username, user.getusername()); values.put(users_t. , user.get ()); values.put(users_t.password, user.getpassword()); long results = db.insert(users_t.table_name, null, values); if (results == -1) return FAILURE; else return SUCCESS; public static int deleteuser(string ) { assert(db!= null); Log.d(TAG, "Deleting: " + ); int res = db.delete(users_t.table_name, Users_T. + " = " + +, null);

12 if (res == 0) { Log.d(TAG, "no rows deleted from excursion table"); return res; public static User getuser(string ) { assert(db!= null); String query = Users_T.GET_USER; String[] data = { ; Cursor c = db.rawquery(query, data); if (c == null c.getcount() == 0) { return null; c.movetofirst(); String username = c.getstring(c.getcolumnindex(users_t.username));

13 String password = c.getstring(c.getcolumnindex(users_t.password)); return new User(username, password, ); public static boolean exists(string ) { assert(db!= null); String query = Users_T.GET_USER; String[] data = { ; Cursor c = db.rawquery(query, data); if (c == null c.getcount() == 0) { return false; else { return true;

14 // END OF LocalDB

An Android Studio SQLite Database Tutorial

An Android Studio SQLite Database Tutorial An Android Studio SQLite Database Tutorial Previous Table of Contents Next An Android Studio TableLayout and TableRow Tutorial Understanding Android Content Providers in Android Studio Purchase the fully

More information

Database Development In Android Applications

Database Development In Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran

More information

07. Data Storage

07. Data Storage 07. Data Storage 22.03.2018 1 Agenda Data storage options How to store data in key-value pairs How to store structured data in a relational database 2 Data Storage Options Shared Preferences Store private

More information

Mobile Computing Practice # 2d Android Applications Local DB

Mobile Computing Practice # 2d Android Applications Local DB Mobile Computing Practice # 2d Android Applications Local DB In this installment we will add persistent storage to the restaurants application. For that, we will create a database with a table for holding

More information

CSCU9YH: Development with Android

CSCU9YH: Development with Android : Development with Android Computing Science and Mathematics University of Stirling Data Storage and Exchange 1 Preferences: Data Storage Options a lightweight mechanism to store and retrieve keyvalue

More information

Android: Data Storage

Android: Data Storage Android: Data Storage F. Mallet Frederic.Mallet@unice.fr Université Nice Sophia Antipolis Outline Data Storage Shared Preferences Internal Storage External Storage SQLite Databases Network Connection F.

More information

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza Data persistence Shared preferences A method to store primitive data in android as key-value pairs, these saved data will

More information

SQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite

SQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite SQLite 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases Dr Dimitris C. Dracopoulos SQLite is a tiny yet powerful database engine. Besides Android, it can be found in: Apple iphone

More information

In-app Billing Version 3

In-app Billing Version 3 13 In-app Billing Version 3 Bruno Oliveira Developer Relations, Android 13 In-app billing! 2 In-app billing! Implement ALL the billing! 2 In-app billing! DO NOT WANT 2 PREVIOUSLY IN IN-APP BILLING 3 Easy

More information

Data storage and exchange in Android

Data storage and exchange in Android Mobile App Development 1 Overview 2 3 SQLite Overview Implementation 4 Overview Methods to implement URI like SQL 5 Internal storage External storage Overview 1 Overview 2 3 SQLite Overview Implementation

More information

Firebase Realtime Database. Landon Cox April 6, 2017

Firebase Realtime Database. Landon Cox April 6, 2017 Firebase Realtime Database Landon Cox April 6, 2017 Databases so far SQLite (store quiz progress locally) User starts app Check database to see where user was Say you want info about your friends quizzes

More information

CS371m - Mobile Computing. Persistence - SQLite

CS371m - Mobile Computing. Persistence - SQLite CS371m - Mobile Computing Persistence - SQLite In case you have not taken 347: Data Management or worked with databases as part of a job, internship, or project: 2 Databases RDBMS relational data base

More information

Sqlite Update Failed With Error Code 19 Android

Sqlite Update Failed With Error Code 19 Android Sqlite Update Failed With Error Code 19 Android i'm wrote simple DataBaseHelper to use SQlite in android. after create class as : static final int DATABASE_VERSION = 1, private SQLiteDatabase mdatabase,

More information

CS378 -Mobile Computing. Persistence -SQLite

CS378 -Mobile Computing. Persistence -SQLite CS378 -Mobile Computing Persistence -SQLite Databases RDBMS relational data base management system Relational databases introduced by E. F. Codd Turing Award Winner Relational Database data stored in tables

More information

The Basis of Data. Steven R. Bagley

The Basis of Data. Steven R. Bagley The Basis of Data Steven R. Bagley So far How to create a UI View defined in XML Java-based Activity as the Controller Services Long running processes Intents used to send messages between things asynchronously

More information

Object-Oriented Databases Object-Relational Mappings and Frameworks. Alexandre de Spindler Department of Computer Science

Object-Oriented Databases Object-Relational Mappings and Frameworks. Alexandre de Spindler Department of Computer Science Object-Oriented Databases Object-Relational Mappings and Frameworks Challenges Development of software that runs on smart phones. Data needs to outlive program execution Use of sensors Integration with

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

MOBILE APPLICATIONS PROGRAMMING

MOBILE APPLICATIONS PROGRAMMING Data Storage 23.12.2015 MOBILE APPLICATIONS PROGRAMMING Krzysztof Pawłowski Polsko-Japońska Akademia Technik Komputerowych STORAGE OPTIONS Shared Preferences SQLite Database Internal Storage External Storage

More information

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. Enums Introduction In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. The Final Tag To display why this is useful, I m going to

More information

Debojyoti Jana (Roll ) Rajrupa Ghosh (Roll ) Sreya Sengupta (Roll )

Debojyoti Jana (Roll ) Rajrupa Ghosh (Roll ) Sreya Sengupta (Roll ) DINABANDHU ANDREWS INSTITUTE OF TECHNOLOGY AND MANAGEMENT (Affiliated to West Bengal University of Technology also known as Maulana Abul Kalam Azad University Of Technology) Project report on ANDROID QUIZ

More information

Mobile and Ubiquitous Computing: Android Programming (part 4)

Mobile and Ubiquitous Computing: Android Programming (part 4) Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,

More information

ADF Mobile Code Corner

ADF Mobile Code Corner ADF Mobile Code Corner m05. Caching WS queried data local for create, read, update with refresh from DB and offline capabilities Abstract: The current version of ADF Mobile supports three ADF data controls:

More information

How-to s and presentations. Be prepared to demo them in class. https://sites.google.com/site/androidhowto/presentati ons

How-to s and presentations. Be prepared to demo them in class. https://sites.google.com/site/androidhowto/presentati ons Upcoming Assignments Readings: Chapter 6 by today Lab 3 due today (complete survey) Lab 4 will be available Friday (due February 5) Friday Quiz in Blackboard 2:10-3pm (Furlough) Vertical Prototype due

More information

Android Application Model II. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model II. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model II CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Outline Activity Lifecycle Services Persistence Content

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 P a g e 1 CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 Q1 Describe some Characteristics/Advantages of Java Language? (P#12, 13, 14) 1. Java

More information

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Data Modelling and Databases. Exercise Session 7: Integrity Constraints Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling

More information

Chapter 4: Writing Classes

Chapter 4: Writing Classes Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own

More information

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL functions fit into two broad categories: Data definition language Data manipulation language Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my

More information

App Development for Smart Devices. Lec #5: Content Provider

App Development for Smart Devices. Lec #5: Content Provider App Development for Smart Devices CS 495/595 - Fall 2011 Lec #5: Content Provider Tamer Nadeem Dept. of Computer Science Some slides adapted from Jussi Pohjolainen and Bob Kinney Objective Data Storage

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

Assertions, pre/postconditions

Assertions, pre/postconditions Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What

More information

Mobile Programming Lecture 10. ContentProviders

Mobile Programming Lecture 10. ContentProviders Mobile Programming Lecture 10 ContentProviders Lecture 9 Review In creating a bound service, why would you choose to use a Messenger over extending Binder? What are the differences between using GPS provider

More information

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search Goal Generic Programming and Inner classes First version of linear search Input was array of int More generic version of linear search Input was array of Comparable Can we write a still more generic version

More information

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Chapter # 7 Introduction to Structured Query Language (SQL) Part I Chapter # 7 Introduction to Structured Query Language (SQL) Part I Introduction to SQL SQL functions fit into two broad categories: Data definition language Data manipulation language Basic command set

More information

MyDatabaseHelper. public static final String TABLE_NAME = "tbl_bio";

MyDatabaseHelper. public static final String TABLE_NAME = tbl_bio; Page 1 of 5 MyDatabaseHelper import android.content.context; import android.database.sqlite.sqliteopenhelper; class MyDatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "friend_db";

More information

EMBEDDED SYSTEMS PROGRAMMING SQLite

EMBEDDED SYSTEMS PROGRAMMING SQLite EMBEDDED SYSTEMS PROGRAMMING 2017-18 SQLite DATA STORAGE: ANDROID Shared Preferences Filesystem: internal storage Filesystem: external storage SQLite (Also available in ios and WP) Network (e.g., Google

More information

Module - P7 Lecture - 15 Practical: Interacting with a DBMS

Module - P7 Lecture - 15 Practical: Interacting with a DBMS Introduction to Modern Application Development Prof. Tanmai Gopal Department of Computer Science and Engineering Indian Institute of Technology, Madras Module - P7 Lecture - 15 Practical: Interacting with

More information

I. Variables and Data Type week 3

I. Variables and Data Type week 3 I. Variables and Data Type week 3 variable: a named memory (i.e. RAM, which is volatile) location used to store/hold data, which can be changed during program execution in algebra: 3x + 5 = 20, x = 5,

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/22/2017

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL

Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL Mr. Pritesh N. Patel 1 Storage Options Android provides several options for you to save persistent application

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

MVC - Repository-And-Unit-Of-Work

MVC - Repository-And-Unit-Of-Work MVC - Repository-And-Unit-Of-Work What are the Repository and Unit of Work Design Patterns? When you set up an ASP.NET MVC project with the Entity framework, you can think of your project as consisting

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/15/2014

More information

Object-Oriented Programming Concepts

Object-Oriented Programming Concepts Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are

More information

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2 Department of Computer Science University of Cyprus EPL342 Databases Lab 2 ER Modeling (Entities) in DDS Lite & Conceptual Modeling in SQL Server 2008 Panayiotis Andreou http://www.cs.ucy.ac.cy/courses/epl342

More information

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210 SQL: Concepts Todd Bacastow IST 210: Organization of Data 2/17/2004 1 Design questions How many entities are there? What are the major entities? What are the attributes of each entity? Is there a unique

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

CSE 530A. DAOs and MVC. Washington University Fall 2012

CSE 530A. DAOs and MVC. Washington University Fall 2012 CSE 530A DAOs and MVC Washington University Fall 2012 Model Object Example public class User { private Long id; private String username; private String password; public Long getid() { return id; public

More information

Systems Analysis and Design in a Changing World, Fourth Edition. Chapter 12: Designing Databases

Systems Analysis and Design in a Changing World, Fourth Edition. Chapter 12: Designing Databases Systems Analysis and Design in a Changing World, Fourth Edition Chapter : Designing Databases Learning Objectives Describe the differences and similarities between relational and object-oriented database

More information

Data storage overview SQLite databases

Data storage overview SQLite databases http://www.android.com/ Data storage overview SQLite databases Data storage overview Assets (assets) and Resources (res/raw) Private data installed with the application (read-only) Use the android.content.res.xxx

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 -recap Views and Layouts Events Basic application components Activities Intents BroadcastReceivers

More information

Answer key SUBJECT : COMPUTER SCIENCE Time : 3 hour 15 min Max. marks : 70

Answer key SUBJECT : COMPUTER SCIENCE Time : 3 hour 15 min Max. marks : 70 Answer key SUBJECT : COMPUTER SCIENCE Time : 3 hour 5 min Max. marks : 7 I. Answer ALL the questions x =. Expand the term DDRRAM. Double Data Rate Random Access Memory 2. Write the standard symbol for

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

Basics of Java: Expressions & Statements. Nathaniel Osgood CMPT 858 February 15, 2011

Basics of Java: Expressions & Statements. Nathaniel Osgood CMPT 858 February 15, 2011 Basics of Java: Expressions & Statements Nathaniel Osgood CMPT 858 February 15, 2011 Java as a Formal Language Java supports many constructs that serve different functions Class & Interface declarations

More information

Android Programming Lecture 15 11/2/2011

Android Programming Lecture 15 11/2/2011 Android Programming Lecture 15 11/2/2011 City Web Service Documentation: http://206.219.96.5/webcatalog/ Need a web services client library: KSOAP2 Acts as our function calling proxy Allows us to generate

More information

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original

More information

Sql Server Call Function Without Schema Name

Sql Server Call Function Without Schema Name Sql Server Call Function Without Schema Name But in the case of sql function query returns the first parameter name empty. t.user_type_id) LEFT JOIN sys.schemas s ON (t.schema_id = s.schema_id) SQL Server:

More information

Recitation 3 Class and Objects

Recitation 3 Class and Objects 1.00/1.001 Introduction to Computers and Engineering Problem Solving Recitation 3 Class and Objects Spring 2012 1 Scope One method cannot see variables in another; Variables created inside a block: { exist

More information

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015 Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

Connecting BioNumerics to MySQL

Connecting BioNumerics to MySQL Connecting BioNumerics to MySQL A brief overview Applied Maths NV - KJ February 2010 MySQL server side MySQL settings file MySQL is a very flexible DBMS and has quite a number of settings that allows one

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1 SQL Fundamentals Chapter 3 Class 03: SQL Fundamentals 1 Class 03: SQL Fundamentals 2 SQL SQL (Structured Query Language): A language that is used in relational databases to build and query tables. Earlier

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST)

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) Preliminaries In this lab you will implement a binary search tree and use it in the WorkerManager program from Lab 3. Start by copying this

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

Android Components. Android Smartphone Programming. Matthias Keil. University of Freiburg

Android Components. Android Smartphone Programming. Matthias Keil. University of Freiburg Android Components Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 3. November 2014 Outline 1 Data Storage 2 Messages to the User 3 Background Work 4

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer May 13, 2013 OOPP / C++ Lecture 7... 1/27 Construction and Destruction Allocation and Deallocation Move Semantics Template Classes Example:

More information

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes 1 CS257 Computer Science II Kevin Sahr, PhD Lecture 5: Writing Object Classes Object Class 2 objects are the basic building blocks of programs in Object Oriented Programming (OOP) languages objects consist

More information

ESE115 Introduction to Programming with Java. Midterm 2 November 10, 2005 SOLUTION

ESE115 Introduction to Programming with Java. Midterm 2 November 10, 2005 SOLUTION ESE115 Introduction to Programming with Java Midterm 2 November 10, 2005 SOLUTION 0 2D Arrays 1. Problems involving symmetry are common in computations involving art and the natural world. We will write

More information

Java Identifiers, Data Types & Variables

Java Identifiers, Data Types & Variables Java Identifiers, Data Types & Variables 1. Java Identifiers: Identifiers are name given to a class, variable or a method. public class TestingShastra { //TestingShastra is an identifier for class char

More information

COMP 430 Intro. to Database Systems. SQL from application code

COMP 430 Intro. to Database Systems. SQL from application code COMP 430 Intro. to Database Systems SQL from application code Some issues How to connect to database Where, what type, user credentials, How to send SQL commands How to get communicate data to/from DB

More information

Presentation Outline 10/16/2016

Presentation Outline 10/16/2016 CPET 491 (Phase II) Fall Semester-2012 Adam O Haver Project Advisor/Instructor: Professor Paul Lin CEIT Department 1 Presentation Outline Executive Summary Introduction Solution Development Software Analysis

More information

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table

More information

Traffic violations revisited

Traffic violations revisited Traffic violations revisited November 9, 2017 In this lab, you will once again extract data about traffic violations from a CSV file, but this time you will use SQLite. First, download the following files

More information

Understanding class definitions

Understanding class definitions Objects First With Java A Practical Introduction Using BlueJ Understanding class definitions Looking inside classes 2.1 Looking inside classes basic elements of class definitions fields constructors methods

More information

Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass

Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Database Design, CSCI 340, Spring 2016 SQL, Transactions, April 15 Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Personal mysql accounts have been

More information

Single Application Persistent Data Storage. CS 282 Principles of Operating Systems II Systems Programming for Android

Single Application Persistent Data Storage. CS 282 Principles of Operating Systems II Systems Programming for Android Single Application Persistent Data Storage CS 282 Principles of Operating Systems II Systems Programming for Android Android offers several ways to store data Files SQLite database SharedPreferences Android

More information

Today s Agenda. Quick Review

Today s Agenda. Quick Review Today s Agenda TA Information Homework 1, Due on 6/17 Quick Review Finish Objects and Classes Understanding class definitions 1 Quick Review What is OOP? How is OOP different from procedural programming?

More information

Ticket Machine Project(s)

Ticket Machine Project(s) Ticket Machine Project(s) Understanding the basic contents of classes Produced by: Dr. Siobhán Drohan (based on Chapter 2, Objects First with Java - A Practical Introduction using BlueJ, David J. Barnes,

More information

Android Components Android Smartphone Programming. Outline University of Freiburg. Data Storage Database University of Freiburg. Notizen.

Android Components Android Smartphone Programming. Outline University of Freiburg. Data Storage Database University of Freiburg. Notizen. Android Components Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 4. November 2013 Outline 1 2 Messages to the User 3 Background Work 4 App Widgets 5

More information

Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass

Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Database Design, CSCI 340, Spring 2016 SQL, Transactions, April 15 Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Personal mysql accounts have been

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands

More information

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with

More information

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) SQL language Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 SQL - Structured Query Language SQL is a computer language for communicating with DBSM Nonprocedural (declarative) language What

More information

Android Programming Lecture 16 11/4/2011

Android Programming Lecture 16 11/4/2011 Android Programming Lecture 16 11/4/2011 New Assignment Discuss New Assignment for CityApp GetGPS Search Web Service Parse List Coordinates Questions from last class It does not appear that SQLite, in

More information

COMP 430 Intro. to Database Systems. Encapsulating SQL code

COMP 430 Intro. to Database Systems. Encapsulating SQL code COMP 430 Intro. to Database Systems Encapsulating SQL code Want to bundle SQL into code blocks Like in every other language Encapsulation Abstraction Code reuse Maintenance DB- or application-level? DB:

More information

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation. Java: Classes Introduction A class defines the abstract characteristics of a thing (object), including its attributes and what it can do. Every Java program is composed of at least one class. From a programming

More information

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7 SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Relational Databases Fall 2017 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL data definition features

More information

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases. Managing Data This week, we'll be looking at managing information. There are actually many ways to store information for later retrieval. In fact, feel free to take a look at the Android Developer pages:

More information

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual

More information

Although this code is under construction the interfaces are unlikely to change, if only because we use it in production.

Although this code is under construction the interfaces are unlikely to change, if only because we use it in production. SQL CONTEXT 1 Contents 1 Introduction 1 2 Presets 1 3 Templates 2 4 Queries 3 5 Converters 4 6 Typesetting 6 7 Methods 7 8 Helpers 7 9 Example 7 10 Colofon 9 1 Introduction Although ConT E Xt is a likely

More information

CS W Introduction to Databases Spring Computer Science Department Columbia University

CS W Introduction to Databases Spring Computer Science Department Columbia University CS W4111.001 Introduction to Databases Spring 2018 Computer Science Department Columbia University 1 in SQL 1. Key constraints (PRIMARY KEY and UNIQUE) 2. Referential integrity constraints (FOREIGN KEY

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information