distribution of marks for second semester internal sessional evaluation external evaluation...

Post on 12-Jan-2016

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Distribution of MarksFor

Second SemesterInternal Sessional Evaluation Externa

l Evaluati

onAssignm

ent/Project

Quizzes

Class Attenda

nce

Mid-Term Test

Total Sessio

nal

Terminal Exam

Final Evaluati

on

10 10 5 25 50 50 100

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

1

Remember:

Chapter No

Chapter NamePage No

1.Database Foundation OR An Overview of Database Management System (DBMS)

2. Semantic Modeling OR Entity Relationship Model (ERD)

3. An introduction to Relational Database

4. Normalization

5. Relational Algebra

6. An Introduction to Structured Query Language (SQL)

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

2

Course Contents

COURSE INSTRUCTOR:

ILTAF MEHDI

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

3

Ch

ap

ter

No:

03

Ch

ap

ter

No:

03

Def:“A data model is a representation of data about entities, events, activities and their relationship”.

A data model represents an organization itself. The purpose of data model two-fold: First “to

represent data” and second “to be understandable”.

If a data model accurately and completely represent required data and is understandable then it can be used in some application.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

4

There are basically three types of data model:

1)Hierarchical Data Model2)Network Data model3)Relational Data model

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

5

1) Relational Data Model: It also called Relational Database Model. The Relational Data Model is the most

recent and best of the three database models.

It was developed by C.F Codd in 1970. This model represents database as a set of

normalized relations. “In Relational Model data are represented in

the form of tables with rows and columns”.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

6

Deptt-No

Deptt-Name

Deptt-Location

D100 IT West

D101 Management

East

D102 English South

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

7

Emp-No

Emp-Name

Emp-Phone #

Deptt-No

E10 Mehdi 336 D100

E11 Danish 448 D101

E12 Nasir 500 D102

DEPARTMENT

EMPLOYEE

Relational Database Model

Notice that there is no physical data structure representing relationship between two tables (relations). Instead relationships are represented logically by the values that are stored within table’s columns.For example: In above figure, the Department-Number (Deptt-No) for each Employee is stored in Employee table.

The above tables have the following properties:1. Each column contained values about some

attribute.2. Each column has distinct name.3. Each row of a table must be unique, means,

that no two rows have the identical data.4. Each row in the relation is called TUPLE.5. Each column in the relation is called DOMAIN.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

8

6. Record: “The combination of more than one fields about a

single entity is called record of that entity”.For example: The record of STUDENT may have fields Roll-No,

Name, Father Name, Gender, Address, Program and Marks. Then this combination of fields is called the record of a particular STUDENT.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

9

Roll-No

Name F-Name

Gender

Address

Program

Marks

100 Abdullah

Zain Male Kabul BCS 40

101 Spogmay

Iqbal Female

Kabul BCS 47

1st RECORD

2nd RECORD

FIELDSFIELDS

STUDENT FILE

7. File or Data File: “The collection of more than one related records

is called a file or data file”. All the records of the should be of the same type. In the above File, two logical records about

STUDENT are shown.8. Degree of file: “The total number of the columns in a file is

called Degree of a file”.9. Cardinality: The total number of rows or records in a file is

called cardinality.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

10

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

11

Roll-No

Name F-Name

Gender

Address

Program

Marks

100 Abdullah

Zain Male Kabul BCS 40

101 Spogmay

Iqbal Female

Kabul BCS 47

Two Records

SEVEN FIELDSSEVEN FIELDS

Degree of File: 07Degree of File: 07

Cardinality: 02Cardinality: 02

STUDENT Relation

Properties of Relation

The Relational Data Model has several advantages but some of them are given below:

1)Implementation Independence: R.D.M logically represents all relationship

implicitly and completely.2)Terminology: The R.D.M has developed with its own set of

terminology.3)Logical Key Pointer: The R.D.M uses primary and secondary keys

to represent relationship between two relations.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

12

Def: “a key is a data item which is used to identify a record or relation”.

OR An attribute through which we can

access an entity within entity class”.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

13

There are different types of keys which are given below:

1. Super Key2. Candidate Key3. Primary Key4. Atomic Key5. Concatenated Key 6. Compound Key7. Secondary Key8. Foreign Key

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

14

1) Super Key:“An attribute or combination of attributes that

can uniquely identify an entity is called super key”.

For Example: consider the STUDENT relation;STUDENT (st-no, st-name, st-age, st-gender etc) A super key may contain some extra

attributes that are not necessary to uniquely identify an entity.

i.e. { st-no, st-name, st-age } In-fact a super key can be:{ Primary-key + Non-key attribute }

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

15

2) Candidate Key: “An attribute or combination of attributes

that uniquely identifies each instances of an entity is called Candidate Key”.

For Example: consider the EMPLOYEE relation;

EMPLOYEE (NIC-No, Name, Address etc) Here NIC-No and Name is a super key that

contain extra attributes that is not necessary for unique identification. So it is not a candidate key. But NIC-No is a Candidate Key.

An entity may be uniquely identified by more than one candidate keys.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

16

3) Primary Key: Def: “A primary key is a key that have been

selected as an identifier for an entity type”. It is also called identifier.For example: Consider the EMPLOYEE relation;EMPLOYEE (Emp-No, Emp-Name, Emp-

Address) If we select Emp-No as an identifier then it

is Primary Key.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

17

4) Atomic Key: Def: “A Primary Key is called atomic key or

simple key when it consists of a single attribute to identify a record or relation”.

For Example: Consider the STUDENT relation;

STUDENT (St-ID, St-Name, St-F/Name,St-Address)

St-ID is atomic key for the STUDENT relation

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

18

5) Concatenated Key: Def: “The combination of two or more keys to

uniquely identify a record is called Concatenated Key”.

For Example: Consider the STUDENT relation;STUDENT (class-no, name, address, class)

“We have student file of Computer Science Department that contain information about Previous and Final students”. In this case class-no can’t uniquely identify a student because there may be duplication of students for class i.e. Previous and Final. So both class-no and class can be used as Primary Key in this case. Such a key is called Concatenated Key.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

19

6) Compound Key: Def: “A Compound Key is a Primary Key that

consists of more than one attribute and every attribute in the key is Primary key in some other relation”.

For Example: Consider the relation;ORDER-LINE (order-no, product-no,

quantity, date) So the primary key consists of order-no and

product-no. But order-no is primary key in ORDER relation and product-no is primary key in PRODUCT relation. So it is a Compound Key.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

20

7) Secondary Key: “A secondary key is a data item that does

not uniquely identify a record but identifies a number of records in a set that share some common property ”.

For Example: Name, Address, Age etc are the examples of Secondary Key.

Now consider the Query:

So based on secondary key “Age” this query will select all students whose age is 20.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

21

Select * from student where Age=‘20’ ;

Select * from student where Age=‘20’ ;

8) Foreign Key: Def: “An attribute that appear as non-

key in one relation but primary key in another relation is called Foreign Key”.

For Example: Consider the relations;DEPARTMENT (Deptt-No, Deptt-Name,

Location)TEACHER (T-No, T-Name, Deptt-No ) Here Deptt-No is a foreign key because it

act as primary key in DEPARTMENT and as non-key attribute in TEACHER relation.

By ILTAF MEHDI (MCS, MCSE, CCNA) An introduction to Relational Database

22

top related