Database Management Systems
Database Management Systems
1. What is a database? A database is a collection of related data which can be used: alone, or combined / related to other data to provide answers to the users question.
A database represents some aspects of the real world, sometimes called the miniworld or the universe of discourse(UoD). A database is a logically coherent collection of data with some inherent meaning. A random assortment of data cannot correctly be referred to as a database. A database is designed, built, and populated with data for a specific purpose. It has an intended group of users and some preconceived applications in which these users are interested.
A DBMS is a collection of programs which enables user to create and manage databases
Schema
Definition The description of a database is called the database schema, which is specified during database design and is not expected to change frequently.
Three-Schema Architecture
The goal of this architecture is to separate the user applications and the physical database. The three levels are Internal level Conceptual level External or view level
DBMS Languages
Data Definition Language(DDL) Storage Definition Language(SDL) View Definition Language(VDL) Data Manipulation Language(DML)
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 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.
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
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.
Entity-Relation Model
The ER model describes data as entities, relationships, and attributes. Entities: The basic object that the ER model represents is an entity, which is a thing in the real world with an independent existence. Eg: a person, car, employee, company etc. Attributes: Each entity has attributes-the particular properties that describe it. For eg, an Employee entity may be described by the Employees name, age, salary, address etc.
Types of attributes
Composite Attributes Simple Attributes Single-Valued Attributes Multiple Attributes Stored Attributes Derived Attributes
Dependency Diagram
Dependency Diagram The primary key components are bold, underlined, and shaded in a different color. The arrows above entities indicate all desirable dependencies, i.e., dependencies that are based on PK. The arrows below the dependency diagram indicate less desirable dependencies -- partial dependencies and transitive dependencies.
PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR) ASSIGN (PROJ_NUM, EMP_NUM, HOURS)
Dependency Diagram
It is in 1NF and It includes no partial dependencies; that is, no attribute is dependent on only a portion of the primary key. (It is still possible for a table in 2NF to exhibit transitive dependency; that is, one or more attributes may be functionally dependent on nonkey attributes.)
PROJECT (PROJ_NUM, PROJ_NAME) ASSIGN (PROJ_NUM, EMP_NUM, HOURS) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS) JOB (JOB_CLASS, CHG_HOUR)
3NF Definition
A table is in 3NF if: It is in 2NF and It contains no transitive dependencies.
(A determinant is any attribute whose value determines other values with a row.)
If a table contains only one candidate key, the 3NF and the BCNF are equivalent. BCNF is a special case of 3NF.