My Account | Help Desk | Market Place Shopping Cart
Free shipping. Click here for details.
No items in cart.
Total: $0.00
Textbooks Sell Textbooks Books Supplies Medical Books College Apparel Movies Clearance
Search  Advanced >>
Welcome Book Supplier - VE Students!
Navigate: (use the links to quickly navigate your virtual bookstore)
Beginning Programming All-In-One Desk Reference For Dummies<sup>®</sup>,9780470108543
Other versions by this Author

Beginning Programming All-In-One Desk Reference For Dummies®


Author(s): Wallace Wang (San Deigo, CA )
ISBN10:  0470108541
ISBN13:  9780470108543
Format:  Paperback
Pub. Date:  6/1/2008
Publisher(s): For Dummies

Buy in Bulk
Send to a friend
New Price  $27.29
List Price $34.99
eVIP Price  N/A
New Copy:  Usually Ships in 2-3 Business Days
add remove
Marketplace Price $20.51
List Price $34.99 Available in the eCampus Marketplace
Take 90 Days to Pay on $250 or more
with Quick, Easy, Secure
Subject to credit approval.
SummaryExcerptsAuthor Biography
So you want to be a programmer? Or maybe you just want to be able to make your computer do what YOU want for a change? Maybe you enjoy the challenge of identifying a problem and solving it. If programming intrigues you for whatever reason, Beginning Programming All-In-One Desk Reference For Dummies is like having a starter programming library all in one handy, if beefy, book.

In this practical guide, you’ll find out about compiling, algorithms, best practices, debugging your programs, and much more. The concepts are illustrated in several different programming languages, so you’ll get a feel for the variety of languages and the needs they fill. Seven minibooks cover:

  • Getting started
  • Programming basics
  • Data structures
  • Algorithms
  • Web programming
  • Programming language syntax
  • Applications

Beginning Programming All-In-One Desk Reference For Dummies shows you how to decide what you want your program to do, turn your instructions into “machine language” that the computer understands, use programming best practices, explore the “how” and “why” of data structuring, and more. You’ll even get a look into various applications like database management, bioinformatics, computer security, and artificial intelligence. Soon you’ll realize that — wow! You’re a programmer!

Beginning Programming All-In-One Desk Reference For Dummies


By Wallace Wang

John Wiley & Sons

Copyright © 2008 Wallace Wang
All right reserved.

ISBN: 978-0-470-10854-3


Chapter One

Database Management

In This Chapter

  •   Discovering the basics of databases

  •   Figuring out how to manipulate data

  •   Understanding database programming

    Database management is all about storing organized information and knowing how to retrieve it again. Although the idea of storing and retrieving data is simple in theory, managing databases can get complicated in a hurry. Not only can data be critical, such as bank records, but data retrieval may be time-sensitive as well. After all, retrieving a person's medical history in a hospital emergency room is useless if that information doesn't arrive fast enough to tell doctors that the patient has an allergic reaction to a specific antibiotic.

    Because storing and retrieving information is so important, one of the most common and lucrative fields of computer programming is database management. Database management involves designing and programming ways to store and retrieve data. Because nearly every business from agriculture to banking to engineering requires storing and retrieving information, database management is used throughout the world.

    The Basics of Databases

    A database acts like a big bucket where you can dump in information. The two most important parts of any database is storing information and yanking it back out again. Ideally, storing information should be just as easy as retrieving it no matter how much data you may need to store or retrieve.

    To store and retrieve data, computer scientists have created three types of database designs:

    * Free-form

    * Flat-file

    * Relational

    Free-form databases

    Free-form databases are designed to make it easy to store and retrieve information. A free-form database acts like a scratch pad of paper where you can scribble any type of data, such as names and addresses, recipes, directions to your favorite restaurant, pictures, or a list of items that you want to do the next day. A free-form database gets its name because it gives you the freedom to store dissimilar information in one place, as shown in Figure 1-1.

    Being able to store anything in a database can be convenient, but that convenience is like the freedom to throw anything you want in a closet, such as pants, books, written reports, and photographs. With such a wide variety of stuff dumped in one place, finding what you need can be much more difficult.

    To retrieve data from a free-form database, you need to know at least part of the data you want to find. So if you stored a name and phone number in a free-form database, you could find it again by just typing part of the name you want to find (such as typing Rob to find the name Robert). If you stored a recipe in a free-form database, you could find it by typing one of the ingredients of that recipe, such as milk, shrimp, or carrots.

    WARNING!

    Free-form databases have two big disadvantages:

    * They're clumsy for retrieving information. For example, suppose you stored the name Robert Jones and his phone number 555-9378. The only way to retrieve this information is by typing part of this data, such as Rob, 555, or nes. If you type Bob, the free-form database doesn't find Robert. So it's possible to store information in a free-form database and never be able to find it again, much like storing a cherished photo album in an attic and forgetting exactly where it might be.

    * They can't sort or filter information. If you want to see the phone numbers of every person stored in a free-form database, you can't. If you want to see only information in the free-form database that you stored in the past week, you can't do that either.

    TIP

    Because free-form databases are so limited in retrieving information, they're best used for simple tasks, such as jotting down notes or ideas but not for storing massive amounts of critical information. To store data with the ability to sort, search, and filter data to view only specific types of information, you need a flat-file database.

    Flat-file databases

    The biggest difference between a free-form database and a flat-file database is that a flat-file database imposes structure. Whereas a free-form database lets you type random information in any order, flat-file databases force you to add information by first defining the structure of your data and then adding the data itself.

    Before you can store data, you must design the structure of the database. This means defining what type of data to store and how much room to allocate for storing it. So you might decide to store someone's first name and last name and allocate up to 20 characters for each name.

    Each chunk of data that you want to record, such as a first name, is a field. A group of fields is a record. If you want to store names and telephone numbers, each name and telephone number is a field, and each name and its accompanying telephone number make up a single record, as shown in Figure 1-2.

    Flat-file databases impose a structure on the type of information you can store to make retrieving information much easier later. However, you need to design the structure of your database carefully. If you define the database to store only first and last names, you can't store any other information other than first and last names.

    Designing the size and types of fields can be crucial in using the database later. If you create a Name field but allocate only ten characters to hold that data, the name Bob Jones fits but another name, such as Daniel Jonathan Perkins, cuts off.

    Another problem is how you define your fields. You could store names in one big field or separate them into three separate fields for holding first, middle, and last names. Using a single field to store a name might initially look simpler, but separating names in different fields is actually more useful because this allows the database to sort by first, middle, or last name.

    Although such a rigid structure might seem to make flat-file databases harder to use, it does make flat-file databases easier to search and sort information. Unlike free-form databases that may contain anything, every record in a flat-file database contains the exact same type of information, such as a name, address, and phone number. This makes it possible to search and sort data.

    If you want to find the telephone number of Robert Jones, you could tell the flat-file database to show you all the records that contain a first name beginning with the letter R. If you want to sort your entire database alphabetically by last name, you can do that, too.

    A flat-file database gets its name because it can work only with one file at a time. This makes a flat-file database easy to manage but also limits its usefulness. If you have a flat-file database containing names and addresses and a second flat-file database containing names and telephone numbers, you might have identical names stored in the two separate files. Change the name in one flat-file database and you need to change that same name in the second flat-file database.

    Relational databases

    For storing simple, structured information, such as names, addresses, and phone numbers (similar to a Rolodex file), flat-file databases are adequate. However, if you need to store large amounts of data, you're better off using a relational database, which is what the majority of database programs offer.

    Like a flat-file database, you can't store anything in a relational database until you define the number and size of your fields to specify exactly what type of information (such as names, phone numbers, and e-mail addresses) that you want to save.

    Unlike flat-file databases, relational databases can further organize data into groups, or tables. Whereas a free-form database stores everything in a file and a flat-file database stores everything in file, but organizes it into fields; a relational database stores everything in a file that's divided into tables, which are further divided into fields, as shown in Figure 1-3.

    REMEMBER

    Think of database tables as miniature flat-file databases that can connect with each other.

    Just as storing a name in separate First Name and Last Name fields gives you more flexibility in manipulating your data, grouping data in separate tables also give you more flexibility in manipulating and sharing information.

    Suppose you have a list of employees that includes names, addresses, and telephone numbers. Now you may want to organize employees according to the department where they work. With a flat-file database, you'd have to create a separate file and store duplicate names in these separate databases, as shown in Figure 1-4.

    Every time you add a new employee, you'd have to update both the employee database and the specific department database that defines where he works. If an employee leaves, you'd have to delete his name from two separate databases as well. With identical information scattered between two or more databases, keeping information updated and accurate is difficult.

    Relational databases solve this problem by dividing data into tables with a table grouping the minimum amount of data possible. So, one table might contain names and employee ID whereas a second table might contain only employee names and department names, as shown in Figure 1-5.

    TECHNICAL STUFF

    A column in a table represents a single field, often called an attribute. A row in a table represents a single record, often called a tuple.

    What makes tables useful is that you can link them together. So whereas one table may appear to contain names and addresses while a second table might also contain names and departments, the two tables are actually sharing information. Instead of having to type a name twice in both tables, you need to type the name only once, and the link between separate tables automatically keeps that information updated and accurate in all other linked tables.

    By linking or relating tables together, you can combine data in different ways. If you have a list of customers stored in one table and a list of sales in another table, you can relate these two tables to show which customers are buying which products, or which products are most popular in specific sales regions. Basically, relating tables together allows you to create virtual databases by sharing and combining data from separate database tables. By combining data from separate tables, you can uncover hidden information behind your data, as shown in Figure 1-6.

    Tables divide data into groups, but taken on a larger scale, it's possible to divide an entire database into multiple databases that are physically separate. Such databases are distributed databases.

    A company might use a distributed database to keep track of all its employees. A branch office in Asia might have a database of employees in Singapore, another branch in Europe might have a database of employees in England, and a third branch in America might have a database of employees in California. Combining these separate databases would create a single database of all the company's employees.

    Manipulating Data

    After you define the structure of a database by organizing information in tables and fields, the next step is to write commands for modifying and manipulating that information. This can be as simple as adding data to a specific table or as complicated as retrieving data from three different tables, reorganizing this information alphabetically by last name, and displaying this list on the screen with mathematical calculations showing sales results for each person and a total amount for an entire department and company.

    The three basic commands for manipulating data are Select, Project, and Join. The Select command retrieves a single row or tuple from a table. So if you want to retrieve someone's name to find her e-mail address, you could use the Select command, as shown in Figure 1-7.

    Besides retrieving a single record or tuple, the Select command can retrieve multiple tuples, such as a list of all employees who work in a certain department.

    The Project command retrieves the entire column or attribute from a database table. This can be useful when you just want to view certain information, such as the names of employees along with the department where they work, as shown in Figure 1-8.

    The Project command acts like a filter, hiding data that you don't want to see and displaying only data that you do want to see. Combining the Select and Project commands can find just the names and e-mail addresses of all employees who work in a certain department.

    The Join command combines separate tables together to create a virtual table that can show new information. For example, a Join command might combine a table of products, and a table of customers with a table of sales people can show which sales person is best at selling certain products and which products are most popular with customers, as shown in Figure 1-9.

    WARNING!

    The Select, Project, and Join commands are generic terms. Every database uses its own terms for performing these exact same actions, so be aware of these terminology differences.

    Writing database commands

    Every relational database program includes commands for manipulating data. These commands essentially form a proprietary programming language specific to that database program. Microsoft Access uses a programming language called VBA (Visual Basic for Applications) whereas FileMaker uses a language called FileMaker Script. Most databases actually consist of separate files with one file containing the actual data and a second file containing programs for manipulating that data.

    The main difference between a general purpose language, like C++, and a database language is that the database language needs only to define what data to use and how to manipulate it, but the database program (or the data-base engine) takes care of the actual details. Database languages only need to define what to do, not how to do it.

    The SQL language

    Although every relational database program comes with its own language, the most popular language for manipulating large amounts of data is SQL (Structured Query Language). SQL is used by many different database programs, such as those sold by Oracle, Microsoft, and Sybase. If you're going to work with databases as a programmer, you have to figure out SQL.

    SQL commands, like all database programming languages, essentially hide the details of programming so you can focus on the task of manipulating data. To retrieve names from a database table named Employees, you could use this SQL command:

    SELECT FirstName, LastName FROM Employees

    To selectively search for certain names, you could use this variation:

    SELECT FirstName, LastName FROM Employees WHERE FirstName = 'Richard'

    To add new information to a table, you could use this command:

    INSERT INTO Employees VALUES ('John', 'Smith', '555-1948')

    To delete information from a table, you could use the delete command, such as:

    DELETE FROM Employees WHERE LastName = 'Johnson'

    To modify a phone number, you could use this command:

    UPDATE Employees SET PhoneNumber = '555-1897' WHERE LastName = 'Smith'

    An ordinary user can type simple database commands to retrieve information from a database, but because most users don't want to type a series of commands, it's usually easier for someone else to write commonly used database commands and then store these commands as miniature programs. Then instead of forcing the user to type commands, the user can just choose an option and the database will run its program associated with that option, such as sorting or searching for information.

    Data integrity

    With small databases, only one person may use the database at a time. However with large databases, it's possible for multiple people to access the database at the same time. The biggest problem with multi-user databases is data integrity.

    Data integrity is insuring that data is accurate and updated, which can cause a problem when multiple users are modifying the same data. An airline reservation system might let multiple travel agents book seats on the same airplane, but the database must make sure that two travel agents don't book the same seat at the same time.

    (Continues...)



    Excerpted from Beginning Programming All-In-One Desk Reference For Dummies by Wallace Wang Copyright © 2008 by Wallace Wang. Excerpted by permission.
    All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
    Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

  • Wallace Wang is a bestselling author with more than 2.3 million For Dummies books in print. He wrote Beginning Programming For Dummies and moonlights as a stand-up comic.

    Check Out These Items!
    eCampus.com Pink Backpack eCampus.com Pink Backpack
    Retail Price $28.95
    Our Price $10.00
    eCampus.com T-Shirt eCampus.com T-Shirt
    Retail Price $14.99
    Our Price $2.00
    eCampus.com 4GB USB Drive eCampus.com 4GB USB Drive
    Retail Price $32.95
    Our Price $25.00
      Buy Textbooks
      Sell Textbooks
      College Apparel
      Shop by School
      Virtual Bookstores
      Order Status
      Shipping Rates
      Return Policy
      Marketplace Info
      F.A.S.T.
      Contact Us
      Privacy Policy
      Legal Notices
      Site Security
      Employment
      Help Desk
      eCampus Blog
      Affiliate Program
      Bulk Orders
      College Marketing
    HACKER SAFE certified sites prevent over 99.9% of hacker crime.
    eCampus.com blog follow eCampus.com on twitter find eCampus.com on facebook RSS Need Help? bookstore@ecampus.com   Copyright© 1999-2008     
    .