SQL Check Constraints on MySQL Databases

An SQL check constraint is used and designed in the schema of a database table to restrict the range of values that can be entered into a specific field. In many experienced, they are very rarely used. However, these simple checks, entered at the time of database table creation, can provide additional safe guards against ‘bad’ data getting into your database tables, either via errors in code or simply user area. SQL check constraints can act as a last line of defence against ‘bad’ data, as it is verification at the database level.

You can create a table with a check constraint in MySQL as follows. The check in this example disallows values of the ‘P_Id’ field from falling outside of the condition ‘P_Id>0′. In other words, the ‘P_Id’ field’s values must almost be greater than zero in order for the data to be accepted into the table by the database management system (DBMS).

CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (P_Id>0)
)

You are probably wondering how to add a constraint to an existing database table. This is quite easy, and uses an ‘ALTER TABLE’ SQL query. See the following example for how to add a check constraint to one of your existing database tables.

ALTER TABLE Persons
ADD CHECK (P_Id>0)

For more information, there are other highly useful example queries relating to SQL check constraints at the relevant SQL check constraint article on W3schools.

The iPad and its effect on the Mobile Web

Apple iPadI recently wrote an article on the company blog regarding the Apple iPad and its potential effect on the mobile web.

“The release of Apple’s ever popular smartphone, the iPhone, back in mid 2007 caused a huge development spike in websites and dynamic web applications designed the mobile devices. Of course, the vast majority of these mobile website were developed specifically with the iPhone in mind, however the results were beneficial to pretty much all smartphones with the capability the browse the web and with some form of web browser application.

So, why do I think the iPad will slow this development in the mobile web market? The iPad is a mobile device itself is it not?

Well, perhaps not. Apple’s iPad does indeed use an operating system very similar to the iPhone, with backwards compatibility with almost all of the iPhone’s downloadable apps, and yes, it is mobile in the true sense of the word – it can be easily carried around unlike a full desktop computer and much more easily than a typically larger and much heavier laptop. However, the one aspect of the iPad which stands out is its native screen resolution of 1024×768″

If you’re interested, feel free to read the full article on how the iPad may affect the development of mobile websites in the near future.

Contacular PHP Contact Form

This is just a quick post to announce the recent start of one of my recent open source projects, Contacular. I have been building up Contacular’s overall feature set over the past week, having made the initial release on the 25th of January 2010. I now believe it is worthy of a post here, based on the large influx of recent visitors to the Contacular website.

So, what is Contacular?

Contacular PHP contact form botContacular is an open source contact form generator and processor written in PHP. It is designed to be used as either a complete PHP contact form solution, with full validation and e-mailing, or as an initial code base for web development to build upon. I’ve designed Contacular to be really simple to get up and running with and yet still be very expandable. The entire system is object-orientated and open source licensed.

A quick overview of the features of Contacular:

  1. Fully integrated contact form solution
  2. Simple generation of contact forms
  3. Many built-in Contacular contact form types
  4. Integrated reCAPTCHA human check / spam protection support
  5. Adoption of existing website styling (CSS) wherever possible
  6. Form field validation in all forms
  7. Automatic validation error reporting
  8. Advanced validation – e.g. checking submitted e-mail addresses are from real domains
  9. E-mailing form results to one or more recipients
  10. GPL licensed, open source, object orientated code base
  11. Tested in multiple browsers on multiple platforms
  12. Seamless upgrading to new versions – just download and replace the files
  13. Easily expandable
  14. More on the way…

Take a look at the how to use Contacular guide, and if you’re interested, go ahead and download Contacular. The latest version is always at the top, with that download page also containing the Contacular change log.

Ubuntu 10.04 Lucid Lynx sees the release of Alpha 2

Ubuntu 10.04, currently in development, has hit the second alpha release. As a quite update, here are some of the features you can see in the Alpha 2 release of Ubuntu 10.04.

  • A new graphical boot screen manager called ‘Plymouth’ which is to replace the currently used xsplash and usplash boot screen systems.
  • The user menu and power/session locking menus have been split into two distinct icons, marking the first steps into the development of Ubuntu 10.04’s social networking features including the ‘Me Menu’.
  • Improvements in the manner in which restricted drivers are handled allows you to now have multiple nVidia graphics drivers of different versions installed simultaneously. Activating an individual driver is then only a matter of a few click and a restart.

In terms of application changes, the PiTiVi Video Editor has been added to allow home and professional users to perform various tasks to create new videos or editing existing ones. It comes with a variety of features including different video/audio effects, time-line management, dubbing and the like. A quick screenshot of the PiTiVi video editor is shown below.

PiTiVi video editor screenshot

Many of the existing default games in Ubuntu are planned to be replaced over the course of the development cycle for Lucid Lynx. gBrainy is the first new game to enter the scene, and is a brain training game, which is essentially a fun and extensible logic, memory and intelligence test. It resembles, it some ways, the brain training exercises and games for the Nintendo DS.

Rhythmbox Music Player, the default music playing application which ships with Ubuntu has seen some usability improvements in the way of a new application indicator. Application indicator’s are a new attempt to standardise and regulate the difference between notification and effective quick access menus for specific applications which require or desire interaction beyond the scope of their main application windows.

On a more heavily technical side, Alpha 2 of Ubuntu Lucid Lynx brings with it the complete removal of ‘hal’, the now legacy hardware abstraction layer. The removal of hal will allow for faster boot up, shut down and improved, speedier resuming from suspend and hibernation mode.

For additional details about Ubuntu 10.04 Lucid Lynx Alpha 2 and the changes it brings, see the official Ubuntu 10.04 Alpha 2 testing page.

Avatar film rendered with enormous Ubuntu server farm

It turns out that Avatar, the hugely successful science fiction epic film from James Cameron, was rendered using a huge Ubuntu rendering server farm, at Weta Digital.

Avatar Movie Ubuntu

The Weta Digital server farm or ‘rendering wall’, as they call it, has a disk array capable of storing roughly 2 petabytes of data in total. The individual servers are linked by a 10 gigabits per second networking infrastructure, and in total there are 35,000 cores based in over 4000 Hewlett Packard Blade servers. In the case of Avatar, each minute of rendering equates to approximately 17.28GB of data.

The system is entirely water-cooled, as traditional air and fan cooling systems are not sufficient during near deadline times, due to constant high load on the servers.The photograph below shows the enormous water cooling system cooling a portion of the server farm.

Weta Digital Water Cooled Servers

The high power server farm used to render many films computer generated imagery (including Avatar), shown with its advanced water cooling system.

According to Paul Gunn, a systems admistrator at Weta Digital, Ubuntu is at the core of almost all their systems. Ubuntu runs on all of their 3D rendering servers, and at least 90% of all their desktop systems. More detailed information about the Ubuntu powered rendering farm that rendered the CGI of Avatar is available from the Information Management and IT World websites.

vBulletin Fake User Plugin – Good or bad?

This article is pulled from a previous site of mine, and relates to the starting of a forum board and the negative cycle of not having enough users registered to entice new users to join. It primarily focuses around the idea of using a vBulletin plugin to artificially inflate the number of online users in a vBulletin powered forum board.

When starting a new forum board based on the vBulletin forum (or in fact an forum software), one of the most common problem is making the board popular and getting users to register. The problem most people face is that users will not register on a forum board that looks completely empty! I mean, who would?

So, how can you do this? People will not register if a board is empty – that much is obvious. I’ve recently had to artificially inflate the user count and online users for a vBulletin forum, by request of the forum board owner. Luckily, I found an excellent plugin which does just this. Not only does it increase the counts for online members and guests, but it also lists real usernames.

It is implemented by grabbing the existing member names from the database and appending them to user list at the bottom of the forum home. This plugin is very ingenius and pretty believable – good if you are starting up a new vBulletin powered forum board.

You can read more about the vBulletin Fake User plugin on this website.. Note that you will need a vBulletin.org account and a valid vBulletin license to download this plugin.

Retrospectively, I do not believe this is necessarily the best manner in which to entice new users to any form of community for it provides little motivation to join beyond the active community. If the ‘active community’ (which in this case, would not exist) produces no content worthy of the potential member’s time, why would they feel the need to register or sign up?

I have and still do run a few online communities, including vBulletin forum boards. During this time, I have found new and interesting content to the specific niche (if one exists) is the key for all forms of online social activity and indeed, for drawing in new users. If the content is interesting enough, people will come either in surges for time sensitive content or as a new member registration trickle effect over time.

A Social Media Overview – How are you feeling?

How are you feeling?How are you feeling? View the day’s global mood swings with this fun, social media, Twitter-powered tool. Click here to choose a feeling and begin.

‘How are you feeling?’ is a quick social overview of the feelings that are appearing in the microblogging community. It pulls down hourly updates of today’s microblogs (or ‘Tweets’) based on specific emotional keywords, and presents these microblogs in an appealing and ever so slightly artistic manner.

Clicking an individual microblog will take you directly to the specific Tweet and allow you to see the otherwise hidden author of that Tweet. Take a look at some of the screenshots below and then try out ‘How are you feeling?’ for yourself.

How are you feeling? List of moods

How are you feeling? Specific mood - relaxed people

‘How are you feeling?’ is a social media tool/toy/experiment and dynamic web application, created by myself ever so quickly one lunchtime, using PHP running under the Apache web-server. I hope you enjoy playing with it.

New Indicator Applet & Messaging Menu for Ubuntu 10.04 Lucid Lynx

I previously discussed some of the new social networking aspects coming in Ubuntu 10.04. These mainly focus on the brand new Me Menu which is a personalised menu that holds and controls all your social networking and assists with broadcasting to microblogging services. Some related changes are the new changes to the indicator applet and attached messaging menu.

Currently, in the Ubuntu 9.10 (the latest stable version of Ubuntu), the indicator applet and messaging menu looks like the following screenshot taken from my computer.

Current Ubuntu Indicator Applet 0.1 and Messaging Menu

Looks relatively bland. It essentially list the current communication or social programs for instant messaging, microblogging, e-mailing and general social networking. It also list any recent communications, stating the user name of the contact you’ve spoken to recently (not shown in above screenshot). Many new improvements are planned for the next iteration of the messaging menu and indicator applet (currently at version 0.3). The following design mock up of the messaging menu emphasises the most important and visible changes for the end-user.

New Ubuntu Messaging Menu

As you can see, there is a lot more content in the new messaging menu. One of the important points is the ability to access certain programs actions directly. So, for example, if I wanted to send an e-mail to someone, I could just click the messaging menu and hit ‘Compose New Message’ which would very easily let me start writing and e-mail without the need to find my e-mail application, start it and locate the ‘compose new message’ button, which can easily vary in location and appearance between applications. By adding this action to the messaging menu, this has the effect of not only making the option easier to find, but also – potentially more importantly – it abstracts away the specifics of the application itself and draws the focus towards the user, their desire and their content.

In my opinion, application abstraction is very important. Most users do not wish to ‘use Evolution’ or ‘use Thunderbird’, they want to ‘check their e-mail’ or ‘compose a new e-mail’. Allowing them to do this regarding of the e-mail client they use reduces the learning curve significantly. The same principle applies to many other applications, including those outside of communications, such as productivity applications. Users tend to want to ‘create a new document’, ‘draw a picture’, and ‘check a budgeting spreadsheet’ rather than ‘open OpenOffice Write and create a blank OpenDocument Text file’, ‘open image editing software and create a new blank image’ and ‘open spreadsheet application and locate/open relevant file’. Even saying the specific non-abstracted alternatives takes a long time, but essentially the users content should be priority over the application itself in the vast majority of cases. One says that work is on a spreadsheet, an image or a document and not an Excel, GIMP or Writer file.

The new messaging menu brings on this concept of application abstraction with the instant messaging system. You can see in the second and third sections of the menu, instant messaging contacts and recent microblogging activity (mocked up as messages from ’sabdfl’) are shown as independent of the application which controls them. In this case, it would be likely be Empathy (for instant messaging) and Gwibber (for microblogging) that controlled these sections, but note the application name itself in not even mentioned, as it is not relevant to the actual social actions, which again demonstrates abstraction away from the specific applications and a focus on user content.

The final two sections indicate e-mail notification from GMail and IRC conversations with XChat. In these cases, definitely so with the GMail e-mail notifications, it is relevant to display the application name as this is an important part of the relevant content itself (the e-mail account).

Hope this quite summary gives you a good idea of what changes are coming to the messaging menu and its attached indicator applet in Ubuntu 10.04. More information is available about the new messaging menu at its design specification while these is additional information about the new indicator applet available on the applet’s Lauchpad pages.

What are your opinions on the new messaging menu? Will it affect your social use of Ubuntu? Will it affect your work flow? If so, how?

Ubuntu 10.04 Lucid Lynx’s Social Networking Features

Social media and social networking are huge now-a-days, with Twitter, Facebook and the like being hugely successful at keeping friends and family in touch. Now only that, but social networks are huge for charities, with many causes being supported and heavily promoted via social networking. Corporations and business use social networking too to promote their products and services to users in a manner which is so relevant that they tend not to annoy as is generally the case with more corporate advertising.

With the currently in development, Ubuntu 10.04, codenamed Lucid Lynx, the development road map is set to take huge advantage of the major social networks. Common social networking actions, such as updating your Facebook status, or sending a Tweet to your friends are set to be integrated directly into the operating system allowing users to keep their friends up-to-date and share information without the need to even open a web browser.

Take a look at the image below. This is a basic mock-up of the new social menu codenamed the ‘Me Menu’, which is aimed to become to a simple, centralised way to manage your social activities. It has options for a user avatar, multiple social networks, instant messaging and microblogging services and the setting and broadcast of custom and preset statuses and microblogs.

Ubuntu Me Menu Mockup

This clever menu will link into other social applications, like your instance messaging application. In others words, you set your status in the me menu, and the update is reflected automatically in all your social networks and configured social applications. Related to this, in the diagram above, ‘Chat Accounts…’ will refer to all forms of instant messaging and direct communications, while ‘Broadcast Accounts’ will refer to social networks which allow you to share a status update such as Twitter, Facebook and identi.ca.

The Ubuntu One service will also be integrated into the Me Menu and Ubuntu’s new social infrastructure. This will allow social network information to be synchronised and related to your Ubuntu One login, along with the existing file synchronisation, contact management and note synchronisation services already offered by Ubuntu One.

The Me Menu will be the overall representation of ‘you’ within Ubuntu. If you want more information regarding the Me Menu, which is to become the central social network integrations of Ubuntu, you can take a look at the design specification.

Don’t be evil licensing

Evil Inside Intel LogoGoogle, who brought forward the specifics of the ‘do no evil’ ideology within consumer visible software, is refusing to host an open-source project due to slight, almost humorous, modifications to its license, denying ‘evil’ use of the licensed software.

Douglas Crockford selected the MIT license for his JSMin program to reduce JavaScript code syntax in such a way to make it still functionally identical but smaller in size to enable bandwidth savings when these JavaScript files are downloaded by end-users’ web browsers. Ryan Grove continued to utilise this license for his variation of JSMin called JSMin-PHP, appropriately rewritten in the PHP language. This specific license however, contains a variation from the original MIT open-source license, as it includes the following line of text, originally inserted into the license for assumed comical value.

“The Software shall be used for Good, not Evil.”

Since Google’s code hosting solution, imaginatively called ‘Google Code’ only allows hosting of code licensed under very specific open-source licenses, this single modification acts an additional condition which Google is not willing to accept. This means JSMin-PHP can not be hosted at Google Code simply due to this licensing issue.

The developer of JSMin-PHP, Ryan Groove has the following to say about this, on his blog.

“As Google (and some others) interpret it, this additional requirement constitutes a vague use restriction and thus makes the license non-free. Chris [DiBona] explained that if I were to remove that line from the license and ‘return to a proper open source license that we support,’ then jsmin-php could stay on Google Code. Otherwise, he said, ‘we can’t host you,’

… Of course, I can’t change the license, because it’s not my license. It’s Douglas’s license… All derivative works and copies of jsmin.c either include this license or are in violation of it.”

If you are using Google Code to host your project, be warned, Google are very tight on their licensing restrictions. What do you think? Valid reasoning or over the top enforcement of open-source licensing terms?