You are on page 1of 38

DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS

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.

DATABASE MANAGEMENT SYSTEMS

A DBMS is a collection of programs which enables user to create and manage databases

control access to data


facilitates the processes of defining, constructing, manipulating, and sharing databases amongst various users and applications

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.

Student Name Student_name Semester Branch

Course Course_name Course_Number Credit_hours Branch

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.

Relational Database Definitions


Entity: Object, Concept or event (subject) Attribute: a Characteristic of an entity Row or Record: the specific characteristics of one entity Table: a collection of records Database: a collection of tables

The Relational Database model


Developed by E.F. Codd, C.J. Date (70s) Table = Entity = Relation Table row = tuple = instance Table column = attribute Table linkage by values Entity-Relationship Model

The Relational Model


Each attribute has a unique name within an entity All entries in the column are examples of it Each row is unique Ordering of rows and columns is unimportant Each position (tuple) is limited to a single entry.

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

Database Table Keys


Definition:
A key of a relation is a subset of attributes with the following attributes: Unique identification Non-redundancy

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.

Relational Database Management System (RDBMS)


Table A Name Address Parcel #

John Smith 18 Lawyers Dr. 756554 T. Brown 14 Summers Tr. 887419

Table B Parcel # Assessed Value 887419 152,000 446397 100,000

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.

Constructing Join Relationships


One-to-many relationships include the Primary Key of the one table and a Foreign Key (FK) in the many table.

Other common terms


Cardinality: one-to-one, one-to-many, manyto-many relationships Optionality: the relationship is either mandatory or optional.

Ensuring Database Integrity


Database integrity involves the maintenance of the logical and business rules of the database. There are two kinds of DB Integrity that must be addressed:
Entity Integrity Referential Integrity

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

Database Tables and Normalization


Normalization is a process for assigning attributes to entities. It reduces data redundancies and helps eliminate the data anomalies. Normalization works through a series of stages called normal forms: First normal form (1NF) Second normal form (2NF) Third normal form (3NF) Fourth normal form (4NF) The highest level of normalization is not always desirable.

First Normal Form (1 NF)


1NF Definition The term first normal form (1NF) describes the tabular format in which: All the key attributes are defined. There are no repeating groups in the table. All attributes are dependent on the primary key.

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.

Second Normal Form (2 NF)


Conversion to Second Normal Form Starting with the 1NF format, the database can be converted into the 2NF format by Writing each key component on a separate line, and then writing the original key on the last line and Writing the dependent attributes after each new key.

PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR) ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

Dependency Diagram

Second Normal Form (2 NF)


A table is in 2NF if:

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.)

Third Normal Form (3 NF)


Conversion to Third Normal Form
Create a separate table with attributes in a transitive functional dependence relationship.

PROJECT (PROJ_NUM, PROJ_NAME) ASSIGN (PROJ_NUM, EMP_NUM, HOURS) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS) JOB (JOB_CLASS, CHG_HOUR)

Third Normal Form (3 NF)

3NF Definition
A table is in 3NF if: It is in 2NF and It contains no transitive dependencies.

Boyce-Codd Normal Form (BCNF)


A table is in Boyce-Codd normal form (BCNF) if every determinant in the table is a candidate key.

(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.

The Decomposition of a Table Structure to Meet BCNF Requirements

You might also like