The Database
The Database
The last component in Figure 1-7 is the database. A database is a self-describing collec- tion of integrated tables. Integrated tables are tables that store both data and the relation- ships among the data. The tables in Figure 1-3 are integrated because they store not just student, class, and grade data, but also data about the relationships among the rows of data.
A database is self-describing because it contains a description of itself. Thus, databases contain not only tables of user data, but also tables of data that describe that user data. Such descriptive data is called metadata because it is data about data. The form and format of metadata varies from DBMS to DBMS. Figure 1-13 shows generic metadata tables that describe the tables and columns for the database in Figure 1-3.
You can examine metadata to determine if particular tables, columns, indexes, or other structures exist in a database. For example, the following statement queries the Microsoft
USER_TABLES Table
Figure 1-13
Typical Metadata Tables
3 (StudentNumber, ClassNumber)
USER_COLUMNS Table
Length (bytes)
FirstName Text STUDENT 25 EmailAddress
STUDENT
Text
ClassNumber
CLASS
Integer
Name
CLASS
Text
Term
CLASS
Text
Section
CLASS
Integer
StudentNumber
GRADE
Integer
ClassNumber
GRADE
Integer
Grade
GRADE
Decimal
Chapter 1 Introduction
Figure 1-14
Database Contents
• Tables of user data • Metadata
Discussed in
• Indexes
Chapters 7, 10, 10A, 10B
• Stored procedures • Triggers • Security data • Backup/recovery data
Discussed in Chapters 9, 10, 10A, 10B
SQL Server metadata table SYSOBJECTS to determine if a user table (Type = ‘U’) named CLASS exists in the database. If it does, the table is dropped (removed) from the database.
IF EXISTS
[Name]='CLASS'
AND
Type='U')
DROP TABLE CLASS;
Do not be concerned with the syntax of this statement. You will learn what it means and how to write such statements yourself as we proceed. For now, just understand that this is one way that database administrators use metadata.
Because metadata is stored in tables, you can use SQL to query it, as just illustrated. Thus, by learning how to write SQL to query user tables, you will
also learn how to write SQL to query metadata. To do that, you just apply the SQL state- ments to metadata tables rather than user tables.
In addition to user tables and metadata, databases contain other elements, as shown in Figure 1-14. These other components will be described in detail in subsequent chapters. For now, however, understand that indexes are structures that speed the sorting and searching of database data. Triggers and stored procedures are programs that are stored within the database. Triggers are used to maintain database accuracy and consistency and to enforce data constraints. Stored procedures are used for database administration tasks and are sometimes part of database appli- cations. You will learn more about these different elements in Chapters 7, 10, 10A, and 10B.
Security data define users, groups, and allowed permissions for users and groups. The par- ticulars depend on the DBMS product in use. Finally, backup and recovery data are used to save database data to backup devices as well as to recover the database data when needed. You will learn more about security and backup and recovery data in Chapters 9, 10, 10A, and 10B.
Personal Versus Enterprise-Class Database Systems
We can divide database systems and DBMS products into two classes: personal database sys- tems and enterprise-class database systems.
Parts
» This page intentionally left blank
» Reporting and Data Mining Database Applications
» Database Applications and SQL
» Reading Specified Columns and Rows from a Single Table
» “Does Not Work with Microsoft Access ANSI-89 SQL”
» Processing SQL Statements in Microsoft Access 2010
» Using SQL in Microsoft SQL Server 2008 R2
» Using SQL in Oracle Database 11g
» Using SQL in Oracle MySQL 5.5
» Wildcards in SQL WHERE Clauses
» Using SQL Built-in Functions
» SQL Expressions in SQL SELECT Statements
» Querying Multiple Tables with Subqueries
» Querying Multiple Tables with Joins
» Comparing Subqueries and Joins
» Finding Functional Dependencies
» Eliminating Anomalies from Multivalued Dependencies
» The Multivalue, Multicolumn Problem
» The General-Purpose Remarks Column
» R Diagrams Using the IE Crow’s Foot Model
» The Multivalued Attribute Pattern
» The Archetype/Instance Pattern
» The Student Acceptance Letter
» X This is a warning, no further action is required.
» 1:1 Relationships Between Strong Entities
» M Relationships Between Strong Entities
» Relationships in Mixed Entity Designs
» Representing Ternary and Higher-Order Relationships
» Relational Representation of the Highline University Data Model
» Surrogate Key Database Design
» Column Properties for the View Ridge Database Design Tables
» Variations in SQL Data Types
» Implementing Data Constraints
» Populating the View Ridge Database Tables
» Using Triggers to Provide Default Values
» The WORK_AddWorkTransaction Stored Procedure
» • If a PROJECT row is deleted, then the project has been canceled, and it is unneces-
» Reducing Cardinalities (with Data Loss)
» Optimistic Versus Pessimistic Locking
» Declaring Lock Characteristics
» Processing Rights and Responsibilities
» Recovery via Rollback/Rollforward
» Maintaining the Data Repository
» Types of Distributed Databases
» • Express Edition. This free, feature-limited version is available for download. It
» SQL Server 2008 R2 SQL Statements and SQL Scripts
» Creating the View Ridge Database Table Structure
» Populating the VRG Tables with Data
» The Stored Procedure InsertCustomerAndInterests
» The Stored Procedure InsertCustomerWithTransaction
» A Trigger for Setting Default Values
» A Trigger for Enforcing a Data Constraint
» A Trigger for Enforcing a Required Child Constraint
» Creating an ODBC Data Source Name
» Materializing XML Documents with XSLT
» Using the SQL SELECT . . . FOR XML Statement
» Multitable SELECT with FOR XML
» A Schema with Two Multivalued Paths
» Problems with Operational Data
» Using SQL for Market Basket Analysis
Show more