ThePlace

Home ] Search ] Resources ] Site Map ] Contact Me ]
Dave's Information Technology Resource

Up ]

Computers & Programming ] Operating Systems ] Programming Environments ] Windows-Based Applications ] Objects and Programming ] Data and Variables ] Operational Expressions ] Functions and Procedures ] Programming Control ] Algorithms ] [ Files, Graphics & Databases ] Software Development ] 10 Things... ]

--- Files, Graphics & Databases ---

There are a lot of things to learn about files, graphics, and printing.  This section should help you get started in understanding some of these concepts.

Files

Files are used to contain programs and to store data.  Typically, applications and "data files" work together.  For example, a word processor application stores data (a letter or other document) in a file so that it can be recalled and edited later.  Applications or programs may share data files.  For example, in some word processors you can load files from other word processors.

Types of Files

Files may contain text, images, databases, and audio and video data.  Data can be read using a text editor if it is in "text" (also called ASCII) format.  Other files, such as graphics, use a "binary" format.  Binary formats are usually read by specific applications.

Working with files involves three steps:

  1. Opening the file - usually for input, output, or appending to existing file

  2. Reading or writing from or to the file.

  3. Closing the file.

Opening the file means telling the computer which file you want (the filename), how you want it opened (for input, output, append), what type it is (binary, text), and then assigning a handle to it.  A handle is usually a unique number that allows you to keep track of the file that is opened.

Reading and writing from or to a file is a matter of sending the data to the file by referencing the file handle.  The process is similar to writing to a printer or reading from user input.

Closing a file is simply a matter of telling the computer you are done.

For example:

Open filename.txt for input as #1  'open the file to get data

Tbox.text = input(100,#1)  'get 100 characters from the file

Close 1  'close the file when you are done

   

Graphics

Graphics are pictures that can be displayed on the computer.  Graphics are displayed by manipulating pixels (spots of color on the screen) to various colors to create the picture.

Picture and image objects are most commonly used to store and display graphics.  You can usually access specific pixels to examine and modify graphics. 

You can also use point, line, and circle functions to draw on the object.  This process combines the use of methods and events to manage drawing operations:

bullet

MouseDown event - start a drawing operation and setting a pen for drawing.

bullet

MouseOver event - use drawing methods to create points, lines, circles, and rectangles.

bullet

MouseUp event - end the drawing operation.

 Files are used to store graphics.  There are several file formats including bitmap, JPEG, and GIF.  Most programming systems have specific functions for loading and saving graphic images.

 

Printing

Printing is the process of sending data to a printer.  It can also mean sending data to the screen or to a file.

Typically, printing will involve setting up the printer and selecting the printer, printing mode (color, graphic mode), numbers of copies, and so forth.  Many of these functions are handled by the operating system in common dialogs that can be accessed by all applications.

Most programming languages treat the printer as an output device to which data is sent for display (printing).

 

Databases

For more detail, please visit...Database Concepts.

Databases are repositories of information typically organized to allow selection of specific subsets of information and updating, removal, and addition of new information.

Flat Files

These are "cheap" databases.  Data is stored as lines of text with little or no internal or external referencing.  No tools are specifically available for easy access, updating, deleting, and adding (you could use a word processor to create and manage a flat file).

The following is a typical example of a flat file layout:

lastname, firstname, address, city, state

Smith, Jones, 111 Elm Street, Anycity, MD

Doe, John, 2222 Main Road, Anycity, MD

James, Mary 33 Oak Terrace, Mytown, MD

 

 

Note that the field names are indicated in the first row.  Fields are separated by commas.  Tabs, quotations, and other characters may also be used to separate fields.

 

Relational Databases

For more detail visit the Database Bootcamp!

Relational databases enable you to organize information in natural ways.  For example a corporate database would include information about:

bullet

Employees

bullet

Projects

bullet

Costs

bullet

Facilities

Each of these groups of information would thoroughly describe the topic.   Relationships may exist between these groupings.  For example, employees will staff projects; projects have costs; and facilities house employees. 

Technically speaking, relational databases consist of:

bullet

One or more tables describing an aspect of the database (e.g., employees) containing...

bullet

 Records holding data organized by one or more (usually more) fields (e.g., employee name, address, phone).

bullet

Fields designed to hold various types of data (text, numbers, currency, etc.)

Tables

Let's take a closer look at tables.  Tables in relational databases are used to organize complex information sets.   Each table in a database is used for a specific grouping of information.  For example, a corporate database might contain:

bullet

Employee table—name, address, phone, job of each employee

bullet

Project table—project name, description, name of project leader for each project

bullet

Jobs table—job, description, salary range for each type of job

bullet

Assignment table—project name, employee name (which references you back to the employee table)

 

Note that each table has unique information that is not found in other tables.   Good table design means: never repeating data (e.g., an employee address only appears once).

Fields and Data Types

Fields in a table describe the kind and nature of the information that is being stored.   For example, using our employee table:

Employee Number Last Name First Name Address
102 Smith John 111 Main St
103 Jones Marie 222 Elm St
104 Johnson Robert 333 Oak Dr

 

SQL

Structured Query Language (SQL) is the ANSI (American National Standards Institute) standard relational database language used for managing objects, data, and security.  SQL is supported by many commercial database products as a means to access and manage databases.

There are 6 basic statements in SQL:

  1. Select -- Retrieves columns and rows from a table or tables.

  2.  Insert -- Adds rows to a table.

  3. Update -- Updates columns in existing rows in a table.

  4. Delete -- Deletes rows from a table.

  5. Create -- Creates a new table.

  6. Select Into -- Creates new tables with data from an existing table.

The following sections describe the syntax for each of these statements:

Select

Select — columns of data to be retrieved
From — tables from which to retrieve rows
Where — criteria for returned data
Group By — for aggregate queries, columns by which the data is to be grouped
Having — for aggregate queries, criteria that the aggregate value returned must have
Order By — sort order of the returned rows

 

Example: SELECT lastname, firstname, address, city, state, zip FROM employee WHERE state='MD' GROUP BY zip

Where operators include: =, >, <, >=, <=, <> (not equal) IN, BETWEEN..AND, LIKE

Linking relationships can join tables.  For example:

·        Two tables: employee (with studentid, lastname, firstname, address, etc..), project (projectid, emplyeeid)

·        Employee table has a field: employeeid

·        Project table has a field: employeeid

Example: SELECT employee.lastname, employee.firstname FROM employee, project WHERE employee.employeeid = project.employeeid

This query joins two tables and provides the student names.

 

Insert

Insert Into -- which table will have rows added
column list -- which columns will add data
Values (value list) -- values to be added to the table
Select -- returns rows to be added to the table

Example: INSERT INTO employee (lastname, firstname, address, city, state, zip) VALUES ('Smith', 'David', '111 Elm Street', 'Anycity', 'MD', '20872')

 

Update

Update — table to be updated
Set — columns to update and values
From — tables to be included in the update
Where — criteria to determine which columns will be updated

Example: UPDATE students SET address = '99 Elm St' WHERE lastname = 'Smith'

 

Delete

Delete From — specify table in which rows are to be deleted
Where — criteria for deletion

Example: DELETE FROM employee WHERE employeeid = 10

 

Create

Create Table — table to be created
column list — describes columns to be created in new table

  Example: CREATE TABLE divisions (divisionid id NOT NULL , divisiondescription varchar (30) NULL )

 

Select Into

Select column list — columns to build the new table
Into — new table being created
From — table from which data is coming from
Where — criteria for data being selected
Group By — for aggregate queries, columns by which data is grouped
Having — for aggregate queries, criteria that must be met
Order By — sort order of returned rows

 

Example: SELECT lastname, firstname INTO localemployees FROM employee WHERE state = 'MD'

 

Home ] Up ] Computer Architecture ] Database Bootcamp ] Visual BasicS ] Web Basics ] Web Multimedia ] Web Programming ] Advanced Web Topics ] Developing Web Sites ] XML Technology ] Web Glossary ]

Copyright © 1999 - 2005 
ThePlace - Written and Sponsored by Dave Hillman