MS Access Chapter 1
Data Base Concepts Course Guide 2
Data Base Concepts Data The term data is often used to distinguish binary machine-readable information from textual human-readable information. For example, some applications make a distinction between data files (files that contain binary data) and text files (files that contain ASCII data). Data base A Database is an organized collection of data. The Data are typically organized to model relevant aspects of reality in a way that supports processes requiring this information. For example, modeling the availability of rooms in hotels in a way that supports finding a hotel with vacancies. Database Management System (DBMS) Database management systems (DBMSs) are specially designed applications that interact with the user, other applications, and the database itself to capture and analyze data. A general-purpose database management system (DBMS) is a software system designed to allow the definition, creation, querying, update, and administration of databases. Well-known DBMSs include MySQL, PostgreSQL, SQLite, Microsoft SQL Server,Oracle, SAP, dbase, FoxPro, IBM DB2, LibreOffice Base and FileMaker Pro. A database is not generally portable across different DBMS, but different DBMSs can by using standards such as SQL and ODBC or JDBC to allow a single application to work with more than one database. Formally, the term "database" refers to the data itself and supporting data structures. Databases are created to operate large quantities of information by inputting, storing, retrieving, and managing that information. Databases are set up so that one set of software programs provides all users with access to all the data. A "database management system" (DBMS) is a suite of computer software providing the interface between users and a database or databases. Because they are so closely related, the term "database" when used casually often refers to both a DBMS and the data it manipulates. Course Guide 3
Relationship A Relationship, in the context of databases, is a situation that exists between two relational database tables when one table has a foreign key that references primary key of the other table. Relationships allow relational databases to split and store data in different tables, while linking disparate data items. Normalizations Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database using the defined relationships. Database Components Fields - In computer science, data that has several parts can be divided into fields. Relational databases arrange data as sets of database records, also called rows. Each record consists of several fields; the fields of all records form the columns. Records - In the context of a relational database, a row also called a record or tuple represents a single, implicitly structured data item in a table. In simple terms, a database table can be thought of as consisting of rows and columns or fields. Each row in a table represents a set of related data, and every row in the table has the same structure. Tables - In relational databases and flat file databases, a table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows, the cell being the unit where a row and column intersect. A table has a specified number of columns, but can have any number of rows. Each row is identified by the values appearing in a particular column subset which has been identified as a unique key index. Course Guide 4
Key Fields Primary Key - In a relational database, a "Primary Key" is a key that uniquely defines the characteristics of each row (also known as record or tuple). The primary key has to consist of characteristics that cannot be duplicated by any other row. The primary key may consist of a single attribute or a multiple attributes in combination. For example, a birthday could be shared by many people and so would not be a prime candidate for the Primary Key, but a social security number or Driver's License number would be ideal since it correlates to one single data value. Another unique characteristic of a Primary Key as it pertains to a relational database, is that a Primary Key must also serve as a Foreign Key on a related table. Foreign Key - In the context of relational databases, a foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table. In other words, a foreign key is a column or a combination of columns that is used to establish and enforce a link between the data in two tables. For example, consider a database with two tables, a CUSTOMER table that includes all customer data and an ORDER table that includes all customer orders. Suppose that the business requires that each order must refer to a single customer. To reflect this in the database, the primary key (e.g., CUSTOMERID) in the CUSTOMER table is added to the ORDER table, where it is called a foreign key. Since CUSTOMERID in the ORDER table uniquely identifies a row of the CUSTOMER table, it says which customer placed the order. Course Guide 5
Rationalization and Redundancy: Grouping logically-related fields into distinct tables, determining key fields, and then relating distinct tables using common key fields is called rationalizing a database. There are two major reasons for designing a database this way: To avoid wasting storage space for redundant data To eliminate the complication of updating duplicate data copies For example, in the Customers/Orders database, we want to be able to identify the customer name, address, and phone number for each order, but we want to avoid repeating that information for each order. To do so would take up storage space needlessly and make the job of updating multiple customer addresses difficult and time-consuming. To avoid redundancy: Place all the fields related to customers (name, address, etc.) into a Customer table and create a Primary key field which uniquely identifies each customer: Customer ID. Put all the fields related to orders (date, salesperson, total, etc.) into the Orders table. Include the Primary key field (Customer ID) from the Customer table in the table for Orders. The One-to-Many relationship between Customer and Orders is defined by the common field Customer ID. In the table for Customers (the "one" table) Customer ID is a primary key, while in the Orders table (the "many" table) it is a foreign key. Course Guide 6
What is SQL? SQL Structured Query Language is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).SQL is pronounced SEQUEL. SQL was developed during the early 70 s at IBM. DML: A data manipulation language (DML) is a family of syntax elements similar to a computer programming language used for inserting, deleting and updating data in a database. Performing read-only queries of data is sometimes also considered a component of DML. A popular data manipulation language is that of Structured Query Language (SQL), which is used to retrieve and manipulate data in a relational database. Other forms of DML are those used by IMS/DLI, CODASYL databases, such as IDMS and others. Data manipulation language comprises the SQL data change statements, which modify stored data but not the schema or database objects. Manipulation of persistent database objects, e.g., tables or stored procedures, via the SQL schema statements, rather than the data stored within them, is considered to be part of a separate data definition language. In SQL these two categories are similar in their detailed syntax, data types, expressions etc., but distinct in their overall function. DDL: A data definition language or data description language (DDL) is a syntax similar to a computer programming language for defining data structures, especially database schemas. Short for Data Definition Language, DDL is a computer language that is used to define data structures. In Database Management Systems (DBMS), it is used to specify a database scheme as a set of definitions (expressed in DDL). In SQL, the Data Definition Language (DDL) allows you to create, alter, and destroy database objects. Course Guide 7
The Data Definition Language (DDL) is used to create and destroy databases and database objects. These commands will primarily be used by database administrators during the setup and removal phases of a database project. DDL: Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples: CREATE - to create objects in the database ALTER - alters the structure of the database DROP - delete objects from the database TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed COMMENT - add comments to the data dictionary RENAME - rename an object DML: Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples: SELECT - retrieve data from the a database INSERT - insert data into a table UPDATE - updates existing data within a table DELETE - deletes all records from a table, the space for the records remain MERGE - UPSERT operation (insert or update) CALL - call a PL/SQL or Java subprogram EXPLAIN PLAN - explain access path to data LOCK TABLE - control concurrency Course Guide 8