You are on page 1of 76

Welcome to the course on Relational Database Management System.



4 .

5 .

6 .

7 .

8 .

9 .

10 .•In the traditional approach. •Application programs go through the file system to access these flat files. information is stored in flat files which are maintained by the file system of OS.

otherwise it will lead to inconsistent data. If the Email ID of one Customer. Generally. This would mean an increased overhead. the programmer must be concerned with data management. it would mean that the details be retrieved from two files. Example: Assume the Customer‟s details such as Cust_Last_Name. Example: Assume Customer‟s details such as Cust_Last_Name. If change is made to data in one file. It is thus preferred to store the information in the Customer_Fixed Deposit file itself. one can design file systems with minimal redundancy. the data is scattered in various files. In a file system it is difficult to give the Customer access to only his data. The Customer_Transaction file has details about the total available balance of all customers. If it is required to get this information about the customer along with his fixed deposit such as addition of a data field requires that the change must be made in all the application programs that access the master file. However. Consequently. it will lead to error during access of the data. for each of the application programs that a programmer writes or maintains. Data management is scattered among all the application programs. Program/Data Dependence: Under the traditional file to Langer_Justin@rediffmail. Changes in the physical format of the master file(s). therefore writing new application programs to retrieve the appropriate data is difficult. If this is not done. Cust_First_Name. Cust_Mid_Name. Data Isolation: Data Isolation means that all the related data is not available in one file. it is required that the change be made to the data in the other file as well. There is no centralized[3] execution of the data management functions. The duplication of data also called redundancy leads to higher storage cost and access cost. A Customer wants information about his account balance. Cust_Email is stored both in the Customer_Details file and the Customer_Fixed_Deposit file. Langer S. for example. Thus enforcing security constraintsfor the entire file or for certain data items are difficult. Justin changes from Langer_Justin@yahoo. Data Redundancy: Often the same information is duplicated in two or more files. Example: Consider the Banking System. 11 . Data redundancy is sometimes preferred. Cust_Mid_Name.Disadvantages of the traditional approach Data Security: The data as maintained in the flat file(s) is easily accessible and therefore not secure. assume the same data is repeated in two or more files. It also lead to data inconsistency For Example. application programs are dependent on the master and transaction file(s) and vice-versa. and the files may be in different formats. the Cust_Email has to be updated in both the files. Cust_First_Name and Cust_Email are not stored in the Customer_Fixed_Deposit file.

A master file. An application program is available to generate a list of customer names in a particular area of the city. record delimiter. This is called concurrent access. Assume a new data field. are changed.00 Hire an application programmer to write the application program for the same. Lack of Flexibility: The traditional systems are able to retrieve information for predetermined requests for data. Both the solutions are cumbersome. Because the application program depends on the master file. Concurrent Access Anomalies: Many traditional systems allow multiple users to access and update the same piece of data simultaneously. These difficulties prompted the development of database systems. Thus by the time the information is made available. But the interaction of concurrent updates may result in inconsistent data. Assume the bank manager is analyzing all the transactions made by the customers. a customer accesses his account to make a withdrawal. the information can perhaps be provided if it is in the files of the system. The account is both read by the bank manager and updated by the customer at the same time. Customer_Fixed_Deposit file exists which has details about the customers fixed deposit accounts. it necessitates that the application program which depends on it. it also needs to be altered. If the physical format of the master/transaction file for example the field delimiter. At the same time.000. If the management needs unanticipated data. Example: Consider the bank system. Example: Consider the banking system. the Fixed_Deposit_Maturity_Date is added to the master file. there is a possibility of the bank manager reading an incorrect balance.000. Because the customer‟s account is being updated at the same time. An application program for this purpose does not exist. 12 . The bank manager has two choices: To print the list of customer names in a particular area of the city and then manually find out those with an account balance greater than $10. also be altered. Extensive programming is however required which may result in delay in making the information available.00 and residing in a particular area of the city. etc. A customer‟s fixed deposit record is described as follows: Cust_ID Cust_Last_Name Cust_Mid_Name Cust_First_Name Cust_Email Fixed_Deposit_No Amount_in_Dollars Rate_of_Interest_in_Percent An application program is available to display all the details about the fixed deposit accounts of all the customers. The bank manager requires a list of customer names having an account balance greater than $10. it may no longer be required or useful.Disadvantages of the traditional approach: Example: Consider the banking system.

facilities like data import & export. physical storage control 13 . user management. logging & audit. backup.Services provided by a DBMS •Data management •Data definition •Transaction support •Concurrency control •Recovery •Security and integrity •Utilities. performance analysis.

the DBMS acts as a layer of abstraction on top of the File system. For interacting with the DBMS we would be using a Query language called SQL. the „c‟ file handling functions. for interacting with the file system.• • Now. You might have observed that. 14 . we were using high level language functions for example.

15 .

16 .

In the above figure. The External view is how the Customer. the three level of DBMS architecture is depicted. 17 . The Conceptual view is how the DBA views it. Jack views it. The Internal view is how the data is actually stored.

18 .

make use of the various database elements and write programs to retrieve data from them. design the database elements. • 19 . Database designers. End users use the DBMS.• • • DBA is a key person and takes care of most administrative tasks as mentioned in the slide. Application programmers.

• • • • 20 . 2. Proper database design can reduce or eliminate data redundancy and confusion. Data can be stored for long term analysis (data warehousing). 4. Data can be more effectively shared between users and/or application programs. 3.better flexibility.• Users and application programs need not know exactly where or how the data is stored in order to access it.Support for unforeseen (ad hoc) information requests are better supported .

21 .

DB2(DataBase 2) 22 .Commercial Packages •Hierarchical Model –an example is IMS (Information Management System) •Network Model – an example is IDMS (Integrated Data Management System) •Relational Model – few examples are Oracle.

g.: Information Management System (IMS) from IBM 23 .Record based data model – Hierarchical data model Organizes the data in a Tree Structure There is hierarchy of parents and child segments Data is represented by a collection of records types This restricts child segment having more than one parent E.

g.: Integrated Data Management System(IDMS) from Honeywell 24 .Record based data model – Network data model Data in the network model is represented by a collection of records Relationships among data are represented by links (Pointers) The records in the database are collection of graphs E.

25 .

• Though logically data is viewed as existing in the form of two dimensional tables. actually. the data is stored under the file system only. each tuple of the relation will represent one student‟s information. The RDBMS provides an abstraction on top of the file system and gives an illusion that data resides in the form of tables. • • • • 26 . Example: If Student is a relation. Tuples in a relation are always unique.

Candidate Key An attribute. A primary key which is a combination of more than one attribute is called a composite primary key . or group of attributes. Every tuple must have. by definition. any subset of these set of attributes would not identify a row uniquely Primary key The candidate key that is chosen to perform the identification task is called the primary key. A candidate key is all those set of attributes which can uniquely identify a row. However. 27 . that is sufficient to distinguish every tuple in the relation from every other one. a unique value for its primary key.

28 .

29 .

30 .

A candidate key is all those set of attributes which can uniquely identify a row. However.An attribute. or group of attributes. that is sufficient to distinguish every tuple in the relation from every other one. any subset of these set of attributes would not identify a row uniquely 31 .

32 .

Cust_Id. For e. (they have Account_no in common) 33 . Account_No and Emailid. Account_No are two overlapping candidate keys.Overlapping candidate keys: Two candidate keys overlap if they involve any attribute in common.g. in the above Customer table.

a unique value for its primary key. 34 .Primary key The candidate key that is chosen to perform the identification task is called the primary key. A primary key which is a combination of more than one attribute is called a composite primary key . by definition. Every tuple must have.

Foreign key •Usually a foreign key is a “copy” of a primary key that has been exported from one relation into another to represent the existence of a relationship between them. 35 . •Foreign keys can also be null . •Foreign key values do not (usually) have to be unique.

36 .




40 .

• The spouse data is identified with the help of the employee id to which it is related 41 .

Key attribute mentioned in the slide should not be miss understood with key attribute discussion of relational model. 42 . The key attribute discussion here is only in the context of ER Diagram.

43 .

44 .

• The minimum and maximum values of this connectivity is called the cardinality of the relationship 45 .

So department entity‟s participation is total and employee entity‟s participation is partial in the above relationship. So only few instances of employee entity participate in the above relationship. 46 .• • All employees will not be head-of some department. But each department will be headed by some employee.


48 .

49 .


E.Represented by an ellipse from which other ellipses emanate and represent the component attributes.g Address 51 .

The relationship above means. 52 . some instances of employee manage other instances of Employee.• • A unary relationship is represented as a diamond which connects one entity to itself as a loop.

53 .

A relationship between two entity types 54 .

55 .A relationship connecting three entity types.

all instances of the entity type Department participate in this relationship.•All instances of the entity type Employee don‟t participate in the relationship. •But. •So. every department would be headed by some employee. So. we say that it is total participation from the department side. So. Head-of. employee entity type is said to partially participate in the relationship. 56 . •Every employee doesn‟t head a department.

These attributes best describe the relationship prescription rather than any individual entity Doctor. Patient or Medicine. 57 .

The identifying relationship is the one which relates the weak entity (dependant) with the strong entity (Employee) on which it depends. Id is underlined with a dotted line because it is used to form composite key of dependent entity along with E#. 58 .

59 .

60 .

61 .

62 .

63 .

64 .

65 .

66 .

67 .

68 .

69 .

70 .

71 .

72 .

73 .

74 .

75 .

76 .