|
In the other chapters of this course consideration is given to producing a good design for a database structure or schema. In this chapter the focus is on applying this schema to a database management system, and then using that DBMS to allow storage and retrieval of data. In the next section we will be practicing the topics we have covered so far with the sample tables we have.
Chapter 3 – SQL
To communicate with the database system itself we need a language. SQL is an international standard language for manipulating relational databases. It is based on an IBM product. SQL is short for Structured Query Language. SQL can create schemas, delete them, and change them. It can also put data into schemas and remove data. It is a data handling language, but it is not a programming language.
SQL is a DSL (Data Sub Language), which is really a combination of two languages. These are the Data Definition Language (DDL) and the Data Manipulation Language (DML). Schema changes are part of the DDL, while data changes are part of the DML. We will consider both parts of the DSL in this discussion of SQL.
Sections covering basic SQL usage.
- Simple SELECT statements
- Logical Operators and Aggregation
- JOINs and VIEWs
- Subqueries and Schema
3.A. Simple SELECT statements Download Tutorial
Please review the following sections in detail after you complete the tutorial from the download link above.
3.B. Logical Operators and Aggregation Download Tutorial
Please review the following sections in detail after you complete the tutorial from the download link above.
In the previous section we saw how a single rule could be added to a query using a WHERE clause. While this is useful, usually more than a single rule is required to produce the correct result. To support multiple rules we need to make use of NOT, AND, OR and parentheses.
3.C. JOINs and VIEWs Download Tutorial
Please review the following sections in detail after you complete the tutorial from the download link above.
3.D. Subqueries and Schema Download Tutorial
Please review the following sections in detail after you complete the tutorial from the download link above.
One SELECT statement can be used inside another, allowing the result of executing one query to be used in the WHERE rules of the other SELECT statement. Where one SELECT statement appears within another SELECT statement's WHERE clause it is known as a SUBQUERY.
One limitation of subqueries is that it can only return one attribute. This means that the subquery can only have one attribute in its SELECT line. If you supply more than one attribute the system will report an error.
Subqueries are generally used in situations where one might normally use a self join or a view. Subqueries tend to be much easier to understand.
Practice the above Chapters
Note: Please use discussion board if you have any questions.
This is an online SQL environment. It provides tutorials to learners, which they can interact with, execute their own SQL, and obtain automatic feedback on the quality of that SQL.
Anyone is free to use the environment. Registration is used to support users returning to the site to continue from where they left off. Please be accurate in registration details, thus allowing me to separate real University students from independent users.
Download the notes and Code samples for the above practice. I would advice you to print and practice them online here or on your Local PC. You can use any site downloader for offline preparation.
Trackback(0)
|