CSC 370 Database Systems Summer 2004 Assignment No. 2



Similar documents
sqlite driver manual

A Brief Introduction to MySQL

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy

AWS Schema Conversion Tool. User Guide Version 1.0

Integrating VoltDB with Hadoop

Writing MySQL Scripts With Python's DB-API Interface

MySQL 5.1 INTRODUCTION 5.2 TUTORIAL

Installation Guidelines (MySQL database & Archivists Toolkit client)

Database Design and Programming

Creating Database Tables in Microsoft SQL Server

DBI-Link: 3.0. PgCon Ottawa 2008 Copyright David Fetter 2008 All Rights Reserved

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

Package sjdbc. R topics documented: February 20, 2015

ER/Studio 8.0 New Features Guide

Connect to MySQL or Microsoft SQL Server using R

How to Copy A SQL Database SQL Server Express (Making a History Company)

AWS Schema Conversion Tool. User Guide Version 1.0

TIBCO Spotfire Automation Services 6.5. User s Manual

Infinitel HotSpotWeb User Manual

CSCI110 Exercise 4: Database - MySQL

MYSQL DATABASE ACCESS WITH PHP

Lab 2: PostgreSQL Tutorial II: Command Line

Database Security. Principle of Least Privilege. DBMS Security. IT420: Database Management and Organization. Database Security.

Risks to Database Activities

MS ACCESS DATABASE DATA TYPES

FileMaker 13. ODBC and JDBC Guide

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

Writing Scripts with PHP s PEAR DB Module

What is ODBC? Database Connectivity ODBC, JDBC and SQLJ. ODBC Architecture. More on ODBC. JDBC vs ODBC. What is JDBC?

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Unlocking Hadoop for Your Rela4onal DB. Kathleen Technical Account Manager, Cloudera Sqoop PMC Member BigData.

Image Databases INLS 623 Lina Huang Elise Moore Ketan Palshikar Nevin Yang

FileMaker 12. ODBC and JDBC Guide

LedgerSMB on Mac OS X An Installation Guide

Database Administration with MySQL

Course Objectives. Database Applications. External applications. Course Objectives Interfacing. Mixing two worlds. Two approaches

Project 2 Database Design and ETL

User Guide. Trade Finance Global. Reports Centre. October nordea.com/cm OR tradefinance Name of document 8/8 2015/V1

Database Migration from MySQL to RDM Server

Configuring an Alternative Database for SAS Web Infrastructure Platform Services

Lightroom And It s Application In Dentistry

Using DOTS as Apache Derby System Test

Writing MySQL Scripts with Python DB-API

Maintaining Stored Procedures in Database Application

dbext for Vim David Fishburn h5p://

2/3/04 Doc 7 SQL Part 1 slide # 1

Pluggable Rule Engine

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Mimer SQL. Programmer s Manual. Version 8.2 Copyright 2000 Mimer Information Technology AB

Programming Database lectures for mathema

Using Temporary Tables to Improve Performance for SQL Data Services

Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

INASP: Effective Network Management Workshops

Business Interaction Server. Configuration Guide Rev A

Once the schema has been designed, it can be implemented in the RDBMS.

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

Add an Audit Trail to your Access Database

Talend for Data Integration guide

Using SQL Server Management Studio

SQL and programming languages

PostgreSQL Audit Extension User Guide Version 1.0beta. Open Source PostgreSQL Audit Logging

Oracle Database 10g Express

Install BA Server with Your Own BA Repository

Excel Companion. (Profit Embedded PHD) User's Guide

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

HP Vertica Integration with SAP Business Objects: Tips and Techniques. HP Vertica Analytic Database

A Tutorial on SQL Server CMPT 354 Fall 2007

CS346: Database Programming.

Hypercosm. Studio.

Information Technology NVEQ Level 2 Class X IT207-NQ2012-Database Development (Basic) Student s Handbook

Developing SQL and PL/SQL with JDeveloper

agileworkflow Manual 1. agileworkflow 2. The repository 1 of 29 Contents Definition

Using ORACLE in the CSLab

IGEL Universal Management. Installation Guide

A table is a collection of related data entries and it consists of columns and rows.

Virto Pivot View for Microsoft SharePoint Release User and Installation Guide

Sophos Enterprise Console Auditing user guide. Product version: 5.2

C++ Wrapper Library for Firebird Embedded SQL

Working with the Cognos BI Server Using the Greenplum Database

Matisse Installation Guide for MS Windows. 10th Edition

XenClient Enterprise Synchronizer Migration

Watch Your Garden Grow

Storing SpamAssassin User Data in a SQL Database Michael Parker. [ Start Slide ] Welcome, thanks for coming out today.

Plug-In for Informatica Guide

New York Oracle Users Group (NYOUG) Long Island SIG. Oracle Data Integrator (ODI) Best Practices Do You Know How Flexible ODI Is?

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

FileMaker Pro and Microsoft Office Integration

FileMaker 11. ODBC and JDBC Guide

Rational Rational ClearQuest

lug create and edit TeX Local User Group web pages

Setting Up ALERE with Client/Server Data

1. Digital Asset Management User Guide Digital Asset Management Concepts Working with digital assets Importing assets in

MyOra 4.5. User Guide. SQL Tool for Oracle. Kris Murthy

DbSchema Tutorial with Introduction in MongoDB

Transcription:

CSC 370 Database Systems Summer 2004 Assignment No. 2 Note 1 This assignment is to be done in teams of two people. Note 2 Except as indicated, working with other teams is strictly prohibited. Due date: July 5, 2003, at the beginning of the class. This assignment is worth 5% of your total course mark. Clearly mark your student number on all submissions. Objectives After completing this assignment, you will have experience in: Writing programs that interact with the database using embedded C, Java JDBC and Perl DBI; Using the system tables. Preliminaries System Tables System tables are relations that store information used by the DBMS. The idea behind system tables is that everything that the DBMS knows about the database, its users, and its environment should be stored in tables, so this information can be manipulated using SQL. Unfortunately system tables are not standardized, and each DBMS uses different schemas for them and therefore stores similar information in very different ways. In particular, a great deal of data is stored in postgresql system tables. The names of these tables begin with pg. The tables contain information about data types, functions, operators, databases, users, and groups. The following table shows some of these tables: Table pg database pg class pg attribute pg users Contents databases tables columns users Try doing a select * from each of these tables. You will find a detail description of each field in the Postgresql Administration Guide. EXIF data in digital photos Most digital cameras are able to generate JPEG files. These JPEG files contain information about the photo, such as the date/time it was taken, the aperture, exposure time, lens focal length, etc. It also contains information about the camera and its manufacturer. This information is stored in a format called EXIF. 1

Your task, should you choose to accept it The programs you will write use a table. The catch is that you don t know the names of its columns, but you know the following information about each of the columns of the table. Column number data type comment 1 timestamp Date the photo is taken 2 char(40) Camera model 3 char(40) Camera maker 4 integer Horizontal size in pixels 5 integer Vertical size in pixels 6 float Aperture 7 float Exposure Time 8 integer ISO speed Table 1: Columns in photos table The only field that is required is the date the photo is taken (which is the primary key of the relation). All the others can be NULL. Your programs will have to find out the names of the columns from the system tables. Your programs cannot assume anything. This assignment is composed of 3 parts. Part 1 loadphotos(1) NAME SYNOPSIS DESCRIPTION loadphotos - load selected EXIF data from JPEG files into a given table. loadphotos HOST DB USERNAME TABLE [<jpegfile1>...] loadphotos connects to the postgresql database DB running in the computer HOST using as user USERNAME. If only these three parameters are specified, the program should print the names of the attributes of the table TABLE, one per line. <attributename1> <attributename2>... <attributenamen> where <N> is the number of attributes. The attributes should be printed in the same order as they were defined (hint, use field attnum of one of the system tables). When the optional file names are provided, it will inspect one file at a time, and for each file it will load the corresponding data into the photographs table (which will have the schema described previously). If the file is a valid JPEG photo, and it contains at least the date it was taken, then a new record is added to the database. This date is the primary key of the table, and therefore, you will not be able to insert the same file information twice. If one of the other EXIF attribute is not found in the JPEG then the attribute is filled with a NULL. The program should output one line per file, with the 2

NOTES: following legend: <filename>: <message> where the <message> can be error ok EXAMPLES: already inserted the file does not exist, or it does not contain a valid EXIF block or it does not contain the date taken field or an error occurred. the file s EXIF data was properly loaded into the table this file s data is already inserted For example, for 3 files, this is a potential output: <jpegfile1>: ok <jpegfile2>: already inserted <jpegfile3>: error At the end of its execution, it should print a message with the total number of photos loaded, for example: 2 photo(s) loaded. The program reads the password needed to connect to the database from the standard input. You should prompt for the password, and then read one line from standard input and use this value as the password. Your program will be run as follows: loadphotos host user table file1 file2... < filecontainingpassword During a successful run, the program exits with errorcode 0. Any critical error is handled by printing some error message (such as "An error has occurred") to standard error and then exiting with error code 1. Display the attributes of the table RIP in the databases csc370, in the host server using username dmg. $ loadphotos server csc370 dmg RIP password: fieldname1 fieldname2 fieldname3 Load all the photos in the current directory into the databases myphotos, table photos available in the host localhost using username test. $ loadphotos localhost myphotos test photos *.jpg < passwd password: test1.jpg: ok test2.jpg: ok test3.jpg: ok who.jpg: error zapphoto.jpg: ok 5 photo(s) loaded. AUTHOR Written by you. REPORTING BUGS Report bugs to <you@uvic.ca>. COPYRIGHT Copyright 2002 Your Name Write a programs that implements loadphotos in embedded SQL. 3

Part 2 reportphotos(1) NAME SYNOPSIS DESCRIPTION OPTIONS: NOTES: EXAMPLES: reportphotos - report data from the photos table. reportphotos [options] HOST DB USERNAME TABLE reportphotos connects to the postgresql database DB running in the computer HOST using as user USERNAME. The program should list all the photographs loaded in table TABLE as follows: Total: <n> photo(s) value1,value2,value3,value4,value5...,value8 value1,value2,value3,value4,value5...,value8 value1,value2,value3,value4,value5...,value8 The report should be ordered by date (field 1 of the table). NULL values should be left empty. Strings should be printed without trailing spaces. The aperture should be printed using a "%3.1f" format, and the exposure time using "%7.4f" format, and integers should be printed without any spaces. Dates should be printed in the following format: yyyy/mm/dd HH:MM:SS, without trailing spaces. -sort <fieldnumber> -group <fieldnumber> Order the report according to the field number <fieldnumber>, and use the date taken as the secundary ordering field. Instead of the usual report, count the number of photos that have the same field value. For example, -group 2 will result in a report of camera models, followed by the number of photos of each model, for example: Total: 5 photo(s) Canon EOS D60,3 Canon PowerShot S300,2 This report should be ordered by the field to group by and it will always contain only 2 columns. The program reads the password needed to connect to the database from the standard input. You should prompt for the password, and then read one line from standard input and use this value as the password. Your program will be run as follows: reportphotos host... < filecontainingpassword During a successful run, the program exits with errorcode 0. Any critical error is handled by printing some error message (such as "An error has occurred") to standard error and then exiting with error code 1. Load all the photos in the current directory into the databases myphotos, table photos available in the host localhost using username test. $ reportphotos.pl localhost myphotos test photos < passwd password: Total: 5 photo(s) 2002-11-20 11:23:35,CanonCanon PowerShot S300,1024,768,2.7, 0.0025,0 2002-12-28 10:27:23,CanonCanon PowerShot S300,1024,768,2.7, 0.0100,0 2004-06-04 17:01:03,CanonCanon EOS D60,160,120,2.0, 0.0100,800 2004-06-06 11:18:09,CanonCanon EOS D60,160,120,4.5, 0.0016,100 2004-06-06 11:43:00,CanonCanon EOS D60,160,120,4.0, 0.0100,100 $ java -sort 2 reportphotos localhost myphotos test photos < passwd 4

password: Total: 5 photo(s) 2004-06-04 17:01:03,CanonCanon EOS D60,160,120,2.0, 0.0100,800 2004-06-06 11:18:09,CanonCanon EOS D60,160,120,4.5, 0.0016,100 2004-06-06 11:43:00,CanonCanon EOS D60,160,120,4.0, 0.0100,100 2002-11-20 11:23:35,CanonCanon PowerShot S300,1024,768,2.7, 0.0025,0 2002-12-28 10:27:23,CanonCanon PowerShot S300,1024,768,2.7, 0.0100,0 AUTHOR Written by you. REPORTING BUGS Report bugs to <you@uvic.ca>. COPYRIGHT Copyright 2004 Your Name Write a programs that implements reportphotos in java and in perl. Both programs should be functionally equivalent. Part 3 Write a programs that implements aggregatephotos in perl. Implementation Notes Look at the examples in dmgerman/public/csc370/assign2. There you will find: an example of an embedded C program; one of a Java JDBC program; one of a Perl DBI; an example of a program that reads EXIF data; some sample images. Pay particular attention to the Makefiles and/or README files. Each program requires specific libraries to run. Make sure the format of your output is identical to the one specified. Otherwise you will lose marks. What to submit Choose one of the CVS modules (each member of the team has one) to submit the assignment. Create a directory assign2 to this module. Add to this directory any files you need, including a Makefile. After running make, there should be the following 3 executable files: loadphotos (executable for embedded C), reportphotos.javac (for Java JDBC), reportphotos.pl (for Perl DBI), 5

Print the results of the cvs status command by running it in the assign2. At the start of the class on the deadline, hand in your solution to this assignment (including a hardcopy of the source code of each of your programs). Only one copy per team is required. Clearly mark the name of your team, the name of the CVS repository you used, and the name of each member of the team in your submission. This assignment is not trivial. The amount of programming is small, but it will be time consuming. You will have a lot of questions about how to complete this assignment. You will need to use the Postgresql documentation a lot. I suggest you use google to find answers to your questions. Part of the assignment s objective is that you find the answers to those questions. Start early. I will answer any questions about the project in the bulletin board of the course. 6