Skip to main content Accessibility help
×
Hostname: page-component-74d7c59bfc-6sd86 Total loading time: 0 Render date: 2026-02-04T06:32:55.748Z Has data issue: false hasContentIssue false

7 - Relational Databases: Structured Query Language (SQL)

from Part II - Types of Database Systems

Published online by Cambridge University Press:  17 August 2019

Wilfried Lemahieu
Affiliation:
KU Leuven, Belgium
Seppe vanden Broucke
Affiliation:
KU Leuven, Belgium
Bart Baesens
Affiliation:
KU Leuven, Belgium
Get access

Summary

Chapter Objectives

In this chapter, you will learn to:

  • • understand the importance of SQL in an RDBMS environment;

  • • use SQL as a data definition language (DDL);

  • • use SQL as a data manipulation language (DML) for retrieving, inserting, deleting, and updating data;

  • • define and use views in SQL;

  • • define indexes in SQL;

  • • use SQL for granting and revoking privileges;

  • • understand how SQL can be used to manage metadata.

  • Opening Scenario

    The relational model adopted by Sober needs to serve various information needs. For example, the insurance firm of the company requests an overview of all accidents together with the number of Sober cars involved and the average damage amount per accident. As part of its customer relationship management (CRM) program, the company wants to retrieve the customer with the maximum wait time and offer him or her a free ride-hailing service. Furthermore, Sober also would like to find out which customers have never booked any of its services and target them with a promotion campaign. To implement its eco-friendly tree-planting program, Sober needs to know which customers booked more than 20 Sober ride-sharing services. Finally, the company remembers that one of the limitations of the EER conceptual data model was that it is perfectly possible that customers book either a ride-hailing or ride-sharing service with their own car. To safeguard its data quality, Sober wants to periodically check that this is not the case in its relational database.

    In the previous chapter, we dealt with the modeling aspects of relational databases. In this chapter, we elaborate on SQL, which is the lingua franca of RDBMSs and one of the most popular data definition and manipulation languages in use in the industry nowadays. Its core functionality is implemented, with only some minor variations, throughout all RDBMS products. We discuss the SQL language constructs to express a relational model and to formulate queries that retrieve and modify the data in a relational database.

    First, we provide an overview of the SQL data definition language (SQL DDL) to define a relational data model. We also discuss how the SQL data manipulation language (SQL DML) can be used for data manipulation such as retrieving data, updating data, inserting new data and deleting existing data. We then elaborate on SQL views and SQL indexes, which are part of the external and internal data model, respectively.

    Information

    Type
    Chapter
    Information
    Principles of Database Management
    The Practical Guide to Storing, Managing and Analyzing Big and Small Data
    , pp. 146 - 206
    Publisher: Cambridge University Press
    Print publication year: 2018

    Access options

    Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

    Book purchase

    Temporarily unavailable

    Accessibility standard: Unknown

    Why this information is here

    This section outlines the accessibility features of this content - including support for screen readers, full keyboard navigation and high-contrast display options. This may not be relevant for you.

    Accessibility Information

    Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

    Save book to Kindle

    To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

    Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

    Find out more about the Kindle Personal Document Service.

    Available formats No formats are currently available for this content.
    ×

    Save book to Dropbox

    To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

    Available formats No formats are currently available for this content.
    ×

    Save book to Google Drive

    To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

    Available formats No formats are currently available for this content.
    ×