Part 1
Getting Started with SQL
IN THIS PARTâŠ
The essentials of relational databases
Basic SQL concepts
Fundamental database tools
Chapter 1
Relational Database Fundamentals
IN THIS CHAPTER
Defining âdatabaseâ in digital terms Looking at the evolution of database models Defining ârelational databaseâ (can you relate?) Considering the challenges of database design SQL (pronounced ess-que-ell, not seeâqwl, though database geeks still argue about that) is a language specifically designed with databases in mind. SQL enables people to create databases, add new data to them, maintain the data in them, and retrieve selected parts of the data. Developed in the 1970s at IBM, SQL has grown and advanced over the years to become the industry standard. It is governed by a formal standard maintained by the International Standards Organization (ISO).
Various kinds of databases exist, each adhering to a different model of how the data in the database is organized.
SQL was originally developed to operate on data in databases that follow the relational model. Recently, the international SQL standard has incorporated part of the object model, resulting in hybrid structures called object-relational databases. In this chapter, I discuss data storage, devote a section to how the relational model compares with other major models, and provide a look at the important features of relational databases.
Before I talk about SQL, however, I want to nail down what I mean by the term database. Its meaning has changed, just as computers have changed the way people record and maintain information.
Keeping Track of Things
Today people use computers to perform many tasks formerly done with other tools. Computers have replaced typewriters for creating and modifying documents. Theyâve surpassed calculators as the best way to do math. Theyâve also replaced millions of pieces of paper, file folders, and file cabinets as the principal storage medium for important information. Compared with those old tools, of course, computers do much more, much faster â and with greater accuracy. These increased benefits do come at a cost, however: Computer users no longer have direct physical access to their data.
When computers occasionally fail, office workers may wonder whether computerization really improved anything at all. In the old days, a manila file folder âcrashedâ only if you dropped it â then you merely knelt down, picked up the papers, and put them back in the folder. Barring earthquakes or other major disasters, file cabinets never âwent down,â and they never gave you an error message. A hard-drive crash is another matter entirely: You canât âpick upâ lost bits and bytes. Mechanical, electrical, and human failures can make your data go away into the Great Beyond, never to return. Backing up your data frequently is one thing you can do to enhance your peace of mind. Another thing you can do is store your data in the cloud and let your cloud provider do the backing up.
Taking the necessary precautions to protect yourself from accidental data loss allows you to start cashing in on the greater speed and accuracy that computers provide.
If youâre storing important data, you have four main concerns:
- Storing data must be quick and easy because youâre likely to do it often.
- The storage medium must be reliable. You donât want to come back later and find some (or all) of your data missing.
- Data retrieval must be quick and easy, regardless of how many items you store.
- You need an easy way to separate the exact information you want now from the tons of data that you donât want right now.
State-of-the-art computer databases satisfy these four criteria. If you store more than a dozen or so data items, you probably want to store those items in a database.
What Is a Database?
The term database has fallen into loose use lately, losing much of its original meaning. To some people, a database is any collection of data items (phone books, laundry lists, parchment scrolls ⊠whatever). Other people defin...