3.4 Using a query language
When you search a large website for information, for instance when you search a large e-government site, very often, behind the scenes, a large relational database is being searched. I mentioned earlier the use of SQL as a way of extracting information from a database. Depending on the system being used, your enquiry may be converted into an SQL query, and this finds the information you need. For example, suppose we wanted to find the family names of all people enrolled on the digital photography course (E02) in the last section. Below is an SQL query to find this information. (There are other ways to construct this query using SQL.)
FROM TABLE_2 JOIN TABLE_4 ON TABLE_2.STUDENT_KEY=TABLE_4.STUDENT_KEY
I will briefly explain how the query works. It is based on the idea of merging Tables 2 and 4 ('Table_2 join Table_4'), subject to certain constraints. One constraint is that the student_keys must be equal ('On Table_2.Student key=Table_4.Student_key'). In effect, the merged table is like Table 2, but with an extra column giving the course codes for each student. However, the only records included in this table are those for which the course code is E02, as specified in the condition 'Where course_code='E02''. The first instruction ('select family_name') retrieves the required information from this joint table.