Databases are a vital component of modern websites. Common functionality that Internet users have come to expect, such as user login, would not be possible without the existence of a database.
Communication with and manipulation of a database is possible using Structured Query Language (SQL). The basic structure of a simple SQL Select statement is below:
The ‘SELECT’ tag specifies which pieces of data (‘fields’) are to be taken from the table – the * simply means ‘all’. When naming a list of fields, use a comma to separate them.
The ‘FROM’ tag specifies the table name the statement is referring to.
Finally, the ‘WHERE’ condition contains filters to prevent unwanted data from being returned in the query results.
For example, a select statement to gather the name of employees who are older than sixty might look like the following:
SELECT firstname, surname
WHERE age > 60;
You might have noticed the semi-colon at the end of the statement. This is necessary to tell the DBMS (see below) where the statement ends.
Once the knowledge of basic SQL structure is gained, it becomes easier to learn different types of statements. Alternatives to the SELECT statement in our example above include DELETE, INSERT and UPDATE. Though these have slightly different syntaxes, they follow this same basic structure.
The control of databases and use of SQL is done through a Database Management System (DBMS). Of all the types of DBMS available, there are three that stand out:
– MySQL (often used in conjunction with PHP)
– Microsoft SQL Server (often used with .NET programming languages, such as C#)
Each requires the developer to communicate using slightly different syntax, but they are all based around the same core SQL.
At Somerset Web Services we have worked with each of these DBMS. If you have need of a website or piece of software involving a database, we can help you set it up. Maybe you’re not sure whether you need a database? Give us a call on 01823 353760 and we’d be glad to help, whatever your enquiry.