COMPUTER STUDIES

STRUCTURED QUERY LANGUAGE

Structured Query Language (SQL) is a special-purpose programming language designed for managing data in relational database management systems (RDBMS).Originally based upon relational algebra and tuple relational calculus, its scope includes data insert, query, update and delete, schema creation and modification, and data access control. SQL was one of the first commercial languages for Edgar F. Codd’s relational model.

The SQL language is subdivided into several language elements, including:

  1. Clauses, which are constituent components of statements and queries. In some cases, these are optional.
  2. Expressions, which can produce either scalar values or tables consisting of columns and rows of data.
  3. Predicates, which specify conditions that can be evaluated to SQL three-valued logic (3VL) or Boolean (true/false/ unknown) truth values and which are used to limit the effects of statements and queries, or to change program flow.
  4. Queries, which retrieve the data based on specific criteria. This is the most important element of SQL.
  5. Statements, which may have a persistent effect on schemata and data, or which may control transactions, program flow, connections, sessions, or diagnostics.

 

Creating a Database

With database management systems, many tasks can be done either via programmatically or a user interface. Creating databases is no exception.

The following examples demonstrate how to create a database in Microsoft Access.

1) From the “File” menu, click on “New Database”:

 

2) Choose “Blank Database”. (MS Access also gives you the ability to choose from a template, but we’ll just use a blank database here):

 

3) Choose a location to save the database:

 

Your New Database

Once you have completed the above tasks, you should see a blank database, like this:

 

We know this database is blank because it does not have any tables. If it did, you would see these tables in the middle pane of the table tab. Now that we have our blank database, we can start adding some tables.

 

Adding Data to a Database

There are a number of ways you can enter data into a database table. The method you choose will largely depend on your context.

You will need to choose from the following methods:

  • Direct entry.
  • Form.
  • Structured Query Language (SQL).
  • Website or other application.

 

Here is an explanation of those methods.

Direct entry

You can type directly into the table while it’s in Data Sheet view. Initially, this may seem like the quickest and easiest method, but it’s not suitable if you have lots of data, and/or if non-technical users need to enter data.

 

Form

If you use a desktop database program (such as MS Access), you can set up a form, so that non-technical users can enter data into the form. Once they submit the form, the data is automatically inserted into our table. The form could insert data into multiple tables too – saving you from having to open up each table to manually insert the data.

 

Most enterprise database systems don’t have the ability for setting up a form. This is probably because they’re designed for larger scale applications with hundreds, thousands, or even millions of users. In this environment, a form would be created through other means (for example, using HTML).

Applications such as Access provide a form wizard, which steps you through the process to building a form.

 

Structured Query Language (SQL)

You can use a programming language called SQL to insert the data (we could also have used SQL to create the database and tables if we’d wanted to). One advantage of this is that you can save your SQL script for re-use. This could be handy if you need to insert the data into multiple databases.

 

It is also useful to create scripts that insert “lookup” data – this is generally a base set of data that never changes (such as Countries, Cities, etc). If you ever need to rebuild your database, you can simply run your ready made script against it (which saves you from manually re-entering the data).

Leave a Reply

Your email address will not be published. Required fields are marked *

Advantages of local domestic helper.
Blogarama - Blog Directory