Archive for the ‘Software’ Category

Feb 26 MySQL Developer Training - Day 2 Posted at 3:06 pm | 2 Comments »

I didn’t take any notes during the first day of class, as we really only went over a lot of introductory information. However, I started taking notes at the beginning of day two, and tried to be pretty thorough. I hope they help a bit.

Day 2

Data Type Overview

Three Major Categories:

  • Numeric
    • Integer
      • Tinyint
        • 1 byte
      • Smallint
        • 2 bytes
      • Mediumint
        • 3 bytes
      • Int
        • 4 bytes
      • Bigint
        • 8 bytes
        • Bigints are used for all internal mathematic operations within MySQL
    • Floating-point (approximate numbers)
      • Float (4 bytes)
      • Double (8 bytes)
      • Floats are generally inaccurate. For instance, inserting a value of “0.99″ will actually create a value of 0.99000000953674
      • Floats will not be limited by the amount of digits you “set” when creating the column. The amount of digits you set is simply used for formatting
    • Fixed-point
      • Decimal
      • Fixed
      • Fixed-point digits will be limited by the amount of digits you “set” when creating the column. For instance, if you specify a column as DEC(4,2), it will not allow you to store the number 100. The largest value it can store is 99.99
    • BIT
      • Column width is the number of bits per value
  • Character/Binary (strings)
    • Binary elements are made up of characters, although you don’t generally manipulate the individual characters
    • CHAR - Stores a fixed number of character locations, no matter what value you give it.
      • Limited to a length of 255 characters
      • More efficient in MyISAM, because you are storing a set number of characters each time - also helps prevent fragmentation issues
    • VARCHAR - Stores a variable number of characters, up to the limit that you set when creating the table
      • If the strictness mode is turned on, it will throw an error when attempting to insert a string longer than your limit
      • If strictness mode is turned off, it will truncate the string before inserting it into the database
      • Limited to a maximum length of 65,555 characters
    • TINYTEXT - up to 255 characters
    • TEXT - up to 65,535 characters
    • MEDIUMTEXT - up to 16,777,215 characters
    • LONGTEXT - up to 4,294,967,295 characters
    • ENUM - enumarated values
      • You specify the possible values, which are treated as their numerical equivalents when evaluated
      • You can store up to 65,535 possible values for an enumerated column
      • Only one of the enumerated values can be selected in each row
    • SET - list of string values
      • You specify the possible values, as you do in ENUM
      • However, with SET, you can select multiple values for each row
      • The numerical values of a SET are stored as BIT switches rather than consecutive numbers
  • Temporal
    • TIME
      • HH:MM:SS
      • Is not necessarily an indication of time of day. This can accept times longer than 23:59:59, because it is simply an indication of amount of time
      • Can be negative or positive
      • ‘-838:59:59′ to ‘838:59:59′
    • YEAR
      • Two or four digits
      • Indicating a two-digit value will be interpreted in a range from 1970-2069
      • 1901-2155 (for year(4)), 1970-2069 (for year(2))
    • DATE
      • ‘YYYY-MM-DD’ - can only accept dates in this format
      • ‘1000-01-01′ TO ‘9999-12-31′
    • DATETIME
      • ‘YYYY-MM-DD HH:MM:SS’ - can only accept datetimes in this format
      • Time in this data type is limited to time of day. Highest value is 23:59:59 and lowest value is 0
      • ‘1000-01-01 00:00:00 to ‘9999=12-31 23:59:59′
    • TIMESTAMP
      • If given no value when creating or updating a timestamp column, it will automatically assign the current system date/time
      • No point in having more than one timestamp column, as they will all end up with the same value
      • ‘1970-01-01 00:00:00′ to mid-year 2037

You want to choose the most appropriate data type (whichever you will be using in that column the most)

Each table must have at least one column. The columns must have a name and a data type.

Precision and scale of numbers must be considered carefully when creating numeric data types

Numbers must be set up as either signed or unsigned. Signed numbers will use an equal amount of negative and positive values. In other words, a tinyint (1 byte) will range from -128 to 127 if set as signed. Unsigned will range from 0 to 255. If you will not be using negative values, you should set the column as unsigned.

To store a binary number in a column, you should specify it by beginning your value with “b”, then wrapping the value in single quotes. For example: INSERT INTO bits VALUES(b’0101′);

To store a hexidecimal number in a column, you should specify it by beginning your value with “x”.

Character Sets

A character set is a named encoded character

Each character is mapped to a specific number in a character set.

ASCII is the same as Latin1, which is close to the lower bit range of UTF-8

A character set is actually specified on a column-by-column basis within MySQL.

Character set controls sort order, based on the numerical equivalent of each character

Binary String Data Types

Binary strings are strings of characters that are intended to be interpreted as a whole, rather than by character

Binary Types

  • Binary
  • Variable Binary
  • Tinyblob
  • Blob
  • Mediumblob
  • Longblob

No character set or collation is associated with binary data

The Meaning of NULL

  • NULL can set data types to allow missing values
  • NULL can be an empty query result
  • Conceptually has several different meanings
    • no value
    • unknown value
    • missing value
    • out of range
    • not applicable
    • no column
  • Two categories
    • Unknown
    • Not applicable

Primary key columns cannot allow NULL

Unique columns can allow NULL

SQL Expressions

Numeric expressions

  • Literal Values
    • Exact-value
    • Approximate value
    • Numerical expressions with NULL usually return NULL
  • Expressions with NULL will return NULL
  • Results depend on literal values
  • SELECT 1.1 + 2.2 = 3.3, 1.1E0 + 2.2E0 = 3.3E0;
    • 1, 0 (true, false)

Mixing numbers with strings

  • MySQL is capable of converting strings into numerical values, but it uses extra resources
    • You can compare numbers with strings (1=’1′)
    • You can perform mathematical operations on numbers and strings (1+’1′, 1-’1′, etc.)
    • You should avoid that if possible

Comparison Operations

  • x >=5 AND x<=10 is not necessarily the same as x BETWEEN 5 AND 10
    • The first expression will not necessarily be optimized when querying the database
    • The second expression will always be optimized
  • BETWEEN will include the indices (so it will return anything with 5 as the key and 10 as the key, and everything in between)
  • When using BETWEEN, you must put the lowest value first

Literal strings are quoted

  • You can generally use single or double quotes to wrap your literal strings
  • If ANSI_QUOTES is enabled through MySQL, then values must be wrapped by single quotes and references to columns, etc. must be wrapped by double quotes
  • If ANSI_QUOTES is enabled, wrapping values with double quotes will cause the query to fail

String comparisons

  • Depends on character set and collation
  • The default is set to be case-insensitive
  • Therefore, an expression like “Hello”=”hello” will evaluate as true
  • You can change the character encoding when establishing a connection
    • SET collation_connection = latin1_german2_ci;
    • To compare two strings that are not identical, but are equal (”Hello” vs. “hello” or “Dusseldorf” vs. “Dⁿsseldorf”), you can set the collation to latin1_bin (which will not convert binary information to characters when comparing) or latin1_general_cs (which will still consider accented characters to be the same as their unaccented equivalents, but will not consider lowercase characters to be equal to uppercase characters)
  • Using the “LIKE” operator
    • Percent character (%) - Any character(s) wildcard - the wildcard can match multiple characters
      • LIKE ‘w%ll’ will match “well”, “wall”, “whole lot of hell”
    • Underscore character (_) - Will only match a single character
      • LIKE ‘d_g’ will match ‘dog’, but will not match ‘dung’
  • You can use regular expressions to compare strings in MySQL
    • REGEXP
    • RLIKE

Temporal Operations

Functions can be invoked in MySQL expressions

Within MySQL, functions should be followed directly by an open parens. By default, no space is allowed between function name and parens

  • You can use an IF function

IF(1 > 0 , ‘YES’, ‘NO’);

SELECT name FROM country

ORDER BY IF(code=’USA’,1,2), name;

Will order by whether or not the name is equal to “USA” first, then will order by name

  • You can also use “CASE” statements
    CASE case_expr WHEN when_expr THEN result WHEN when_expr THEN result ELSE result ENDSELECT name FROM country
    ORDER BY CASE code
    WHEN ‘USA’ THEN 1
    WHEN ‘CAN’ THEN 2
    WHEN ‘MEX’ THEN 3
    ELSE 4 END, nameSELECT CASE
    WHEN Code = ‘USA’ THEN ‘United States’
    WHEN Continent = ‘Europe’ THEN ‘Europe’
    ELSE ‘Rest of the world’
    END AS Area,
    SUM(GNP), SUM(Population) FROM Country GROUP BY Area;

Numerical Functions

  • Mathematical operations (add, subtract, divide, etc.)
  • Common functions
    • TRUNCATE()
    • FLOOR() - Returns the greatest integer that is less than the given value
    • CEILING() - Returns the smallest integer that is greater than the given value
    • ROUND()
      • By default, this will round to the nearest integer
      • If you specify a second parameter, it will round to the nearest number with the specified number of decimal places. If you insert a negative number, it will round away from the decimal (in other words, ROUND(15.75,-1) will round to 20 - the nearest 10)
    • RAND() - Returns a random number

String Functions

  • LENGTH/CHAR_LENGTH
    • LENGTH returns the number of bytes in a character string
    • CHAR_LENGTH returns the number of characters in a character string
  • ELT() - Allows you to select an item from a list
    • ELT(column_value,’1st’,'2nd’,'3rd’…)
    • If column_value is equal to 1, then the function will return “1st”, if column_value is equal to 2, then the function will return “2nd”, etc.
    • ELT is 1-based, not 0-based
  • CONCAT()/CONCAT_WS()
    • CONCAT() will simply combine all of the given arguments with no separators
      • If NULL is returned by any of the given arguments, then the entire CONCAT string will return NULL
    • CONCAT_WS() will combine all of the given arguments with a separator, which is specified as the first argument in the function
      • This function will simply skip NULL elements and not insert a separator for NULL elements
      • To concatenate a group of elements that may contain NULL anywhere, you can use CONCAT_WS(”,your_values), using a blank separator
  • STRCOMP (string compare) - compare two strings to see if they are equal, less than or equal to
    • Will return -1 if the first one is less than the second
    • Will return 0 if they are equal
    • Will return 1 if the first one is greater than the second

Temporal Functions

  • NOW() - Returns the current MySQL timestamp from the system clock
  • GET_FORMAT() - Shows us how dates and times are generally formatted in a specific region of the world
  • CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP

NULL-Related Functions

  • ISNULL()/IFNULL()
    • ISNULL returns 0 if something is not null and 1 if it is
    • IFNULL accepts two parameters. The first parameter is the item that will be evaluated and the second item is the string that will be returned if the first returns as null
    • SELECT IFNULL(Continent,’Grand Total’) ContinentName, SUM(Population) FROM Country
      GROUP BY Continent WITH ROLLUP;

MySQL Comments

  • You can use a hash character to create a comment that will end at the end of the line
  • You can use C-style comments to comment multiple lines of code
  • Within MySQL, you can set up conditional comments that will show up as comments in all other SQL DBMAs, but will be executed within MySQL
    • /*! This is not a comment to MySQL, but is in all other SQL DBMAs */
    • /*!50002 This comment will only be executed by MySQL version 5.0002 */

Metadata

Using “INFORMATION_SCHEMA”, you can gather various metadata information about your database. Some of the information you can select is:

+----------------------+
| COLUMN_NAME          |
+----------------------+
| TABLE_CATALOG        |
| TABLE_SCHEMA         |
| TABLE_NAME           |
| VIEW_DEFINITION      |
| CHECK_OPTION         |
| IS_UPDATABLE         |
| DEFINER              |
| SECURITY_TYPE        |
| CHARACTER_SET_CLIENT |
| COLLATION_CONNECTION |
+----------------------+

You can also use SHOW and DESCRIBE commands to show specific information from the database.

From the command prompt (outside of the MySQL client), you can call a program called “mysqlshow” to show you the information in your MySQL installation.

C:\Documents and Settings\Student>mysqlshow -u root -p
Enter password: ****
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| test               |
| test2              |
| world              |
+--------------------+ 

C:\Documents and Settings\Student>mysqlshow -u root -p world
Enter password: ****
Database: world
+-----------------+
|     Tables      |
+-----------------+
| city            |
| country         |
| countrylanguage |
| students        |
+-----------------+

Database Design and Information

A database is simply a directory within the filesystem

Schema is considered a synonym of database in MySQL

Two ways to approach database design:

  1. You need to convert something else (another kind of database, a spreadsheet, etc.)
  2. You are creating the database from scratch

Four basic relational types:

  1. one pointing to one (1->1)
  2. one pointing to many (1->M)
  3. many pointing to one (M->1)
  4. many pointing to many (M->M)

Within a database, you can only structurally manage a M->1 relationship (1->1 is a subset of that)

If you have a M->M relationship, then you should set up an intermediary table to relate between the two tables

Normalization

First Normal Form (1NF) - contains no repeating groups within rows

Second Normal Form (2NF) - normalize at the first level and every non-key (supporting) value is dependent on the primary key value

Third Normal Form (3NF) - normalized at the first and second level, dependent solely on the primary key and no other non-key (supporting) value

Identifier Syntax

  • Alias
  • Database
  • Column
  • Index

May be quoted or unquoted

Can use any alphanumeric characters, including $ and _. Anything using any characters other than that must be quoted.

You can access tables from other databases on the same server by qualifying the tablename:

SELECT * FROM world.Country;

Building Tables

General syntax for creating a table:

  • CREATE TABLE <table> (
    <column_name> <column type> [<column options>],
    [<column_name> <column_type> [<column_options>],…,]
    [<index list>]
    )[<table options>];
  • CREATE TABLE CountryLanguage (
    CountryCode CHAR(3) NOT NULL,
    Language CHAR(30) NOT NULL,
    IsOfficial TINYINT(1) NOT NULL DEFAULT 0,
    Percentage FLOAT(3,1) NOT NULL,
    PRIMARY KEY(CountryCode, Language)
    ) ENGINE = MyISAM COMMENT=’Lists Language Spoken’;
  • Several options available
    • ENGINE
    • COMMENT
    • CHARACTER SET (CHARSET)
    • COLLATE
  • Cannot create an auto_increment column that is not indexed

Feb 24 Sun Microsystems to Acquire MySQL Posted at 7:39 pm | 1 Comment »

A few weeks ago, I took a week-long training course on MySQL development. The course was fantastic, but extremely intensive. I learned quite a bit about using MySQL.

In addition to all of the MySQL development I picked up during the course, I was also privy to some “inside” information about Sun’s possible acquisition of MySQL.

First of all, although it is 99.9% sure that Sun will acquire MySQL, it’s not an absolute certainty, yet. There is still quite a bit of negotiating to be done before the acquisition goes through.

Secondly, although a lot of people seem to think this acquisition spells doom for MySQL and its open-source, free software, it should be an extremely good thing for MySQL and Sun’s products. Rumor has it that Sun decided to acquire MySQL because of the incredible experience MySQL has monetizing open-source software. Sun has had trouble with that proposition since the beginning. MySQL has done fairly well with it.

Sun decided to pick up MySQL as much for their business sense in the open-source software world as for the product they produce.

On a side note, while this probably won’t do anything phenomenal for those of us interacting with MySQL through PHP, developers using Java will probably have a whole lot more support and tools at their fingertips than ever before.

Over the next week or two, I will be posting my notes from the MySQL developer course. They might not make a whole lot of sense, but hopefully they’ll do somebody some good. I know they’ll do a lot of good for me in the future. Hopefully I’ll be able to get certified in MySQL before too much longer.

Feb 22 Free YouTube to iPod Converter Posted at 6:41 pm | 4 Comments »

I came across a cool, free utility the other day while I was searching for ways to get video prepared for my Zune (which I’ll review at a later date). The utility is simply called “Free YouTube to iPod Converter”. The utility was developed by DVDVideoSoft and it is extremely useful.

Free YouTube to iPod Converter

Basically, the software was designed with one purpose in mind, and it does that very well. It converts Flash Video files to video that’s compatible with your mobile devices. It’s main purpose is to convert YouTube videos to the iPod mp4 video format, but it does do a few other things, too.

First of all, not only can it convert FLV files from your hard drive into mp4 video files, it is also capable of extracting an FLV directly from YouTube. All you do is plug in the URL for the video you want to convert, and the utility accesses YouTube automatically, finds the video file embedded in the page, and extracts it for conversion. Unfortunately, it seem to only work on YouTube; it doesn’t seem to be capable of extracting FLV files from other video sites.

In addition to being able to convert FLV files to iPod video (giving you four options for the quality of the output video), it can also convert your FLV files to three quality levels of PSP video, three quality levels of mobile phone-compatible mp4 video and four different quality levels of mp3 audio.

The only issue I’ve come across in the software so far (and some people may consider this a pro for the software as opposed to a con), is that it doesn’t throw any errors out if it it fails to download the entire FLV file from YouTube. Instead, the progress indicator jumps from wherever it encountered the problem straight to 100%, and the utility tells you that it’s done converting the video. Sometimes you get the whole video, other times you only end up with a few seconds of video before it cuts off.

You can download the utility for free and view a tutorial explaining how to use the software from the main project Web site. If you have a digital media player, a PSP or a video-capable mobile phone, you should definitely get ahold of this application.

Jan 12 BluePrint for Outlook Posted at 9:53 pm | No Comments »

blueprint_med.jpgFor those of you that have installed Office 2007 on your computers, you’ve probably noticed a big problem in the new Outlook.

In previous versions of Outlook, HTML-formatted e-mail messages used the Internet Explorer print dialog, while text-only messages used the print dialog written for Outlook. The print dialog that’s been written for Outlook only gives you three options when choosing which pages to print: all, even or odd.

(more…)

Dec 3 A Free New Tool From TechSmith Posted at 6:10 pm | 1 Comment »

jing-logo.gifFirst of all, I am still sick, so this is going to be a short post, but I wanted to get something posted and I wanted to get this information out there for people.

TechSmith, the company that brought us Camtasia Studio, has released a new tool that’s completely free. The tool is called “Jing”, and from the limited time I’ve had to play with it, it seems wonderful.

Jing isn’t completely new. In fact, it’s been around for about six months. However, a new release was made on Nov. 28, 2007 that, according to the changelog, includes a lot of monumental improvements. I’m not sure how long Jing will be a free product, but as long as it is, I encourage you to try it out.

(more…)

Nov 25 Firefox 3 Beta is now available Posted at 4:07 pm | No Comments »

The first beta release of Firefox 3 was released about a week ago, and there is a lot of buzz around the Internet about its pros and cons. A pretty decent review of the beta release can be found on this site. Another good, in-depth look at Firefox 3 Beta 1 can be found on CNET’s blogs.

The main questions people around the Web seem to be asking are:
What features will be added?
Will the new Firefox handle memory more efficiently than current and older versions?
Which bugs will be fixed?
Which standards of CSS will Firefox 3 support?

You can view the official plan for Firefox 3 on Mozilla’s wiki. You can view the complete list of developer information (how to update extensions, etc.) on the Mozilla Developer Center.

Nov 11 YaBB 2.2 Released Posted at 6:10 pm | 2 Comments »

yabblogo.png

YaBB, an extremely popular and secure forum software, written entirely in Perl, released a new version on Thursday, Nov. 8, 2007. Exactly two years after YaBB 2.1 was released, YaBB 2.2 has come on full-force.

From the official announcement on the YaBB Support Forums:

YaBB 2.2 - small numbers don’t mean small changes

Below is a list of just some of the things changed for this release. The list will be updated over the next few days. There are so many improvements, it’s a project just to list them all!

Feature Additions:
——————————–
Allow members to choose non-administration membergroups in their profile
Private Messages Buddy List
Buddy list integration in view profile and topic displays
Added a:visited CSS style and various other missing or previously hardcoded styles
Carbon and Blind-Carbon Copy address boxes in Private Messages
User Panel - buddy list, private messaging center, profile, etc.
Admin option for who can see the members list
Private Message ignore list
Forward Private Messages

The full list of feature additions, security fixes, bug fixes, etc. is available in the official announcement.

Oct 26 Ripping Audio from VOB Files Posted at 8:49 pm | No Comments »

Yesterday I had the pleasure of trying to figure out how to rip the audio soundtrack off of a DVD. To say the least, it was an extremely painful process. The end lesson for me was that there is no easy way to rip the soundtrack from a DVD.

I’m certain that there are tools out there to make this easier, but with the short amount of time I had to complete the project, I wasn’t able to find one.

(more…)

Oct 4 An Interesting Discussion of Office Applications Posted at 6:06 pm | No Comments »

cnetlogo.gifI subscribe to a semiweekly newsletter from CNet that keeps me up-to-date on some of the latest blog entries and forum discussions going on at the Web site. It’s kind of like a “Dear Abby” for technology users.

The main highlight in yesterday’s issue was a discussion about Microsoft Office and some of the viable alternatives available to the public. The comments that follow the initial blog post create a fairly interesting discussion.

(more…)

Sep 24 Freeware Recommendations Posted at 5:50 pm | 3 Comments »

Because none of these utilities are open-source, I’m not going to bother writing entire reviews of each proggie. However, I did want to offer up my stamp of approval for each one.

The applications I’m going to recommend in this post range from media applications to Web development apps to general miscellaneous utilities.

(more…)

Bitrix
Clicky Web Analytics
CloudContacts
Maxtango

community discussion