Вы находитесь на странице: 1из 30

J k

A s

Computers In Management
J k

A s

What is a Database? A structured


collection of Records and Data

How is the structure achieved? The


structure is achieved by organizing the
data according to a database model.
J k

A s

What is a Database Model? A model that can be used to refer


to the graphical depiction of a database structure.
J k
Database Model A s

• A database model is a theory or specification


describing how a database is structured and
used
• A data model is not just a way of structuring
data, it also defines a set of operations that can
be performed on the data.
• Common models include:
– Flat Model
– Hierarchical model
– Network model
– Relational model
J k
Flat Model A s

• Also called Table Model


• Consists of a single, two-dimensional array of data elements, where
all members of a given column are assumed to be similar values,
and all members of a row are assumed to be related to one another.

S.NO Name Password

1 ABC ****

2 DEF ****

3 GHI ****

4 JKL ****
J k
Hierarchical model A s

• Data is organized into a tree-like structure.


• It has a single upward link in each record to describe the nesting,
and a sort field to keep the records in a particular order in each
same-level list
Network model J k

A s

• It organizes data using two fundamental constructs, called records


and sets.
• Records contain fields whereas sets define one-to-many
relationships between records
Hierarchical model Vs. Network model J k

A s

• In the Network Model


branches can be connected to
multiple nodes.

• Network model is able to


represent redundancy in data
more efficiently than in the
hierarchical model.
Relational Model J k

A s
• A relational database is a single database spread across multiple tables.
• Three key terms are used extensively in relational database models:
relations, attributes, and domains. A relation is a table with columns
and rows. The named columns of the relation are called attributes, and
the domain is the set of values the attributes are allowed to take.
Relational Model (Continued) J k

• All of the employee information is kept in the first A s

drawer; all of the vendor information is kept in the


second drawer; and all of the purchase orders are
kept in the third drawer. To connect each of these
drawers a set piece of data from one drawer has to
be present in one of the other drawers.
• A purchase order will have a vendor name, address,
and phone number on it, along with the items
purchased, purchase price, and any discounts.
• If the vendor name is the "set" piece of data, it is
entered in the purchase order table, but the
address & phone number are retrieved from the
vendor table instead of having to re-type that
information each time it is needed in the purchase
order table.
Relational Database - Normalization J k

• Normalization is a systematic way of A s

ensuring that a database structure is


suitable for general-purpose
querying and free of certain
undesirable characteristics.
– Insertion Anomaly
– Update Anomaly
– Deletion Anomalies

• The anomalies could lead to a loss


of data integrity.
Insertion Anomaly J k

• There are circumstances in which certain facts cannot be recorded at all.


A s

• For example, each record in a "Faculty and Their Courses" table might contain
a Faculty ID, Faculty Name, Faculty Hire Date, and Course Code—thus we can
record the details of any faculty member who teaches at least one course, but
we cannot record the details of a newly-hired faculty member who has not yet
been assigned to teach any courses.
Update Anomaly J k

• The same information can be expressed on multiple rows; therefore updates


A s

to the table may result in logical inconsistencies.


• For example, each record in an "Employees' Skills" table might contain an
Employee ID, Employee Address, and Skill; thus a change of address for a
particular employee will potentially need to be applied to multiple records
(one for each of his skills). If the update is not carried through successfully—if,
that is, the employee's address is updated on some records but not others—
then the table is left in an inconsistent state.
Deletion Anomaly J k

• There are circumstances in which the deletion of data representing certain A s


facts necessitates the deletion of data representing completely different facts.
• The "Faculty and Their Courses" table described in the previous example
suffers from this type of anomaly, for if a faculty member temporarily ceases
to be assigned to any courses, we must delete the last of the records on which
that faculty member appears.
Database Management System (DBMS) J k

A s

A database management system


(DBMS) is computer software that
manages databases. DBMSes may use
any of a variety of database models,
such as the network model or
relational model. In large systems, a
DBMS allows users and other software
to store and retrieve data in a
structured way.
J k

Normalisation A s

 In the field of relational database design, normalization is a systematic way


of ensuring that a database structure is suitable for general-purpose
querying and free of certain undesirable characteristics—insertion, update,
and deletion anomalies—that could lead to a loss of data integrity.
 E.F. Codd, the inventor of the relational model, introduced the concept of
normalization and what we now know as the first normal form in 1970.
Codd went on to define the second and third normal forms in 1971 and
Codd and Raymond F. Boyce defined the Boyce-Codd normal form in 1974
.
 Informally, a relational database table is often described as "normalized" if
it is in the third normal form (3NF). Most 3NF tables are free of insertion,
update, and deletion anomalies.

Copyright © 2009 JkAs Management Consulting Group


J k

First Normal Form A s

 A relation is in first normal form if all its attributes are simple. In other
words, none of the attributes of the relation is a relation.
 Student-courses (Sid:pk, Sname, Phone, Courses-taken) Where attribute
Sid is the primary key, Sname is student name, Phone is student's phone
number and Courses-taken is a table contains course-id, course-
description, credit hours and grade for each course taken by the student.
More precise definition of table Course-taken is :Course-taken (Course-
id:pk, Course-description, Credit-hours, Grade)

Copyright © 2009 JkAs Management Consulting Group


Student-courses
J k
Sid
100
Sname
John
Phone
487 2454
Courses-taken
St-100-courses-taken
A s

200 Smith 671 8120 St-200-courses-taken


300 Russell 871 2356 St-300-courses-taken

St-100-Course-taken

Course-id Course-description Credit-hours Grade


IS380 Database Concepts 3 A
IS416 Unix Operating 3 B
System

St-200-Course-taken
Course-id Course-description Credit-hours Grade
IS380 Database Concepts 3 B
IS416 Unix Operating 3 B
System
IS420 Data Net Work 3 C

St-300-Course-taken
Course-id Course-description Credit-hours Grade
IS417 System Analysis 3 A

Copyright © 2009 JkAs Management Consulting Group


J k

 Insertion anomaly means that that some data can not be inserted in the
database. For example we can not add a new course to the database of
A s

example-1,unless we insert a student who has taken that course.


 Update anomaly means we have data redundancy in the database and to
make any modification we have to change all copies of the redundant data
or else the database will contain incorrect data. For example in our
database we have the Course description "Database Concepts" for IS380
appears in both St-100-Course-taken and St-200-Course-taken tables. To
change its description to "New Database Concepts" we have to change it
in all places. Indeed one of the purposes of normalization is to eliminate
data redundancy in the database.
 Deletion anomaly means deleting some data cause other information to be
lost. For example if student Russell is deleted from St-100-Course-taken
table we also lose the information that we had a course call IS417 with
description System Analysis.

Thus Student-courses table suffers from


all the three anomalies.

Copyright © 2009 JkAs Management Consulting Group


J k

 To convert the above structure to first normal form relations, all non-simple
attributes must be removed or converted to simple attribute.
A s

 To do that a new relation is created by combining each row of Student-


courses with all rows of its corresponding course table that was taken by
that specific student.
 Student-courses ( Sid:pk1, Sname, Phone, Course-id:pk2, Course-
description, Credit-hours, Grade)
 Notice that the primary key of this table is a composite key made up of two
parts; Sid and Course-id. Note that pk1 following an attribute indicates that
the attribute is the first part of the primary key and pk2 indicates that the
attribute is the second part of the primary key.

Copyright © 2009 JkAs Management Consulting Group


J k

A s

Sid Sname Phone Cours Course- Credi Grade


e-id descripti t-
on hour
s
100 John 487 2454 IS380 Database Concepts 3 A
100 John 487 2454 IS416 Unix Operating System 3 B
200 Smith 671 8120 IS380 Database Concepts 3 B
200 Smith 671 8120 IS416 Unix Operating System 3 B
200 Smith 671 8120 IS420 Data Net Work 3 C
300 Russell 871 2356 IS417 System Analysis 3 A

Copyright © 2009 JkAs Management Consulting Group


J k

 Examination of the above Student-courses relation reveals that Sid does


not uniquely identify a row (tuple) in the relation hence cannot be the
A s

primary key. For the same reason Course-id cannot be the primary key.
However the combination of Sid and Course-id uniquely identifies a row in
Student-courses, Therefore (Sid, Course-id) is the primary key of the
above relation.
 The primary key determines every attribute. For example if you know both
Sid and Course-id for any student you will be able to retrieve Sname,
Phone, Course-description, Credit-hours and Grade, because these
attributes are dependent on the primary key.

Copyright © 2009 JkAs Management Consulting Group


J k

A s

Copyright © 2009 JkAs Management Consulting Group


J k

Was the solution – The Best A s

 Insertion anomaly: We cannot add a new course such as IS247 with


course description programming techniques to the database unless we
add a student who to take the course.
 Update anomaly: If we change the course description for IS380 from
Database Concepts to New_Database_Concepts we have to make
changes in more than one place or else the database will be inconsistent.
In other words in some places the course description will be
New_Database_Concepts and in any place were we forgot to make the
changes the description still will be Database_Concepts.
 Deletion anomaly: If student Russell is deleted from the database we also
loose information that we had on course IS417 with description
System_Analysis.

Copyright © 2009 JkAs Management Consulting Group


J k

Second Normal Form A s

 A first normal form relation is in second normal form if all its non-primary
attributes are fully functionally dependent on the primary key.
 To convert Student-courses to second normal relations we have to make
all non-primary attributes to be fully functionally dependent on the primary
key.
 To do that we need to project (that is we break it down to two or more
relations) Student-courses table into two or more tables.
 To avoid such problems it is important to keep attributes, which are
dependent on each other in the same table, when a relation is projected to
smaller relations.

Copyright © 2009 JkAs Management Consulting Group


J k
Sid
100
Sname
John
Phone
487 2454
A s

200 Smith 671 8120

300 Russell 871 2356

Course-id Course- Credit-hours


description
IS380 Database Concepts 3
IS416 Unix Operating System 3
IS420 Data Net Work 3
IS417 System Analysis 3

Sid Course-id Grade


100 IS380 A
100 IS416 B
200 IS380 B
200 IS416 B
200 IS420 C
300 IS417 A

Copyright © 2009 JkAs Management Consulting Group


J k
 All these three relations are in second normal form. Examination of these
relations shows that we have eliminated the redundancy in the database.
A s

Now relation Student contains information only related to the entity


student, relation Courses contains information related to entity Courses
only, and the relation Student-grade contains information related to the
relationship between these two entity.
 Insertion anomaly: Now a new Course with course-id IS247 and Course-
description can be inserted to the table Course. Equally we can add any
new students to the database by adding their id, name and phone to
Student table. Therefore our database, which made up of these three
tables does not suffer from insertion anomaly.
 Update anomaly: Since redundancy of the data was eliminated no update
anomaly can occur. To change the course-description for IS380 only one
change is needed in table Courses.
 Deletion anomaly: the deletion of student Russell from the database is
achieved by deleting Russell's records from both Student and Student-
grade relations and this does not have any side effect because the course
IS417 untouched in the table Courses.

Copyright © 2009 JkAs Management Consulting Group


J k

A s

Winner Date of
Tournament Year Winner
Birth
Indiana Invitational 1998 Al Fredrickson 21 July 1975
Cleveland Open 1999 Bob Albertson 28 September 1968
Des Moines 1999 Al Fredrickson 21 July 1975
Masters
Indiana Invitational 1999 Chip Masterson 14 March 1977

Copyright © 2009 JkAs Management Consulting Group


J k

Tournament Year Winner A s


Indiana Invitational 1998 Al Fredrickson
Cleveland Open 1999 Bob Albertson
Des Moines Masters 1999 Al Fredrickson
Indiana Invitational 1999 Chip Masterson

Player Date of Birth


Chip Masterson 14 March 1977
Al Fredrickson 21 July 1975
Bob Albertson 28 September 1968

Copyright © 2009 JkAs Management Consulting Group


J k

Third Normal Form A s

 A table whose non-primary key fields are dependent only on the primary
key and therefore have no dependence (relationship to) any other non-
primary key field in the table is consider in third normal form (3NF). And,
additionally the table must first be in 2nd normal form.

Copyright © 2009 JkAs Management Consulting Group

Вам также может понравиться