Home > Articles > Data

This chapter is from the book

An Introduction to the Database Used in This Book

Before continuing with your journey through SQL fundamentals, the next step is introducing the tables and data that you use throughout the course of instruction for the next 23 one-hour lessons. The next two sections provide an overview of the specific tables (the database) being used, their relationship to one another, their structure, and examples of the data contained.

Diagram of the Tables in This Book

Figure 1.4 reveals the relationship between the tables that you use for examples, quiz questions, and exercises in this book. Each table is identified by the table name as well as each residing field in the table. Follow the mapping lines to compare the specific tables' relationship through a common field, in most cases referred to as the primary key (discussed in Hour 3).

Table-Naming Standards

Table-naming standards, as well as any standard within a business, are critical to maintaining control. After studying the tables and data in the previous sections, you probably noticed that each table's suffix is _TBL. This is a naming standard selected for use, such as what's been used at various client sites. The _TBL simply tells you that the object is a table; there are many different types of objects in a relational database. For example, you will see that the suffix _INX is used to identify indexes on tables in later hours. Naming standards exist almost exclusively for overall organization and assist immensely in the administration of any relational database. Remember, the use of a suffix is not mandatory when naming database objects.

Figure 1.4 Table relationships for this book.

NOTE

You should not only adhere to the object-naming syntax of any SQL implementation, but also follow local business rules and create names that are descriptive and related to the data groupings for the business.

A Look at the Data

This section offers a picture of the data contained in each one of the tables used in this book. Take a few minutes and study the data, the variations, and the relationships between the tables and the data itself. Notice that some fields may not require data, which is specified when each table is created in the database.

EMPLOYEE_TBL

EMP_ID    LAST_NAM FIRST_NA  M  ADDRESS         CITY         ST  ZIP  PHONE
--------- -------- --------- -- -------------  ------------  -- ----- ----------
311549902 STEPHENS TINA      D  RR 3 BOX 17A    GREENWOOD    IN 47890 3178784465


442346889 PLEW     LINDA     C  3301 BEACON     INDIANAPOLIS IN 46224 3172978990


213764555 GLASS    BRANDON   S  1710 MAIN ST    WHITELAND    IN 47885 3178984321


313782439 GLASS    JACOB        3789 RIVER BLVD INDIANAPOLIS IN 45734 3175457676


220984332 WALLACE  MARIAH       7889 KEYSTONE   INDIANAPOLIS IN 46741 3173325986


443679012 SPURGEON TIFFANY      5 GEORGE COURT  INDIANAPOLIS IN 46234 3175679007


EMPLOYEE_PAY_TBL


EMP_ID    POSITION        DATE_HIRE   PAY_RATE  DATE_LAST     SALARY      BONUS
--------- --------------- ----------- --------  ------------- ----------- ------
311549902 MARKETING       23-MAY-89             01-MAY-99     4000
442346889 TEAM LEADER     17-JUN-90      14.75  01-JUN-99
213764555 SALES MANAGER   14-AUG-94             01-AUG-99     3000        2000
313782439 SALESMAN        28-JUN-97                           2000        1000
220984332 SHIPPER         22-JUL-96         11  01-JUL-99
443679012 SHIPPER         14-JAN-91         15  01-JAN-99


CUSTOMER_TBL


CUST_ID CUST_NAME       ADDRESS        CUST_CITY      ST  ZIP   CUST_PHONE   CUST_FAX
------- --------------- ----------    ------------    -- ----- ------------ --------
232     LESLIE GLEASON  798 HARDAW     INDIANAPOLIS   IN 47856 3175457690
                        AY DR


109     NANCY BUNKER    APT A 4556     BROAD RIPPLE   IN 47950 3174262323
                        WATERWAY


345     ANGELA DOBKO    RR3 BOX 76     LEBANON        IN 49967 7658970090


090     WENDY WOLF      3345 GATEW     INDIANAPOLIS   IN 46224 3172913421
                        AY DR


12      MARYS GIFT SHOP 435 MAIN S     DANVILLE       IL 47978 3178567221  3178523434
                        T


432     SCOTTYS MARKET  RR2 BOX 17     BROWNSBURG     IN 45687 3178529835  3178529836
                        3


333     JASONS AND DALL LAFAYETTE     INDIANAPOLIS    IN 46222 3172978886  3172978887
        AS GOODIES      SQ MALL

21     MORGANS CANDIES  5657 W        INDIANAPOLIS    IN 46234 3172714398
       AND TREATS       TENTH ST

43     SCHYLERS NOVELT  17 MAPLE        LEBANON       IN 48990 3174346758
       IES              ST

287    GAVINS PLACE     9880 ROCKV      INDIANAPOLIS  IN 46244 3172719991  3172719992
                        ILLE RD

288   HOLLYS GAMEARAMA  567 US 31       WHITELAND     IN 49980 3178879023

590   HEATHERS FEATHE   4090 N SHA      INDIANAPOLIS  IN 43278 3175456768
      RS AND THINGS     DELAND AVE

610   REGANS HOBBIES    451 GREEN       PLAINFIELD    IN 46818 3178393441  3178399090

560   ANDYS CANDIES     RR 1            NASHVILLE     IN 48756 8123239871
                        BOX 34

221   RYANS STUFF       2337 S          INDIANAPOLIS IN 47834  3175634402
                        SHELBY ST

175	  CAMERON'S PIES    178 N TIBBS     AVON         IN 46234  3174543390

290   CALEIGH'S KITTENS 244 WEST ST     LEBANON      IN 47890  3174867754

56	  DANIELS SPANIELS  17 MAIN ST      GREENWOOD    IN 46578  3172319908

978	  AUTUMN'S BASKETS  5648 CENTER ST  SOUTHPORT    IN 45631  3178887565

ORDERS_TBL
  
ORD_NUM    CUST_ID PROD_ID           QTY ORD_DATE
---------- ------- ----------------- --- ---------
56A901     232     11235               1 22-OCT-99
56A917     12      907               100 30-SEP-99
32A132     43      222                25 10-OCT-99
16C17      090     222                 2 17-OCT-99
18D778     287     90                 10 17-OCT-99
23E934     432     13                 20 15-OCT-99

PRODUCTS_TBL
 
PROD_ID     PROD_DESC                      COST
---------- ------------------------------ ------
11235      WITCHES COSTUME                29.99
222        PLASTIC PUMPKIN 18 INCH         7.75
13         FALSE PARAFFIN TEETH            1.10
90         LIGHTED LANTERNS               14.50
15         ASSORTED COSTUMES              10.00
9          CANDY CORN                      1.35
6          PUMPKIN CANDY                   1.45
87         PLASTIC SPIDERS                 1.05
119        ASSORTED MASKS                  4.95

A Closer Look at What Comprises a Table

The storage and maintenance of valuable data is the reason for any database's existence. You have just viewed the data that is used to explain SQL concepts in this book. The following sections take a closer look at the elements within a table. Remember, a table is the most common and simplest form of data storage.

A Field

Every table is broken up into smaller entities called fields. The fields in the PRODUCTS_TBL table consist of PROD_ID, PROD_DESC, and COST. These fields categorize the specific information that is maintained in a given table. A field is a column in a table that is designed to maintain specific information about every record in the table.

A Record, or Row, of Data

A record, also called a row of data, is each individual entry that exists in a table. Looking at the last table, PRODUCTS_TBL, consider the following first record in that table:

11235   WITCHES COSTUME        29.99

The record is obviously composed of a product identification, product description, and unit cost. For every distinct product, there should be a corresponding record in the PRODUCTS_TBL table. A record is a horizontal entity in a table.

A row of data is an entire record in a relational database table.

A Column

A column is a vertical entity in a table that contains all information associated with a specific field in a table. For example, a column in the PRODUCTS_TBL having to do with the product description would consist of the following:

WITCHES COSTUME
PLASTIC PUMPKIN 18 INCH
FALSE PARAFFIN TEETH
LIGHTED LANTERNS
ASSORTED COSTUMES
CANDY CORN
PUMPKIN CANDY
PLASTIC SPIDERS
ASSORTED MASKS

This column is based on the field PROD_DESC, the product description. A column pulls information about a certain field from every record within a table.

The Primary Key

A primary key is a column that makes each row of data in the table unique in a relational database. The primary key in the PRODUCTS_TBL table is PROD_ID, which is typically initialized during the table creation process. The nature of the primary key is to ensure that all product identifications are unique, so that each record in the PRODUCTS_TBL table has its own PROD_ID. Primary keys alleviate the possibility of a duplicate record in a table and are used in other ways, which you read about in Hour 3.

A NULL Value

NULL is the term used to represent a missing value. A NULL value in a table is a value in a field that appears to be blank. A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation. Notice that in the EMPLOYEE_TBL table, not every employee has a middle initial. Those records for employees who do not have an entry for middle initial signify a NULL value.

Additional table elements are discussed in detail during the next two hours.

Examples and Exercises Used in This Book

As stated before, most of the examples used in this book were generated using Oracle. This was done for several reasons: consistency, the popularity of the Oracle database, and Oracle's high compliance to the ANSI SQL-99 standard.

Many exercises in this book use Oracle examples. We have also included exercises for as much of the book as possible using MySQL. We decided to use MySQL in this edition for exercises because MySQL is open source and may be freely distributed, whereas Oracle is not. MySQL is popular, easy to download, and easy to install. MySQL is available for most operating system platforms, including Windows and Linux. Note that because MySQL is not as compliant to the SQL-99 standard as Oracle, MySQL exercises may be somewhat limited in some hours of instruction. Due to MySQL's lack of compliance to several parts of the SQL standard, we have opted to keep our Oracle examples.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020