Monday, May 14, 2012

SQL Environments

There are two general ways in which you can issue a SQL command to a database:
  • Interactive SQL, in which a user types a single command and sends it immediately to the database. The result of an interactive query is a table in main memory (a virtual table). In mainframe environments, each user has one result table at a time, which is replaced each time a new query is executed; PC environments sometimes allow several. Result tables may not be legal relations—because of nulls they may have no primary key—but that is not a problem because they are not part of the database but exist only in main memory.
  • Embedded SQL, in which SQL statements are placed in an application program. The interface presented to the user may be form-based or command-line based. Embedded SQL may be static, in which case the entire command is specified at the time the program is written. Alternatively, it may be dynamic, in which case the program builds the statement using user input and then submits it to the database.
The basic syntaxes of interactive SQL and the static embedded SQL are very similar. We will therefore spend the first portion of this book looking at interactive syntax and then turn to adapting and extending that syntax for embedding it in a program. Once you understand static embedded SQL syntax, you will be ready to look at preparing dynamic SQL statements for execution.

In addition to the two methods for writing SQL syntax, there are also a number of graphic query builders. These provide a way for a user who may not know the SQL language to “draw” the elements of a query. Many of these programs are report writers (for example, Crystal Reports3) and are not intended for data modification or for maintaining the structure of a database.

Sunday, May 13, 2012

Metadata and the Semantic Web

The basic structure of web documents provides the desired appearance and functionality. By default, however, the content is human-readable only. You can use additional technologies to provide meaning to web documents, making them machine-readable and part of the Semantic Web. Many terms have been recently introduced for emerging Semantic Web technologies, but because of the lack of formal definitions, many of the definitions are somewhat fuzzy. For example, because of the potential to perform actions automatically, a new era of the Web has begun, which is denoted as Web 2.0. After gaining popularity on online community portals, some features of the Semantic Web, together with personalization, are now referred to as Web 3.0. There is a wide choice of metadata available, along with microformats and various annotations that can significantly extend the possibilities of web documents. They can also considerably improve the effectiveness of web searches. RDF should be used to add structure to the Web and change conventional search engines that apply brute-force approaches.
In this chapter, you will learn machine-readable metadata annotations and semantically meaningful attributes. You will also become familiar with the Resource Description Framework, the fundamental standard behind Semantic Web technologies. After reading the chapter, you will be able not only to apply a variety of metadata annotations but also to create new vocabularies, schemes, and ontologies, including but not limited to the following:
  • General metadata in the markup: Conventional meta tags
  • Microformats: Metadata provided as attribute values of markup elements
  • Microdata: A metadata annotation for general metadata embedding in HTML5
  • RDF: A standardized framework for Semantic Web data models
  • OWL: A knowledge representation language for describing and sharing web ontologies that formally represent knowledge as a set of concepts within a domain and the relationships between those concepts
  • FOAF and DOAC: Machine-readable ontologies for people and their professional capabilities
  • XMP, Rich Snippets, SearchMonkey RDFa: Metadata formats for images and video clips

Thursday, May 10, 2012

Multiple Catch Clauses In JavaScript 1.5

In JavaScript 1.5, the try/catch statement has been extended to allow multiple catch
clauses. To use this feature, follow the name of the catch clause parameter with the
if keyword and a conditional expression:
try {
// multiple exception types can be thrown here
throw 1;
}
catch(e if e instanceof ReferenceError) {
// Handle reference errors here
}
catch(e if e === "quit") {
// Handle the thrown string "quit"
}
catch(e if typeof e === "string") {
// Handle any other thrown strings here
}
catch(e) {
// Handle anything else here
}
finally {
// The finally clause works as normal
}
When an exception occurs, each catch clause is tried in turn. The exception is assigned
to the named catch clause parameter, and the conditional is evaluated. If true, the body
of that catch clause is evaluated, and all other catch clauses are skipped. If a catch clause
has no conditional, it behaves as if it has the conditional if true, and it is always
triggered if no clause before it was triggered. If all catch clauses have a conditional, and
none of those conditionals are true, the exception propagates uncaught. Notice that
since the conditionals already appear within the parentheses of the catch clause, they
are not required to be directly enclosed in parentheses as they would be in a regular
if statement.

Wednesday, May 09, 2012

Playing an audio file with different sources.

Let’s say you wanted to provide audio in both Ogg Vorbis and MP3 formats to support
Firefox, Chrome, Opera, Safari, and IE9. You can do this by using the source
element in conjunction with the audio element. The code would look like this:
<audio controls>
<source src=”sayHello.ogg” type=”audio/ogg”>
<source src=”sayHello.mp3” type=”audio/mp3”>
</audio>

It couldn’t be easier!
Naturally, you can add a WAV file format too (should you want to):
<audio controls>
<source src=”sayHello.ogg” type=”audio/ogg”>
<source src=”sayHello.mp3” type=”audio/mp3”>
<source src=”sayHello.wav” type=”audio/wav”>
</audio>
You can incorporate any of the attributes mentioned earlier here as well. So
making whichever source the browser chooses to play automatically would simply
require this code:
<audio controls autoplay>
<source src=”sayHello.ogg” type=”audio/ogg”>
<source src=”sayHello.mp3” type=”audio/mp3”>
<source src=”sayHello.wav” type=”audio/wav”>
</audio>
To support browsers that don’t support the HTML5 audio element, you’d follow
the same tactic, but the fallback is different.

Monday, May 07, 2012

Google Analytics for Mobile

Google Analytics is one of the most used (and most powerful) free web statistics tool for mobile websites, but it is based on JavaScript code that, in the mobile world, only works on high-end devices.


Google Analytics for Mobile Websites (http://code.google.com/mobile/analytics/docs/web/) works on all web-enabled browsers, with or without JavaScript support. The technology supports script code for PHP, ASP.NET, Perl, and JSP.
Google Analytics is also available for Android and iPhone native appli- cations, supporting tracking of pages and events.
To use the mobile service, you should apply for a normal Google Analytics account at http://www.google.com/analytics. Create a new Website Profile and, in the Advanced section, select “A site built for a mobile phone,” select your server language, and follow the instructions.