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

Unit-1

UNIT 1 DBMS ===========================================================

Characteristic of relational data base system


There are a number of characteristics that distinguish the database approach with the file-based approach. In this section, we describe in detail some of those important characteristics. Self-Describing Nature of a Database System : Database System contains not only the database itself but also the descriptions of data structure and constraints (meta-data). These information is used by the DBMS software or database users if needed. This seperation makes database system totally different from traditional file-based sytem in which data definition is a part of application programs Insulation between Program and Data : In the filed base sytem, the structure of the data files is defined in the application programs so if user want to change the structure of a file, all the programs access to that files might need to be changed. On the other hand, in database approach, data structure is stored in the system catalog not in the programs so such changes might not occurs. Support multiple views of data: A view is a subset of the database which is defined and dedicated for particular users of the system. Multiple users in the system might have different views of the system. Each view might contains only the interested data of an user or a group of user. Sharing of data and Multiuser system: A multiuser database system must allow multiple users access the database at the same time. As the result, the multiuser DBMS must have concurrency control strategies to ensure that several user try to access the same data item at a time do so in the manner so that the data always be correct.

Data Models:
Data modeling is a method used to define and analyze data requirements needed to support the business processes of an organization and by defining the data structures and the relationships between data elements. In other words, A data model is a collection of concepts and rules for the description of the structure of the database. Structure of the database means the data types, the constraints and the relationships for the description or storage of data respectively.
Data modeling techniques are used : to manage data as a resource ( migrate, merge, data quality) for designing computer databases. to better cope with change, by allowing to make changes into the model, that will automatically induce changes in the database and programs. There are five models of DBMS, which are distinguished based on how they represent the data contained:

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
The hierarchical model : The data is sorted hierarchically, using a downward tree. This model uses pointers to navigate between stored data. It was the first DBMS model.

The network model : like the hierarchical model, this model uses pointers toward stored data. However, it does not necessarily use a downward tree structure.

The relational model (RDBMS , Relational database management system): The data is stored in two-dimensional tables (rows and columns). The data is manipulated based on the relational theory of mathematics. (This model will be studied in detail.)

The deductive model : Data is represented as a table, but is manipulated using predicate calculus. The object model (ODBMS , object-oriented database management system): the data is stored in the form of objects, which are structures called classes that display the data within. The fields are instances of these classes

By the late 1990s, relational databases were the most commonly used (comprising about threequarters of all databases).

DBMS Architecture and Data Independence


Database management systems are complex software which were often developed and optimized over years. From the view of the user, however, most of them have a quite similar basic architecture. The discussion of this basic architecture shall help to understand the connection with data modeling and the introductionally to this module postulated 'data independence' of the database approach.

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
Three-Schemes Architecture: In 3-Layered architecture there are three levels. The three levels of the architecture are three different views of the data:

1. External - individual user view 2. Conceptual or logical - community user view 3. Internal - physical or storage view

Three-Schemes Architecture

1. External Level : The external level is the view that the individual user of the database
has. This view is often a restricted view of the database and the same database may provide a number of different views for different classes of users. In general, the end users and even the applications programmers are only interested in a subset of the database. For example, a department head may only be interested in the departmental finances and student enrolments but not the library information. The librarian would not be expected to have any interest in the information about academic staff. The payroll office would have no interest in student enrolments. Conceptual Level : The conceptual view is the information model of the enterprise and contains the view of the whole enterprise without any concern for the physical implementation. This view is normally more stable than the other two views. In a database, it may be desirable to change the internal view to improve performance while there has been no change in the conceptual view of the database. The conceptual view is the overall community view of the database and it includes all the information that is going to be represented in the database. The conceptual view is defined by the conceptual schema which includes definitions of each of the various types of data. Internal Level : The internal view is the view about the actual physical storage of data. It tells us what data is stored in the database and how. At least the following aspects are considered at this level:

2.

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
a. Storage allocation e.g. B-trees, hashing etc. b. Access paths e.g. specification of primary and secondary keys, indexes and pointers and sequencing. c. Miscellaneous e.g. data compression and encryption techniques, optimization of the internal structures.

Data Independence
With knowledge about the three-schemes architecture the term data independence can be explained as followed: Each higher level of the data architecture is immune to changes of the next lower level of the architecture. Physical Independence: Therefore, the logical scheme may stay unchanged even though the storage space or type of some data is changed for reasons of optimization or reorganization. Logical Independence: Also the external scheme may stay unchanged for most changes of the logical scheme. This is especially desirable as in this case the application software does not need to be modified or newly translated.

Relational Model:
A relational model database is defined as a database that allows you to group its data items into one or more independent tables that can be related to one another by using fields common to each related table. Basic Terminologies: 1. Relations or Tables:

A relation is usually described as a table, which is organized into rows and columns.The
table below summarizes some of the most important relational database terms and their SQL database equivalents.

Ea p x m le
Nm ae Pa a rsd G ua ar v A s aia ywr Rg o eN 1 I9 C 05 B 9 S4 1 I9 C 02 B 8 S1 1 I9 C 04 B 7 S4 Ad dr 4 6 K r mn a 5, oa a g la 2 J. . R a , C od 1 ,K .L y u 2 .S a o t P oe hn 5 62 4 573 6 21 9 630 6 64 6 695 D it Bh r 2 a -6 3-Mr 7 1 e -6 0-Dc 6 0 u -6 4-A g 5 GA P 8 .9 4 .5 9 .0

BNm rae V Pr m V ua JC od Ra Jaa aa yngr M Ra G od Gnh aa adi gr n

BC y ri t Bna r agl e o M oe y r s Bna r agl e o Bl am e u g Bl am e u g

As t se s 1046 0357 2916 305 6850 746 1456 2456 6888 7888

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1

Relational term relation, base relvar derived relvar tuple attribute

SQL equivalent table view, query result, result set row column

2. Tuples: Each row of data is a tuple. 3. Cardinality: It is defined as the number of tuples in a relation. For example if there is 4 rows in a table, cardinality of this table entity is 4. 4. Degree of a relation: Each column in the tuple is called as an attribute. The number of attributes in a relation is defined as its degree. For example. If there is four columns(attributes) in a table, its degree will be four. Entity : Entity is a person, place, object, event or concept in the user environment about which the organization wishes to maintain data. This is represented by a rectangle in E-R diagrams. Entity Types: A collection of entities that share common properties or characteristics.

Regular Vs. Weak entity type Regular Entity: Entity that has its own key attribute (s). e.g.: Employee, student ,customer, policy holder etc.
Weak entity: Entity that depends on other entity for its existence and doesnt have key attribute (s) of its own. e.g. : spouse of employee.

Difference between Entity Type & Entity Instance: It might help to think of an entity as a thing. So you are asking about a type of thing, and an actual instance of that thing. For example, one type of thing is a Person. Anil P is an instance of a Person. A Fruit is a type of thing, and an Apple is an instance of a Fruit. Make sense?
In a database world you might name a table after the type of an entity, like a Car. However, each record in the table is an instance of a Car, like Ford Mustang. Attribute A named property or characteristic of an entity that is of interest to an organization. Attributes Types : 1. Key attribute: The attribute (or combination of attributes) that is unique for every entity instance E.g.: the account number of an account, the employee id of an employee etc. * If the key consists of two or more attributes in combination, it is called a composite key

2. composite attribute vs Single Attributes Simple attribute: cannot be divided into simpler components E.g.: age of an employee

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
Composite attribute: can be split into components E.g.: Date of joining of the employee can be split into day, month and year.

C posite Vs. Sim om ple Attributes


Com posite attributes can be divided into sm aller p arts w hich represent sim ple attrib utes w independent m ith eaning Sim ple A ttribute: Aircraft -Type Com plex Attrib ute: A ircraft -Location w hich is com prised of : Aircraft -Latitude N otation Aircraft -Longitud e Aircraft -Altitude

There is no form concept of com al posite attribute in the relational m odel

3. Single Vs Multi-valued Attributes Single valued : can take on only a single value for each entity instance e.g.: age of employee. There can be only one value for this.
Multi-valued: can take up many values. e.g.: skill set of employee

Single Vs.

Multivalued

Attributes
-valued

Simple attributes can either be single or multi -valued Single -valued: Gender = F Notation Multivalued Notation : Degree = {

BSc , MInfTech }

An attribute in the relational model is always single valued - Values are atomic!

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1

4.Derived attribute vs Stored Attributes Stored Attribute: Attribute that need to be stored permanently. e.g.: name of an employee
Derived Attribute: Attribute that can be calculated based on other attributes. e.g. : years of service of employee can be calculated from date of joining and current date

Derived Vs. Stored Attributes


Som attribute values can be derived from e related attribute values: Notation Age Date - B-day Y-Sal 12 * M -Sal
Age B-days EMPLO YEE M-sal Y-sal

5. Null Values Attributes

N ll V lu d A u a e ttrib te u s
A p rtic la e tity m y n t h v a a p a le a u r n a o a e n p lic b v lu fo a a a e r n ttrib te u T rtia e ry -D g e N t a p a le fo a e re : o p lic b r p rs n w n u iv rs e u a n e o ith o n e ity d c tio H m -P o e N t k o n if it e is o e hn: o nw x ts H ig t: N t k o n a p se t tim e h o n w t re n e T p o N ll V lu s y e f u a e N t A p a le o p lic b Uk o n nnw M s g is in

Domain : The set of possible values for an attribute is called the domain of the attribute Example: 1. The domain of attribute marital status is having four values: single, married, divorced or

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
widowed. 2. The domain of the attribute month is having twelve values ranging from January to December.

Relationships: A relationship type between two entity types defines the set of all associations between these entity types Relationship instance: Each instance of the relationship between members of these entity types is called a relationship instance. e.g if Works-for is the relationship between the Employee entity and the TTI_Department entity, then Rohan works-for CSE_department, Riya works for CS department ..etc are relationship instances of the relationship, works-for.

Degree of a Relationship The number of entity types involved in a relationship is called degree of a relationship. If One entity type is involved in a relationship, it is called Unary. If two entity type is involved in a relationship, it is called Binary. If Three entity type is involved in a relationship, it is called Ternary.
e.g: employee manager-of employee is unary. employee works-for department is binary. customer purchase item, shop keeper is a ternary relationship.

R elationship D egree
The deg ree of a relationship type is the n be of pa um r rticipating e ntity types
2 entities: Binary Relationship 3 entities: Ternary Relationship n entities: N -ary Relationship Sam entity type could participate in e m ultiple relationship types
Supply Ternary Part Departments

Works_In

Binary

Employees

M ltiple u

Supplier

Project

Assigned_to

Cardinality of a relationship In the relational model, tables can be related as any of: many-to-many , many-to-one (rev. one-to-many ), or one-to-one. This is said to be the cardinality of a given table in relation to another. Relationships can have different connectivity one-to-one (1:1) one-to-many (1:N) many-to- One (M:1) many-to-many (M:N)

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
E.g.: Employee head-of department (1:1) Lecturer offers course (1:N) assuming a course is taught by a single lecturer Student enrolls course (M:N)

P s ib C rd a o s le a in lity R tio a s
1to -1 ( : 1 1 ) B th e titie c n o n s a p r ip te in o ly a tic a n . . . oe n
1 - to - 1 1 - to - 1

. . . . . . .
M y an M y an 1 1

r la n ip in n e e tio sh sta c 1-to -M n , M n ay a y -to -1 ( : N N: 1 1 , ) O e e tity c n n n a p r ip te in a tic a mn a y r la n ip in n e e tio sh sta c s M n -to -M n ( : M ay a y N ) B th e titie c n p r ip te in o n s a a tic a mn a y r la n ip in ta c e tio sh s ne

. . . 1- to - M y an. 1- to - M y an . . .
M y an M y an

. . .

. . .
- to - to -

. . . -to -M . any -to -M y an

Representing Cardinality
N Employees 1 Manages 1 Works_In 1 Departments

One em ployee can w ork in only one departm ent One departm ent can em ploy m any em ployees One departm ent can have only one m anager One em ployee can m anage only one departm ent

Relationship Participation 1. Total Participation : Every entity instance must be connected through the relationship to another instance of the other participating entity types 2. Partial Participation: All instances need not participate E.g.: Employee Head-of Department

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

Unit-1
Employee: partial Department: total

R p s n g P r ip tio e re e tin a tic a n


N E ployees m 1 M anages 1 W orks_In 1 D epartm ents

E e y e p y e m s w rk fo a v r m lo e ut o r dpr et e a tm n E e yd p r e t m s h v am n g r v r e a tm n u t a e aae E e yd p r e t m s h v e p y e v r e a tm n u t a e m lo e s N t e e y e p y e is a m n g r o v r m lo e aae


Key : Each entity type must have an attribute or set of attributes that distinguishes one instance from other instances of the same type.

Ea p : x me l
nm ae

nm ae
Bes er

i Kyf r s e o
mf a n

Bes er

ia s cl r o o As l e

3 8

E a p : aMlt x mle ui
dp et n me u br h us or

-at ib t K y t r ue e
ro om

Cus s ore

Nt t a oe h t h us or ad r o n om k y b t w ms s le t o lyo ek y e , u e ut e c n n e

c u a os r ea a o ld ls ev s .

3 9

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

10

Unit-1 Relationship Constraints:

R l to s i C n t ans eai nh o sr i t p
Wa aeR lai n h C n t a t ? h t r e to s i o sr ins p C nt ans o sr i t o t er l to s i t p li it t e n h eai n h y e m h p p s i lec mi aio o e t ie t a my o sb o bn t n f nit s h t a p r i i aeint ec r e p n in r lai n h atcp t h or s o d g e to s i p st e

Structural Constraints

K d o C nt a t in s f o s r ins
W a k do c n t a t c nb d f e int e h t in f o s r ins a e ein d h E M d l? R oe C r in lit C n t a t a d a y o s r ins P r ic a io C n t a t a t ip t n o s r ins T g t e c lle t u t r l C n t a t o e h r a d Sr c u a o s r in s
C n tr in a er p e e te b o s a ts r e r s n d y s e ific n ta ninth E d g a pc o tio e R ia ra rm

Sub Classes :

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

11

Unit-1

Specialization
Is the process of defining a set of subclasses of a superclass The set of subclasses is based upon some distinguishing characteristics of the entities in the superclass Example: {SECRETARY, ENGINEER, TECHNICIAN} is a specialization of EMPLOYEE based upon job type . May have several specializations of the same superclass Example: Another specialization of EMPLOYEE based in method of pay is {SALARIED_EMPLOYEE, HOURLY_EMPLOYEE}. Superclass /subclass relationships and specialization can be diagrammatically represented in EER diagrams Attributes of a subclass are called specific attributes. For example, TypingSpeed of SECRETARY The subclass can participate in specific relationship types. For example, BELONGS_TO of HOURLY_EMPLOYEE

Example of a Specialization

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

12

Unit-1

Generalization
The reverse of the specialization process Several classes with common features are generalized into a superclass ; original classes become its subclasses Example: CAR, TRUCK generalized into VEHICLE; both CAR, TRUCK become subclasses of the superclass VEHICLE.
W can view {CAR, TRUCK} as a specialization of VEHICLE e Alternatively, we can view VEHICLE as a generalization of CAR and TRUCK

Generalization and Specialization


Arrow pointing to the generalized superclass represents a generalization Arrows pointing to the specialized subclasses represent a specialization W do not use this notation because it is often subjective as to e which process is more appropriate for a particular situation W advocate not drawing any arrows in these situations e A superclass or subclass represents a set of entities Shown in rectangles in EER diagrams (as are entity types) Sometimes, all entity sets are simply called classes, whether th are entity types, superclasses , or subclasses

ey

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

13

Unit-1

Subclasses and

Superclasses

(1)

An entity type may have additional meaningful subgroupings of its entities Example: EMPLOYEE may be further grouped into SECRETARY, ENGINEER, MANAGER, TECHNICIAN, SALARIED_EMPLOYEE, HOURLY_EMPLOYEE,
Each of these groupings is a subset of EMPLOYEE entities Each is called a subclass of EMPLOYEE EMPLOYEE is the superclass for each of these subclasses

These are called superclass /subclass relationships. Example: EMPLOYEE/SECRETARY, EMPLOYEE/TECHNICIAN

Md lin S b la s s o e g u c se
S m o j c inaca s myb s e ia o e be ts l s a e pc l d f n an w l s e i e e ca s b tte : d f ea e r e in s b la s uc s Po u ts r dc S f ae otwr po u ts r dc S - - w d f es b la s s inE o e e in u c s e /R Eua o a d c ti n l po u ts r dc
2 9

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

14

Unit-1

S b la s s u c se
nm a e pic r e Po u t r dc c te oy a gr

I a s

I a s

S f a ePo u t otwr r d c pa o m l tf r s

E u a o a Po u t d c ti n l r d c AeGo p g ru
3 0

S b la s toR la n u c sse e tio s

P dc ro u t
N e am Gm iz o P e ric 9 9 4 9 3 9 N e am Gm iz o C g ry ate o g gt ad e po h to g gt ad e p tfo s la rm u ix n

n e am p rice P d t ro uc

c o ateg ry

C e am ra Ty o

S .P d c w ro u t
Is a

Is a

E .P d c d ro u t
N e am
A eG u g ro p

S ftw P d ct o are ro u p latfo s rm

E u atio al P d ct d c n ro u

A eG u g ro p to le d r re d tire
3 2

Gm iz o Ty o

Md lin S b la sSr c r o e g u c s t u tue


Pa om l tf r s r q i e mmr e ur d e oy S f ae otwr Po u t r dc I a s Eu d c -s f ae otwr Po u t r dc I a s Po u t r dc I a s Eua o a d c ti n l Po u t r dc I a s Eua o a d c ti n l -mth d e o
3 3

AeGo p g ru t pc oi

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

15

Unit-1

S U M M A R Y O F E RG R A M -D IA N O T A T IO N F O R E R S C H E M A S
Symbol M e a n in g E N TIT Y T Y P E W E A K E N TIT Y T Y P E R E L A T IO N S H IP T Y P E ID E N TIF Y IN G R E L A T IO N S H IP T Y P E A T T R IB U T E K EY A TTR IB U T E M U L T IV A L U E D A T T R IB U T E C O M P O S IT E A T T R I B U T E D E R IV E D A T T R IB U T E

E1 E1

R R R N (m in ,m ax )

E2 E2 E

T O T A L P A R TIC IP A T IO2N OR E IN F C A R D IN A L I T Y R A TIO 1 :N:EFINRRE 1 2O S TR U C T U R A L C O N S TR A IN T (m in , m a x ) O N P A R TIC IP A T IO N O F E IN R

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

16

Unit-1

Designing an ER Diagram
Consider the following set of requirements for a University data D esign an ER diagram base. for this application: The university keeps track of each student's name, student numbe security r, social number, current address and phone number, permanent address and number, phone birthdate sex, class (freshman, graduate), major department, minor tment (if any), , depar degree program (B.A., B.S., ... Ph.D.). Some user applications need to refer to the city, state, and zip code of the student's permanent address ande to th student's last name. Both social security number and student number are uniqueach student. for e All students will have at least a major department. Each department is described by a name, department code, office number, office phone, and college.Both the name and code have unique values for each department. Each course has a course name, description, course number, numbe r of credits, level and offering department. he course number is unique for each course. T Each section has an instructor, semester, year, course, and sect ion number.The section number distinguishes sections of the same course that are taught the same during semester/year; its value is an integer (1, 2, 3, ... up to umber of sections taught the n during each semester). A grade report must be generated for each student that lists the letter grade, and section, numeric grade (0,1,2,3, or 4) for each student and calculates hi average GPA. s or her

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

17

Unit-1

University ER Diagram
Degree Name Birth date Sex Class Address City State Zip Offer StudentID SSN Major In DName DCode OfficeNumber OfficePhone College Minor In

Student

Department

CName Grade_Report Letter Grade GPA Credits Numeric Grade Instructor Year CourseDesc

Course
CNumber

Section

Belong_To

SectionNumber

Semester

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

18

Unit-1

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

19

Unit-1

FIGURE 3.17 An ER diagram for an AIRLINE database schema.

TTI INSTITUTE, SHALIMAR BAGH, ND-88

9582324716

20

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