Академический Документы
Профессиональный Документы
Культура Документы
Data Redundancy
Risk to data integrity Data isolation Difficult access to data Unsatisfactory security measure Concurrent access Major Disadvantages when different departments have large data to share
Concept of a Database
A database is a collection of interrelated data from which some information can be extracted. The collection of data must be logically coherent with some inherent meaning.
A database is designed and built for specific purpose, keeping in mind the needs of the applications that are going to use it and the end users of those applications. It is managed by a software package known as a Database Management System (DBMS).
Database Models
Hierarchical
Network
Relational
Hierarchical Model
This model is like a hierarchical tree structure, used to construct a hierarchy of Records In the form of nodes and branches. The data elements present in the structure have a Parent-Child relationship. Closely related information in the parent-child structure is stored together as a logical unit. A parent unit may have many child units, but a child is restricted to have only one parent. This leads to the repetition of same child record for different parents. Each supplier occurrence includes the corresponding shipments quantity.
P02 NUT 16 Chenn P01 Screw 8 Cal
S01 S02
Ram
Shyam 20
15
Cal Chenn
Ram
Shyam 20 25
15
Cal Chenn
Shiva
Hyd
Network Model
It is like Hierarchical model but here, multiple parent-child relationships are used. Rapid and easy access to data is possible in this model to multiple access paths to the data elements.
S01
Ram
15
Cal
S02
Shyam
20
Chenn
150
200
250
100
P01
Screw
Cal
P02
NUT
16
Chenn
Relational Model
Supplier Parts
Supplier Supplier Name Status City Supplier Ram 15 Calcutta Shyam 20 Chennai Amit 25 Hyderabad
Shipment
Pcode PartName P01 Screw P02 Nut P03 Bolt P04 Nut
Qty 150 200 250 100 300
weight 8 16 20 16
Relational Model
Data is organized in terms of rows and columns in a table know as relations
All values appearing in the columns are derived from underlying domain (A set of Values)
Rows must be unique.
Properties of a Table
No duplicate row/column No significance of row/column order
Relational Operators
Restriction Projection Product Join Union Intersect Difference
Decomposition
Break a Relation into two or more Relations Ex: R(Rollno,Name,CourseNo,Grade) R1(Rollno, Name) R2(Rollno,CourseNo,Grade)
All attributes are preserved Is the information preserved
Grade A B B
A B B
Grade A B B
Relational Model
User Level External View
Conceptual View
Administrator Level
Internal View
Hardware Level
Database Design
Requirement Formulation and Analysis Collection and Documentation of Requirement Analysis of Requirement
Conceptual Design
Data Modeling
First Level
Second Level
E-R Modeling
Normalization
Database Design
Requirement Formulation and Analysis
Conceptual Design
To identify the entities and relationships that
effect the organizations data, naturally. The objective of this step is to specify the conceptual structure of the data and is often referred to as data modeling.
Data Modeling
Describes relationship between data objects First Level Entity Relationship Normalization Second Level -
Attribute
Describes an Entity
Relationship
Relation
Entity
Entity
NAME Data object in the system Uniquely identifiable by the identifier. Has attributes that describe it.
An entity is an object, place, person, concept, activity about which an enterprise records data. It is an object which can have instances or occurrences. Each instance should be capable of being uniquely identified. Each entity has certain properties, or attributes associated with it and operations applicable to it. An entity is represented by a rectangle in the E-R Model.
Physical object Abstract object Event Location Employee, Machine, Book, Client, Student, Item Account, Department Application, Reservation, Invoice, Contract Building, city, State
Attributes
Attributes are data elements that describe an entity. If the attribute of an entity has more attributes that describe it, then it is not an attribute of that entity, but another entity. Attributes can either be listed next to the entities, or placed in circles and attached to the entities.
Entity
Customer Book Order
Attributes
Name, Address, Status ISBN, Title, Author, Price Order Number, Order Date, Placed by
Relationship
Thus is an association between entities. It is represented by a diamond in the E-r diagram.
STUDENT
ENROLLS IN
COURSE
MANAGE
EMP
WORK IN
DEPT
Formally Worked In
Degree of Relationship
One to One ( 1:1) One to Many (1:N) Many to Many (M:N)
Order Requisition
RAISES
Purchase Order
1 WORKS IN
Employee
Department
ORDER
ITEM
E-R Model
An organization has employees assigned to specific departments. The employees may work on several projects at the same time. The project uses parts which are supplied by different suppliers, and stored in various warehouses.
PERSON
PARTS
SUPPLIED BY
SUPPLIER
BELONGS TO
WORKS ON
USE
STORED IN
1
DEPT
M
WAREHOUSE
PROJECT
Invoice Invoice Order Challan Cust Custmoer Item No date no no no Name No 112 12/08/97 1 1 C1 S. Srikant I1 112 12/08/97 2 1 C1 S. Srikant I2 113 16/08/97 1 1 C4 Kavita I4 114 16/08/97 1 1 C1 S. Srikant I8 114 16/08/97 2 1 C1 S. Srikant I2
Item Qty Desc. sold Rate Pepsi 2 8 Butter 1 22 Bread 1 12 Biscuit 2 22 Pepsi 4 8
Inv Value 38 38 12 54 54
status 15 20 25 15
Weight 8 16 20 8
The table presents several difficulties in operations Like : Insertion of Fields : If a new field is introduced into the system, it cannot be added to the database, until it becomes related to another existing field, for example, if a supplier name is introduced, its details cannot be entered in the table unless a part name is present for that supplier.
Updation of Fields : If the supplier code of a supplier is to be modified, it has to be changed throughout the table, in all occurrences of the supplier record. Missing out even a single correction, would result in inaccurate data.
Deletion of Fields : If information related to a specific column is to be deleted, the entire row has to be deleted, which results in loss of required information. For example, if the row of the supplier ABC is deleted, the information about the Part name lost.
Steps in Normalization
First Normal Form Identify repeating groups of fields Remove repeating groups to a separate table Identify the keys for the table Key of parent table is brought as part of the concatenated key of the second table.
Invoice Items
Invoice Item No Item No Desc 112 I1 Pepsi 112 I2 Butter 113 I4 Bread 114 I8 Biscuit 114 I2 Pepsi Qty Sold 2 1 1 2 4 Rate 8 22 12 22 8 Discount Nil Nil Nil Nil Nil
Check if all fields are dependent on the whole key Remove fields that depend on part of the key Group partially-dependent fields as a separate table Name the tables Identify key(s) to the table(s)
Invoice Items
Invoice No 112 112 113 114 114 Item No. I1 I2 I4 I8 I2 Qty Sold Discount 2 Nil 1 Nil 1 Nil 2 Nil 4 Nil
Item Table
Item No. I1 I2 I4 I8
Rate 8 22 12 22
Remove fields that Depend on other non-key attribute Can be calculated or derived from logic Group interdependent fields as separate tables, identify the key name and name of the table.
Customer Table
Invoice Items
Qty Sold 3 1 2
Item No. Item Desc. It1 Patties It2 Cake It3 Pizza
Rate 8 100 50
Client/Server
SQL
SQL
SQL
SQL
Database Server
Database
NORMAL FORMS SUMMARY 1NF A relation is in 1NF if every attribute is atomic (not a set of values)
Prime Attributes : An attribute is called a prime attribute if it is a part of the key. It is a non prime attribute if it is not part of the key
Key is Rollno,courseno
Partial dependency not in 2 NF Decompose the table (Rollno,courseno,grade) & (Courseno,coursename)
There are partial as well as transitive dependencies (hence not in 2 and 3 NF)
1
2 3
A
B C
Lect
Prof Lect
20
10 20
(Designation, Entitlement)
INSTRUCTOR-----<Teaches>------COURSE
Instructor Info, Course No Choose any Entity for augmenting Course Info
An M:N relationship when translated to a relation, will result a new relation for the relationship one for each entity and one for relationship Student Relation Register Relation Course Relation
EMPLOYEE ------Empno, ------Phone No(Multivalued Attribute) Employee Relation empno, ename, sal Phone Relation---- empno, Phone No
A Reservation is made for a passenger on a train for a particular seat/ birth against the payment of the cost of the ticket.
The cost/Fare is calculated from a databasewhich stores the cost of each class of tickets for each type of train from every location to every other location.
SEAT
- Bogie Number
Berth Number Class
<Has> <Reservation>
SEAT
PASSENGER
Rule 1. The Information Representation Rule All information in a relational database is represented explicitly and logically represented by the data values in the tables
A description of the database is stored and maintained in the form of tables as is done while defining the data. The database description is represented at the logical level just like ordinary data, so that authorized users can apply to regular data.
Rule 5. Comprehensive Data Sublanguage rule The RDBMS must be completely manageable through its own extension of SQL . The SQL should support DDL, Views, DML, Integrity Constraints, Authorization and transaction boundaries.
The DBMS must have a data sublanguage that enables application programs and terminal activities to remain logically unimpaired when data distribution is first introduced and when data is re-distributed.
Rule 12. Non-Subversion Rule If a relational system has a low-level (single-record-at-a-time) language, that low level can not be used to subvert or by pass the integrity rules and constraints expressed in the high-level relational language (multiple-records-at-a-time).
AN RDBMS product has to satisfy at least 6 rules of Codd to be accepted as a full fledged RDBMS