Rdbms Concepts 1

  • View
    338

  • Download
    2

Embed Size (px)

Text of Rdbms Concepts 1

Database Management System Concepts RDBMS CONCEPTS Introduction: RDBMS is the acronym for Relational Database Management System. The concept of relational database is known since 1980s but the idea of database Management System is definitely quite old. The most famous RDBMS packages are Oracle, Sybase, and Informix. Before we move to the RDBMS it would be helpful if we first have a brief idea about DBMS and the reason for RDBMS being preferred to DBMS. Database Management System: A database management system is essentially a collection of interrelated data and a set of programs to access the data. This collection of data is called database. The primary objective of a DBMS is to provide a convenient environment to retrieve and store database information. Database System supports single user and multi-user. While DBMS lets only one person to access the database at a given time, RDBMS allows many users to simultaneously access the database. A database system consists of two parts namely the Database Management System and the Database Application. Database Management System is the program that organizes and maintains the information whereas the Database application is the program that lets us view, retrieve and update information stored in the database. DBMS has to protect database against unintentional changes that could be caused by users and application like disk crash etc. in case of multi-user system, it must be capable of notifying any database changes to the other user. Database Management System Services: 1. Data definition: It is a method of data definition and storage. 2. Data Maintenance: It checks whether each record has fields containing all information about one particular item. For example if an employee table is considered, it is seen that all information about the employee like name, address, designation, salary, dept-name are recorded. 3. Data Manipulation: allows data in the database to be inserted, updated, deleted and stored. 4. Data display: this ensures the accuracy of the data. 5. Data Integrity: this ensures the accuracy of the data. Before proceeding further, it is necessary to be familiar with certain terms of DBMS.

1 / 122

By Naveen Jaiswal

Database Management System Concepts Entity: an entity is any object, place, person, concept, or activity about which an enterprise records data. The below table gives an idea about an entity. Name Biscuits Pen price 12.00 8.00 description food item stationary

A vendor has to maintain a list of all the items that he sells like name price, description etc. These are called entity types. For instance, the values that they store may be Biscuits, 12.00, food item respectively. These are called entity instances. Each of these is termed as an entity and Entity is always identified by a rectangle. There exists a relation ship between two entities. For example, a vendor sells many items and many vendors can sell a particular item. Attribute: an attribute is the characteristic property of an existing entity. The difference between attribute type and attribute instance has to be understood. Attribute type is the property of entity type, and attribute instance of entity instance. An ellipse always represents the attributes. Ex: suppose a student is an entity then student name, number, address would be the attributes of the entity student and the specific- Rama, no-15, S.V.nagar etc. are the attribute instances. Below figure illustrates this with an e-r diagram.

Addres

Address Student

student

Roll no.

rollno

Name Name Any attribute or set of attributes can be uniquely identify a row in a table. This attribute acts as a candidate for a primary key and is referred to as the candidate key. Candidate key can be chosen as primary key depending on factors like uniqueness, usage etc. the relations among data must be suited in detail before proceeding further with certain things. Relationship among data: A relationship is defined as an association among entities. A relationship type is an association of entity types, while a relationship instance is an association of entity instances. A relationship may associate an entity with itself. Several relationships may exist between the same entities. The three different types of relationships recognized among various data stored in the database are:

2 / 122

By Naveen Jaiswal

Database Management System Concepts One-to-one One-to-many(or many-to-one) Many-to-many

One-to-one: Consider for example a set of students in a class. Each student can have only one roll number. Similarly, each roll number can be associated only with one student. This is the case of one-to-one relation ship. Below shows the relationship.

Student 1

Assigne

Rollno1

Student 2

Assigne

Rollno2

Many-to-one A student can register for only one particular course at a time. Where as many students could register for that particular course. Below figure gives the details

Student1 Regist Student 2 Student 3 Course.

Many-to-many A vendor can sell many items and many vendors can sell a particular item. This can be understood from the below figure Vendor 1 Item 1 3 / 122 By Naveen Jaiswal

Database Management System Concepts

Vendor 2 Database Models:

Item 2

Database models are broadly classified into two categories. They are Object-based logical models. Record-base logical models.

The object-base logical model can be defined as a collection of conceptual tools for describing data, data relationships, and data constraints. The record-base logical model describes the data structures and access techniques of a DBMS. There are three types of record-based logical models. They are the hierarchical model, the network model, and the relational model. Consider an example of a company. There are many employees who work in various departments earning a different salary. EMPLOYEE, DEPARTMENT, SALARY Represents the entities about which data has to be recorded. It would be really meaningless if the data just exist in the database. Hence it is necessary that these data should be related to each other. Therefore a database should maintain information about these data and relationships. File management system: The File management system was the first method used to store data in a computerized database. The data item is stored sequentially in one large file. A particular relation ship cannot be drawn between the items other than the sequence in which it is stored. If one has to locate a particular data item, the search starts at the beginning and each item is checked subsequently till the required item is found. These drawbacks in the system necessitated improvisation. Locating a record is tedious. If data has to be inserted the whole file has to be read and rewritten. This can be overcome by adopting an indexing system. An index file contains a subset of the data files based on one or more key fields. There is a pointer to each record in the database. It satisfies ones requirement at the earliest. Any changes in the database have to be updated. The process of updation is also quite tedious. For ex: adding the age to each employees record would require the DBMS to read each record. Then the DBMS writes in to a temporary file and adds the new information after the last field of each record. After the new file is written, the original file is deleted and the temporary file is renamed. The necessity for establishing a relationship among records and 4 / 122 By Naveen Jaiswal

Database Management System Concepts quicker way to access the records led to the development of another model called hierarchical database model. Hierarchical database systems: DBMS Root

Dept1

Dept 2

Dept 3

Id1

Id 1.1

Id 2

Id 2.2

Id 3

Id 3.3

Jack

Clerk

3000

Rama

MGR

7000

This can be said to have parent-child relationship. The origin of the data tree is the root. Data located at different levels along a particular branch from the root is called the node. The lat node in the series is called leaf. This model supports one-to-many relationship. From the figure above it ca be seen that the nodes in the third level are interrelated. Each child has pointers to numerous siblings and there is just one pointer to the parent thus proving a one-to-many relationship. Proceeding to how to access the data- suppose an information is required, id2, it is not necessary for the DBMS to search the entire file to locate the data. Instead, it first follows the dept2 branch and fetches the data. If an index were used in the HDS as in the FMS the process would definitely he hastened. Here the index would be on a particular level of data. It is not possible to insert a new level in the table without alerting the structure. FMS does not support many-to-many relationship. Suppose a new level is required between the root and the department, the only alternative is to frame an entirely new structure. To set this relationship, multiple copies of the same data must be stored at multiple levels that could cause redundancy of data. To overcome this drawback, the network database model was introduced.

Network database system: This model comes under record-based logical model. The main idea behind this model is to bring about many-to-many relationships. The relationship between the different data 5 / 122 By Naveen Jaiswal

Database Management System Concepts items is called as the sets. This system also uses a pointer to locate a particular record. Let us consider the item-vendor example as shown in figure.

Vendor 1

Vendor 2

Vendor 3

Item 1

Item 2

Item 3

Item 4

If one has to know which vendor(s) is selling a particula