When designing the Database Tables for an application there are many factors that come into play. Often one issue that seems to crop up is the use of denormalized vs normalized tables for representing data. Below is a brief overview of what normalized and denormalized tables are. As for which one to use in your own application that is up to you with many factors coming into play including speed, extensibility, and limits.

Normalized DB Schemes are when you rationalize data objects into tables to reduce and avoid redundancy. A sample would be the below schema where you have a person table, phone table and phone type table. With linkage between the tables to associate the data.

PERSON
ID FIRST_NAME LAST_NAME MIDDLE_INITIAL
PERSON_PHONE
PERSON_ID PHONE_ID
PHONE
ID NUMBER TYPE_ID
PHONE_TYPE
ID NAME

Having a normalized database would allow for a person to have any amount of phone numbers of every type. However if this structure was denormalized then this information would be condensed into a single table that would contain all this information. When doing so it would have to be decided how many numbers a person can have and of which type. One possible denormalization would be to only allow 1 number of each type (home, work, cell, fax) giving the below table design.

PERSON
ID F_NAME L_NAME MID_INIT HOME_NUM CELL_NUM FAX_NUM WORK_NUM

As previously mentioned this denormalization of the data limits how much information can be stored, however it does increase performance of the database in certain as you do not have to do joins for basic select statements.

,

When working with tweens in Flash we often create custom time-line based animations for various elements of the project. These time-line animations can sometimes need to be played in reverse by the frame count and not by a time duration. If one utilizes the TweenLite or TweenMax Tweening Framework this task can easily be completed by use of the frameLabel and useFrames parameters.

The frameLabel property defines the name of the frame that the movie clip should be tweened to enabling us to tween a movie clip both forward and backwards.

TweenLite.to( movieclip, 1.5, { frameLabel:"intro" } );

The above example will tween to the labeled frame over 1.5 seconds. If instead we want our animation to play over 60 frames we would use the useFrames property which treats the second parameter as the number of frames and not number of seconds.

TweenLite.to( movieclip, 60, {frameLabel:"intro", useFrames:true} );

Lastly we may want to have the animation play back to a previous label using the exact animation duration that it was created with. This task although more complicated can be accomplished the first step is to set the ease type to Linear.easeNone which will make the animation play uniformly. The second step is to know the exact number of frames between the current frame of the movie clip and the desired frameLabel. Flash does not provide an interface for obtaining the frame number of a labeled frame and instead you will have to create your own utility and formulas for determining the duration. A simple method would be to have an associated array or dictionary of the frame labels with their corresponding frame number that you can then get the difference of the current frame and that value.

TweenLite.to( movieclip, frameDiff, {frameLabel:"intro", useFrames:true, ease:Linear.easeNone} );
, , , , ,

When writing SQL queries we often measure the performance of the query or procedure by the amount of time it takes to complete. Often I found myself saying that if it completes in a couple seconds then it is good. Lately however I have found myself more concerned with the IO count then with the execution time. The IO count is the amount of reads and writes performed by the execution of a query. This value is what can really tell you if your SQL query is optimized.

To view the IO performance of the query one can use the SET STATISTICS command of SYBASE. To enable the display of the logical reads and writes you would turn on the statistics by the command:

SET STATISTICS IO ON

And would turn it off by running the command:

SET STATISTICS IO OFF

Now that you can obtain the io performance of the query you can make use of the SHOWPLAN command to fine tune your query’s performance. The SHOWPLAN command is enabled similar to the SET STATISTICS command by toggling on and off by the ON/OFF keywords:

SET SHOWPLAN ON

By setting the SHOWPLAN command to ON you will be outputted with the steps that are performed by the query or procedure. The output will display all the selects, inserts, and creations that occur when running the sql statement. Using this input one is able to fine tune the query by the reorganization of statements, addition of indexes to remove or reduce Table Scans, as well as further optimization techniques.

, , , , ,

YahooFinanceAPI is an open source php library for interacting with the Yahoo Finance Stock API. For those of you unfamiliar with Yahoo’s Stock API please review my previous post Yahoo Finance Stock API. This library contains an easy interface for obtaining information on one or more stocks. For a quick demo of the library feel free to go to http://mdbitz.com/testing/PHPYahooFinance/finance.php?symbol=DELL which will return JSON coded response of some of the basic information that can be obtained via the library. Also feel free to swap out the symbol in the url with any of your choice, if it is an invalid symbol you will simply not get any information.

Updates in Release 1.0

  • isSuccess method added to YahooFinance_Result object to check if request was successful.
  • Bug fixes for typo errors in YahooFinance_Options
  • toXML method added to YahooFinance_Result and YahooFinance_Quote
  • STRICT and LOOSE mode added to YahooFinanceAPI to throw or supress exceptions

Online Documentation

The YahooFinanceAPI PHP Library is fully documented using phpDocumentor. The online documentation contains a full code example as well as class and method descriiptions and parameters.

How do I use the YahooFinanceAPI library?

The YahooFinanceAPI was constructed so that users need to simply follow a basic 6 set process to get any stock information they are looking for.

Step 1: Obtain the main YahooFinanceAPI class

require_once(dirname(__FILE__) . '/YahooFinanceAPI.php');

Step 2: Register the autoloader

spl_autoload_register(array('YahooFinanceAPI', 'autoload'));

Step 3: Identify the information to be returned

Now that the library is properly configured in your script lets define the information that is to be returned for each of the symbols or stocks being looked up. This is done by using the addOption function of the YahooFinanceAPI instance. For a complete list of options please view the YahooFinance_Options class.

$api = new YahooFinanceAPI();
 
// set options
$api->addOption("symbol");
$api->addOption("previousClose");
$api->addOption("open");
$api->addOption("lastTrade");
$api->addOption("lastTradeTime");
$api->addOption("change" );
$api->addOption("daysLow" );
$api->addOption("daysHigh" );
$api->addOption("volume" );

Step 4: Identity the symbols (stocks) to obtain the information for

After defining the information to be returned we define they symbols (stocks) to be returned. This is done by the addSymbol function. To find symbols you can search Yahoo Finance for the company you are interested in.

$api->addSymbol("DELL" );

Step 5: Query for the Information

$result = $api->getQuotes();

Step 6: Use the Stock Information

if( $result->isSuccess() ) {
    $quotes = $result->data;
    foreach( $quotes as $quote ) {
        $symbol = $quote->symbol;
        $lastTrade = $quote->lastTrade;
    }
}

Download the YahooFinanceAPI Library

The YahooFinanceAPI is copyright MDBitz – Matthew John Denton under the GNU Public License. The current release is available for download at http://mdbitz.com/downloads/YahooFinanceAPI-1.0.zip. The archive contains the php classes as well as a test.php file that demonstrates how to use the library.

Feedback Appreciated

Please leave your comments, suggestions, and/or questions below. And if you need any additional support please feel free to send me an email at info@mdbitz.com.

, , , , ,

When writing applications, libraries, or other source code we often want some control over how it is used by the community. Licenses allow us developers to protect our rights to the source code while defining the terms in which others may utilize it. Two of the most common licenses used in open source software are the MIT License and GPL License. Although similar in that the they both allow users to utilize, modify, and redistribute the code there is one main difference between these licenses.  That difference is that the MIT License is permissive and the GPL License has strong copyleft.

Although it may be confusing at first which library you utilize comes down to whether or not you want to allow the use of your code in proprietary software.  The MIT License gives this permission under the stipulation that the License is distributed with that software, while the GPL License only grants use and modification by non-proprietary software.

As the copyright holder of the software you may decide you want to Dual License the software with both licenses allowing users to incorporate your source code into their own software under which ever license they want to use. This is also a viable option and is used by such libraries as JQuery.

Resources:

, , , , , ,