Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles

SQL etc

Posted Jun 24, 2002

Introduction to Relational Databases - Page 3

By Ian Gilfillan

Views are virtual tables. They do not contain any data themselves - rather they're a structure to allow us to access data, or a subset of the data. A view can consist of a subset of one table, such as in this example:

  • Code
  • First name
  • Surname
  • Age
  • Address
  • Telephone

This is the complete list of fields from the poet table

Subscriber view
  • Code
  • First_name
  • Surname
  • Grade

This view could be used to allow others to see the poet's code, name and surname, but not allow them access to personal information. Or, a view could be a combination of a number of tables, such as in this example

: Poet
  • Code
  • First name
  • Surname
  • Age
  • Address
  • Telephone

  • Poem code
  • Poet code
  • Title

Subscriber view
  • First_name
  • Surname
  • Poem title

Views are often used for security purposes. Junior developers may need access to certain portions of a table, but they do not need access to all the data. What they don't need, even if it is from the same table, is hidden and safe from manipulation or viewing. Also, views allow SQL queries to be much simpler. For example, without views, a developer may have to use the following query:

SELECT first_name,surname,poem FROM poet,poem
WHERE poem.poet_code=poet.code AND poet.title='Once';

With the view, a developer could do the same with:

SELECT first_name,surname,poem from subscriber_view;

Much more simple for a junior developer who hasn't yet learnt how to do joins across multiple tables, and less hassle for a senior developer too!

This has been a brief introduction to relational databases. Hopefully it's put some of the terms you've come across in context, and whetted your appetite to explore further.

Additional Resources:

SQL etc Archives

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Latest Forum Threads
SQL etc Forum
Topic By Replies Updated
MySQL rollback UAL225 0 August 21st, 09:56 PM
Complex Search Query Galway 0 May 20th, 10:04 PM
change collation at once supercain 2 May 15th, 06:18 AM
SQL Features, tools and utilities question Neomite 1 April 10th, 09:13 AM