Databases Review Intro
Databases Review Intro
Relational Database
Definition:
Data stored in tables that are associated by shared attributes (keys). Any data element (or entity) can be found in the database through the name of the table, the attribute name, and the value of the primary key.
Database Tables
Tables represent entities Tables are always named in the singular, such as: Vehicle, Order, Grade, etc. Tables in database jargon are flat files, dBase or Spreadsheet like..
Attributes
Characteristics of an entity Examples:
Vehicle (VIN, color, make, model, mileage) Student (SSN, Fname, Lname, Address) Fishing License (Type, Start_date, End_date)
Database Views
A View is an individuals picture of a database. It can be composed of many tables, unbeknownst to the user.
Its a simplification of a complex data model It provides a measure of database security Views are useful, primarily for READ-only users and are not always safe for CREATE, UPDATE, and DELETE.
Table Indexing
An Index is a means of expediting the retrieval of data. Indexes are built on a column(s). Indexes occupy disk space; occasionally a lot. Indexes arent technically necessary for operation and must be maintained by the database administrator.
19
44
59
Database Relationships
How is one entity related to another entity? Real-world sources:
Ownership Parentage Assignment Regulation
Types of Keys
PRIMARY KEY
Serves as the row level addressing mechanism in the relational database model. It can be formed through the combination of several items.
FOREIGN KEY
A column or set of columns within a table that are required to match those of a primary key of a second table.
These keys are used to form a RELATIONAL JOIN thereby connecting row to row across the individual tables.
756554 887419
Database Keys
Primary Key - Indicates uniqueness within records or rows in a table. Foreign Key - the primary key from another table, this is the only way join relationships can be established. There may also be alternate or secondary keys within a table.
Entity Integrity
Entity integrity deals with within-entity rules. These rules deal with ranges and the permission of null values in attributes or possibly between records
Enforcing Integrity
Not a trivial task! Not all database management systems or GIS software enable users to enforce data integrity during attribute entry or edit sessions. Therefore, the programmer or the Database Administrator must enforce and/or check for Integrity.
Referential Integrity
Referential integrity concerns two or more tables that are related. Example: IF table A contains a foreign key that matches the primary key of table B THEN values of this foreign key either match the value of the primary key for a row in table B or must be null.
Four basic functions, for a given entity they should all be performed with few exceptions, in your system:
CREATE READ UPDATE DELETE
SQL Examples
CREATE TABLE SALESREP
Item definition expression(s)
{item, type, (width)}
DELETE table
WHERE expression
Data Retrieval
SELECT list FROM table WHERE condition list - a list of items or * for all items
WHERE - a logical expression limiting the number of records selected can be combined with Boolean logic: AND, OR, NOT ORDER may be used to format results
UPDATE tables
SET item = expression WHERE expression INSERT INTO table VALUES ..
Database Normalization
Normalization: The process of structuring data to minimize duplication and inconsistencies.
The process usually involves breaking down a single Table into two or more tables and defining relationships between those tables. Normalization is usually done in stages, with each stage applying more rigorous rules to the types of information which can be stored in a table.
Normalization
Normalization: a process for analyzing the design of a relational database
Database Design - Arrangement of attributes into entities
It permits the identification of potential problems in your database design Concepts related to Normalization:
KEYS and FUNCTIONAL DEPENDENCE
Problem: If student #219 transfers we lose all references to Golf and its price.