Saturday, 21 May 2011

Introduction to DBMS


1.1 Introduction
Databases and database technology are having a major impact on the growing use of computers. It is fair to say that databases play a critical role in almost all areas where computers are used, including business, engineering, medicine, law, education, and library science, to name a few. The word database is in such common use that we must begin by defining a database. Our initial definition is quite general.
A database is a collection of related data (Note 1). By data, we mean known facts that can be recorded and that have implicit meaning. For example, consider the names, telephone numbers, and addresses of the people you know. You may have recorded this data in an indexed address book, or you may have stored it on a diskette, using a personal computer and software such as DBASE IV or V, Microsoft ACCESS, or EXCEL. This is a collection of related data with an implicit meaning and hence is a database.
The preceding definition of database is quite general; for example, we may consider the collection of words that make up this page of text to be related data and hence to constitute a database. However, the common use of the term database is usually more restricted. A database has the following implicit properties:
• A database represents some aspect of the real world, sometimes called the miniworld or the Universe of Discourse (UoD). Changes to the miniworld are reflected in the database.
• A database is a logically coherent collection of data with some inherent meaning. A random assortment of data cannot correctly be referred to as a database.
• A database is designed, built, and populated with data for a specific purpose. It has an intended group of users and some preconceived applications in which these users are interested.
In other words, a database has some source from which data are derived, some degree of interaction with events in the real world, and an audience that is actively interested in the contents of the database.
A database can be of any size and of varying complexity. For example, the list of names and addresses referred to earlier may consist of only a few hundred records, each with a simple structure. On the other hand, the card catalog of a large library may contain half a million cards stored under different categories—by primary author’s last name, by subject, by book title—with each category organized in alphabetic order. A database of even greater size and complexity is maintained by the Internal Revenue Service to keep track of the tax forms filed by U.S. taxpayers. If we assume that there are 100 million tax-payers and if each taxpayer files an average of five forms with approximately 200 characters of information per form, we would get a database of 100*(106)*200*5 characters (bytes) of information. If the IRS keeps the past three returns for each taxpayer in addition to the current return, we would get a database of 4*(1011) bytes (400 gigabytes). This huge amount of information must be organized and managed so that users can search for, retrieve, and update the data as needed.


A database may be generated and maintained manually or it may be computerized. The library card catalog is an example of a database that may be created and maintained manually. A computerized database may be created and maintained either by a group of application programs written specifically for that task or by a database management system.
A database management system (DBMS) is a collection of programs that enables users to create and maintain a database. The DBMS is hence a general-purpose software system that facilitates the processes of defining, constructing, and manipulating databases for various applications. Defining a database involves specifying the data types, structures, and constraints for the data to be stored in the database. Constructing the database is the process of storing the data itself on some storage medium that is controlled by the DBMS. Manipulating a database includes such functions as querying the database to retrieve specific data, updating the database to reflect changes in the miniworld, and generating reports from the data.
It is not necessary to use general-purpose DBMS software to implement a computerized database. We could write our own set of programs to create and maintain the database, in effect creating our own special-purpose DBMS software. In either case—whether we use a general-purpose DBMS or not—we usually have to employ a considerable amount of software to manipulate the database. We will call the database and DBMS software together a database system. Figure 01.01 illustrates these ideas.
1.2 An Example
Let us consider an example that most readers may be familiar with: a UNIVERSITY database for maintaining information concerning students, courses, and grades in a university environment. Figure 01.02 shows the database structure and a few sample data for such a database. The database is organized as five files, each of which stores data records of the same type (Note 2). The STUDENT file stores data on each student; the COURSE file stores data on each course; the SECTION file stores data on each section of a course; the GRADE_REPORT file stores the grades that students receive in the various sections they have completed; and the PREREQUISITE file stores the prerequisites of each course.
To define this database, we must specify the structure of the records of each file by specifying the different types of data elements to be stored in each record. In Figure 01.02, each STUDENT record includes data to represent the student’s Name, StudentNumber, Class (freshman or 1, sophomore or 2, . . .), and Major (MATH, computer science or CS, . . .); each COURSE record includes data to represent the CourseName, CourseNumber, CreditHours, and Department (the department that offers the course); and so on. We must also specify a data type for each data element within a record. For example, we can specify that Name of STUDENT is a string of alphabetic characters, StudentNumber of STUDENT is an integer, and Grade of GRADE_REPORT is a single character from the set {A, B, C, D, F, I}. We may also use a coding scheme to represent a data item. For example, in Figure 01.02 we represent the Class of a STUDENT as 1 for freshman, 2 for sophomore, 3 for junior, 4 for senior, and 5 for graduate student.
To construct the UNIVERSITY database, we store data to represent each student, course, section, grade report, and prerequisite as a record in the appropriate file. Notice that records in the various files may

be related. For example, the record for "Smith" in the STUDENT file is related to two records in the GRADE_REPORT file that specify Smith’s grades in two sections. Similarly, each record in the PREREQUISITE file relates two course records: one representing the course and the other representing the prerequisite. Most medium-size and large databases include many types of records and have many relationships among the records.
Database manipulation involves querying and updating. Examples of queries are "retrieve the transcript—a list of all courses and grades—of Smith"; "list the names of students who took the section of the Database course offered in fall 1999 and their grades in that section"; and "what are the prerequisites of the Database course?" Examples of updates are "change the class of Smith to Sophomore"; "create a new section for the Database course for this semester"; and "enter a grade of A for Smith in the Database section of last semester." These informal queries and updates must be specified precisely in the database system language before they can be processed.



1.4 Actors on the Scene
1.4.1 Database Administrators 1.4.2 Database Designers 1.4.3 End Users 1.4.4 System Analysts and Application Programmers (Software Engineers)
For a small personal database, such as the list of addresses discussed in Section 1.1, one person typically defines, constructs, and manipulates the database. However, many persons are involved in the design, use, and maintenance of a large database with a few hundred users. In this section we identify the people whose jobs involve the day-to-day use of a large database; we call them the "actors on the scene." In Section 1.5 we consider people who may be called "workers behind the scene"—those who work to maintain the database system environment, but who are not actively interested in the database itself.
1.4.1 Database Administrators
In any organization where many persons use the same resources, there is a need for a chief administrator to oversee and manage these resources. In a database environment, the primary resource is the database itself and the secondary resource is the DBMS and related software. Administering these resources is the responsibility of the database administrator (DBA). The DBA is responsible for authorizing access to the database, for coordinating and monitoring its use, and for acquiring software and hardware resources as needed. The DBA is accountable for problems such as breach of security or poor system response time. In large organizations, the DBA is assisted by a staff that helps carry out these functions.
1.4.2 Database Designers
Database designers are responsible for identifying the data to be stored in the database and for choosing appropriate structures to represent and store this data. These tasks are mostly undertaken before the database is actually implemented and populated with data. It is the responsibility of database designers to communicate with all prospective database users, in order to understand their requirements, and to come up with a design that meets these requirements. In many cases, the designers are on the staff of the DBA and may be assigned other staff responsibilities after the database design is completed. Database designers typically interact with each potential group of users and develop a view of the database that meets the data and processing requirements of this group. These views are then analyzed and integrated with the views of other user groups. The final database design must be capable of supporting the requirements of all user groups.
1.4.3 End Users
End users are the people whose jobs require access to the database for querying, updating, and generating reports; the database primarily exists for their use. There are several categories of end users:

Casual end users occasionally access the database, but they may need different information each time. They use a sophisticated database query language to specify their requests and are typically middle- or high-level managers or other occasional browsers.
• Naive or parametric end users make up a sizable portion of database end users. Their main job function revolves around constantly querying and updating the database, using standard types of queries and updates—called canned transactions—that have been carefully programmed and tested. The tasks that such users perform are varied:
Bank tellers check account balances and post withdrawals and deposits.
Reservation clerks for airlines, hotels, and car rental companies check availability for a given request and make reservations.
Clerks at receiving stations for courier mail enter package identifications via bar codes and descriptive information through buttons to update a central database of received and in-transit packages.
• Sophisticated end users include engineers, scientists, business analysts, and others who thoroughly familiarize themselves with the facilities of the DBMS so as to implement their applications to meet their complex requirements.
• Stand-alone users maintain personal databases by using ready-made program packages that provide easy-to-use menu- or graphics-based interfaces. An example is the user of a tax package that stores a variety of personal financial data for tax purposes.
A typical DBMS provides multiple facilities to access a database. Naive end users need to learn very little about the facilities provided by the DBMS; they have to understand only the types of standard transactions designed and implemented for their use. Casual users learn only a few facilities that they may use repeatedly. Sophisticated users try to learn most of the DBMS facilities in order to achieve their complex requirements. Stand-alone users typically become very proficient in using a specific software package.
1.4.4 System Analysts and Application Programmers (Software Engineers)
System analysts determine the requirements of end users, especially naive and parametric end users, and develop specifications for canned transactions that meet these requirements. Application programmers implement these specifications as programs; then they test, debug, document, and maintain these canned transactions. Such analysts and programmers (nowadays called software engineers) should be familiar with the full range of capabilities provided by the DBMS to accomplish their tasks.
1.5 Workers behind the Scene
In addition to those who design, use, and administer a database, others are associated with the design, development, and operation of the DBMS software and system environment. These persons are typically not interested in the database itself. We call them the "workers behind the scene," and they include the following categories.
• DBMS system designers and implementers are persons who design and implement the DBMS modules and interfaces as a software package. A DBMS is a complex software system


that consists of many components or modules, including modules for implementing the catalog, query language, interface processors, data access, concurrency control, recovery, and security. The DBMS must interface with other system software, such as the operating system and compilers for various programming languages.
• Tool developers include persons who design and implement tools—the software packages that facilitate database system design and use, and help improve performance. Tools are optional packages that are often purchased separately. They include packages for database design, performance monitoring, natural language or graphical interfaces, prototyping, simulation, and test data generation. In many cases, independent software vendors develop and market these tools.
• Operators and maintenance personnel are the system administration personnel who are responsible for the actual running and maintenance of the hardware and software environment for the database system.
Although the above categories of workers behind the scene are instrumental in making the database system available to end users, they typically do not use the database for their own purposes.
1.6 Advantages of Using a DBMS
1.6.1 Controlling Redundancy 1.6.2 Restricting Unauthorized Access 1.6.3 Providing Persistent Storage for Program Objects and Data Structures 1.6.4 Permitting Inferencing and Actions Using Rules 1.6.5 Providing Multiple User Interfaces 1.6.6 Representing Complex Relationships Among Data 1.6.7 Enforcing Integrity Constraints 1.6.8 Providing Backup and Recovery
In this section we discuss some of the advantages of using a DBMS and the capabilities that a good DBMS should possess. The DBA must utilize these capabilities to accomplish a variety of objectives related to the design, administration, and use of a large multiuser database.
1.6.1 Controlling Redundancy
In traditional software development utilizing file processing, every user group maintains its own files for handling its data-processing applications. For example, consider the UNIVERSITY database example of Section 1.2; here, two groups of users might be the course registration personnel and the accounting office. In the traditional approach, each group independently keeps files on students. The accounting office also keeps data on registration and related billing information, whereas the registration office keeps track of student courses and grades. Much of the data is stored twice: once in the files of each user group. Additional user groups may further duplicate some or all of the same data in their own files.
This redundancy in storing the same data multiple times leads to several problems. First, there is the need to perform a single logical update—such as entering data on a new student—multiple times: once for each file where student data is recorded. This leads to duplication of effort. Second, storage space is wasted when the same data is stored repeatedly, and this problem may be serious for large databases. Third, files that represent the same data may become inconsistent. This may happen because an update is applied to some of the files but not to others. Even if an update—such as adding a new student—is applied to all the appropriate files, the data concerning the student may still be inconsistent since the updates are applied independently by each user group. For example, one user group may enter a student’s birthdate erroneously as JAN-19-1974, whereas the other user groups may enter the correct value of JAN-29-1974.
In the database approach, the views of different user groups are integrated during database design. For consistency, we should have a database design that stores each logical data item—such as a student’s name or birth date—in only one place in the database. This does not permit inconsistency, and it saves storage space. However, in some cases, controlled redundancy may be useful for improving the performance of queries. For example, we may store StudentName and CourseNumber redundantly in a GRADE_REPORT file (Figure 01.05a), because, whenever we retrieve a GRADE_REPORT record, we want to retrieve the student name and course number along with the grade, student number, and section identifier. By placing all the data together, we do not have to search multiple files to collect this data. In such cases, the DBMS should have the capability to control this redundancy so as to prohibit inconsistencies among the files. This may be done by automatically checking that the StudentName-StudentNumber values in any GRADE_REPORT record in Figure 01.05(a) match one of the Name-StudentNumber values of a STUDENT record (Figure 01.02). Similarly, the SectionIdentifier-CourseNumber values in GRADE_REPORT can be checked against SECTION records. Such checks can be specified to the DBMS during database design and automatically enforced by the DBMS whenever the GRADE_REPORT file is updated. Figure 01.05(b) shows a GRADE_REPORT record that is inconsistent with the STUDENT file of Figure 01.02, which may be entered erroneously if the redundancy is not controlled.
1.6.2 Restricting Unauthorized Access
When multiple users share a database, it is likely that some users will not be authorized to access all information in the database. For example, financial data is often considered confidential, and hence only authorized persons are allowed to access such data. In addition, some users may be permitted only to retrieve data, whereas others are allowed both to retrieve and to update. Hence, the type of access operation—retrieval or update—must also be controlled. Typically, users or user groups are given account numbers protected by passwords, which they can use to gain access to the database. A DBMS should provide a security and authorization subsystem, which the DBA uses to create accounts and to specify account restrictions. The DBMS should then enforce these restrictions automatically. Notice that we can apply similar controls to the DBMS software. For example, only the DBA’s staff may be allowed to use certain privileged software, such as the software for creating new accounts. Similarly, parametric users may be allowed to access the database only through the canned transactions developed for their use.
1.6.3 Providing Persistent Storage for Program Objects and Data Structures
Databases can be used to provide persistent storage for program objects and data structures. This is one of the main reasons for the emergence of the object-oriented database systems. Programming languages typically have complex data structures, such as record types in PASCAL or class definitions in C++. The values of program variables are discarded once a program terminates, unless the programmer explicitly stores them in permanent files, which often involves converting these complex structures into a format suitable for file storage. When the need arises to read this data once more, the programmer must convert from the file format to the program variable structure. Object-oriented database systems are compatible with programming languages such as C++ and JAVA, and the DBMS software automatically performs any necessary conversions. Hence, a complex object in C++ can be stored permanently in an object-oriented DBMS, such as ObjectStore.

Such an object is said to be persistent, since it survives the termination of program execution and can later be directly retrieved by another C++ program.
The persistent storage of program objects and data structures is an important function of database systems. Traditional database systems often suffered from the so-called impedance mismatch problem, since the data structures provided by the DBMS were incompatible with the programming language’s data structures. Object-oriented database systems typically offer data structure compatibility with one or more object-oriented programming languages.
1.6.4 Permitting Inferencing and Actions Using Rules
Some database systems provide capabilities for defining deduction rules for inferencing new information from the stored database facts. Such systems are called deductive database systems. For example, there may be complex rules in the miniworld application for determining when a student is on probation. These can be specified declaratively as rules, which when compiled and maintained by the DBMS can determine all students on probation. In a traditional DBMS, an explicit procedural program code would have to be written to support such applications. But if the miniworld rules change, it is generally more convenient to change the declared deduction rules than to recode procedural programs. More powerful functionality is provided by active database systems, which provide active rules that can automatically initiate actions.
1.6.5 Providing Multiple User Interfaces
Because many types of users with varying levels of technical knowledge use a database, a DBMS should provide a variety of user interfaces. These include query languages for casual users; programming language interfaces for application programmers; forms and command codes for parametric users; and menu-driven interfaces and natural language interfaces for stand-alone users. Both forms-style interfaces and menu-driven interfaces are commonly known as graphical user interfaces (GUIs). Many specialized languages and environments exist for specifying GUIs. Capabilities for providing World Wide Web access to a database—or web-enabling a database—are also becoming increasingly common.
1.6.6 Representing Complex Relationships Among Data
A database may include numerous varieties of data that are interrelated in many ways. Consider the example shown in Figure 01.02. The record for Brown in the student file is related to four records in the GRADE_REPORT file. Similarly, each section record is related to one course record as well as to a number of GRADE_REPORT records—one for each student who completed that section. A DBMS must have the capability to represent a variety of complex relationships among the data as well as to retrieve and update related data easily and efficiently.
1.6.7 Enforcing Integrity Constraints
Most database applications have certain integrity constraints that must hold for the data. A DBMS should provide capabilities for defining and enforcing these constraints. The simplest type of integrity constraint involves specifying a data type for each data item. For example, in Figure 01.02, we may specify that the value of the Class data item within each student record must be an integer between 1 and 5 and that the value of Name must be a string of no more than 30 alphabetic characters. A more complex type of constraint that occurs frequently involves specifying that a record in one file must be related to records in other files. For example, in Figure 01.02, we can specify that "every section record must be related to a course record." Another type of constraint specifies uniqueness on data item values, such as "every course record must have a unique value for CourseNumber." These constraints are derived from the meaning or semantics of the data and of the miniworld it represents. It is the database designers’ responsibility to identify integrity constraints during database design. Some constraints can be specified to the DBMS and automatically enforced. Other constraints may have to be checked by update programs or at the time of data entry.
A data item may be entered erroneously and still satisfy the specified integrity constraints. For example, if a student receives a grade of A but a grade of C is entered in the database, the DBMS cannot discover this error automatically, because C is a valid value for the Grade data type. Such data entry errors can only be discovered manually (when the student receives the grade and complains) and corrected later by updating the database. However, a grade of Z can be rejected automatically by the DBMS, because Z is not a valid value for the Grade data type.
1.6.8 Providing Backup and Recovery
A DBMS must provide facilities for recovering from hardware or software failures. The backup and recovery subsystem of the DBMS is responsible for recovery. For example, if the computer system fails in the middle of a complex update program, the recovery subsystem is responsible for making sure that the database is restored to the state it was in before the program started executing. Alternatively, the recovery subsystem could ensure that the program is resumed from the point at which it was interrupted so that its full effect is recorded in the database.






Sunday, 17 April 2011

Books for 'DBMS'

Books for 'DBMS'
1) Database Systems: Design, Implementation, and Management, Seventh Edition

Peter Rob, Carlos Coronel
ISBN 13: 978-1-4188-3593-4 © 2007
ISBN 10: 1-4188-3593-5
Publish date: January 27, 2006
696 pages
Hardcover

2) DBMS by C.J.Date
DBMS by Korth
3) Raghu Rama Krishna

Sunday, 20 March 2011

data models


Data models:
Defin:
it is a set of concepts that can be used to describe the data such as data types and its length, relationships and consistency and constraints(conditions).
It provides the abstraction.
There are 3 types of data models:
1)record based data model
2)object based data model
3)physical data model.

1.   Record based data model:

These models are used in describing the data at logical and view level of abstraction.
It is in record format.
Each record contains the fields, and each field contains the fixed length of values.
Again this model is divided into 3 models:
1)   hierarchical data model
2)   network data model
3)   relational data model

1)   hierarchical data model:

data stores in the form of records, each record contains the fields and each field contains the fixed length.
Here each record is connected with links.
Features:

It uses tree structure to represent the relationship.
It contains only one parent record and this record doesn’t have any parent record.
This parent record have child record.

Advantages:

It is very efficient to maintain for one-to-many relationships.
It allows handle large amount of data and it provides the integrity.
It is simple and easy to design.

Disadvantages:

Although it is simple, it is difficult to implement the data. (i.e during the updation of the data) it leads to data inconsistency.

It can not handle many-to-many relationships.

2)   Network Data Model:

It is used to explain the data at view and logical level
It provides the many-to-many relationships
In this records are connected through pointers.
Here graphs can be formed but not trees.

Advantages:

It provides the many-to-many relationships.
Data can be accessed very simple.
Fast accessing of the data.
The storage space is reduced due to less data redundancy.

Disadvantages:
It is difficult to design and use properly
It is difficult to changes the database.
Not user friendly.


 
RELATIONAL MODEL
           The Relational data model is currently the most popular data model is DATA BASE MANAGEMENT system.
Ø      Why it is famous means the data is represented is the form of simple row and column format.
Ø      Each data field is considered as column.each record is considered as row of table.
Ø      The data model is developed by E.F.Codd in 1970 which is based on relation.
Ø      We don’t find any parent-child relation shis,we find the data in the form of row and column.tables of data values.
Ø      The tables are called relations.

ADVANTAGES
1.      Easy to use.
2.      Many –to-many relationships
3.      Flexibility
4.      Security
5.      Fast data access, less storage.
6.      Data redundancy is controlled.
7.      Data manipulation language.

DISADVANTAGES:

Needs powerful hardware.
                       























2.OBJECT-BASED LOGICAL MODELS

Ø      It describes the data at the conceptual and new level.
Ø      It allows data constraints explicitly.
Ø      Again these object-based logical models are 30 types.
1.      Entity relationship model
2.      Object oriented model
3.      Binary model
4.      Semantic data model
5.      Infological model
6.      Functional data model

1.Entity relationship model:
Ø      Entity is a thing or object in the real world
Ø      It consists collection of objects, called ENTITY and of relationships among these objects(thing)
Ø      Ex: if u consider customer in a company

1.      Costomer consists:     
2.      Cust_id
3.      Cust_name
4.      Cust_street
5.      Cust_city
Here customer is an entity and cus_id,cust_name,cust_street,cust_city are the attributes

Ø      If you want to make relation between more than one entity (object)then use the following symbols

Rectangles: which represent entity sets
Ellipses: which represent attributes
Diamonds: which represent relationships among entity sets
Lines: which link attributes to entity sets and sets and sets to relationships

Customer                           depositor                             account
Cust_id                                                                      account number
Cust_name                                                                  balance
Cust_street
Cust_city

The E-R diagram indicates that there are two entity sets: customer, account, with attributes as
The above diagram shows a relationship depositor between customer and account.



3.PHYSICAL DATA MODEL:

Ø      A physical data model is a representation of a data design
Ø      It describes the data at the lowest level
Ø      These concepts are mainly done by the computer specialists but not for the end users
Ø      Data is represented as record formats
Ø      Very few models are there
Ex: unifying model
       Frame memory


INSTANCES AND SCHEMAS:

Instances:

The collection of information stored in the database at a particular moment is called AN INSTANCE of the database
Instance is also known as ‘snap-shop’

Ex: in a class strength is 60, this is known as schema, because 60 will not be exceeded at all.
At a particular day strength may be decreased, that particular day strength is known as instance.

Types of schemas:

Physical schema:
                        It describes database design at the physical level.
Conceptual (or) logical schema: describes different news of the database.

Data independence:

The ability to modify a schema(database structure) in one level without affecting a schema definition in next higher level is called data independence.
 There are two levels of data independence:

(1.) physical data independence:
          To improve the performance of the DBMS, modification at the physical level are necessary. The ability to modify the physical schema without affecting the application programs to be rewritten is called physical data independence.

2) Logical data independence:

Whenever the logical structure of the database is altered (changes), modifications at the logical level are necessary. The ability to modify the logical schema without effecting application programs to be rewritten is called logical data independence.

Data models:
Defin:
it is a set of concepts that can be used to describe the data such as data types and its length, relationships and consistency and constraints(conditions).
It provides the abstraction.
There are 3 types of data models:
1)record based data model
2)object based data model
3)physical data model.

1.   Record based data model:

These models are used in describing the data at logical and view level of abstraction.
It is in record format.
Each record contains the fields, and each field contains the fixed length of values.
Again this model is divided into 3 models:
1)   hierarchical data model
2)   network data model
3)   relational data model

1)   hierarchical data model:

data stores in the form of records, each record contains the fields and each field contains the fixed length.
Here each record is connected with links.
Features:

It uses tree structure to represent the relationship.
It contains only one parent record and this record doesn’t have any parent record.
This parent record have child record.

Advantages:

It is very efficient to maintain for one-to-many relationships.
It allows handle large amount of data and it provides the integrity.
It is simple and easy to design.

Disadvantages:

Although it is simple, it is difficult to implement the data. (i.e during the updation of the data) it leads to data inconsistency.

It can not handle many-to-many relationships.

2)   Network Data Model:

It is used to explain the data at view and logical level
It provides the many-to-many relationships
In this records are connected through pointers.
Here graphs can be formed but not trees.

Advantages:

It provides the many-to-many relationships.
Data can be accessed very simple.
Fast accessing of the data.
The storage space is reduced due to less data redundancy.

Disadvantages:
It is difficult to design and use properly
It is difficult to changes the database.
Not user friendly.





1)Create a student table with attributes pino, name, marks ,avg.
2)insert the values into the tables at a time
Syntax: insert into <existing table> values(&attribute1, &attribute2,….);
Ex: insert into student values(‘&name’, &pino,&marks,&avg);
3) update <existing table> set attribute1=<value>,attribute2=<value> where (condition);
Ex: update student set marks=590,avg=60.25 where pino=345;
4)write a query to change the structure of student table by adding a new column.
Syntax:
Alter table <existing table > add attribute datatype(size);
Example: alter table student add address varchar(30);
5)write a query to modify the structure of student table by changing the size of address.
Syntax: alter table <existing table> modify attribute data type(size);
Example: alter table student modify address char2(40);

1)write a query to set some data for the name and avg in the records.
Syntax: update <exitsting table> set attribute1=<value>,attribute2=<value> where <condition>;
Example: update student name=’raj’, avg=76.89 where pino=56;

2)write a query to change the structure of student by adding a new column mobileno.
5) waq to select the names and marks of students whose marks are above 60;
Ex: select name, marks from student where marks>60;
6)write a query that sets the content data base from student in ascending order based on pinno.
Sysnax: select attribute(s) from <existing table > order by attribute;
Query(example): select * from student order by pino;




Database structure:
1)explain about database structure?
Database structure is divided into two parts:
1)   storage management
2)   query processor

1)   storage management:
storage management works as an interface between data stored in database and the application.

That is data is stored in disk as file system using operating system. The storage manager converts DML Statements into low level file systems.

i)TRANSACTION MANAGER:
 as the name specifies, it manages the transactions such that data remain in consistent state even after the transaction. It also provides for optimal concurrent transaction executions.

·       File management: file management allocated space for the data on disk and provides a data structure to define the information saved on disk that provides for easy access.
·       Buffer management: buffer management handles the transfer of data from disk onto the main memory and decides on what data to be kept in main memory.
·       Authorization management: this module allows only authorized users to access the data.
·       Integrity management: this module handles on the integrity constraints that are said on the data.  Storage management uses the following data structure i)data files ii)data dictionary iii)indices.
(II) QUERY PROCESSOR:
·       Interpreter Of DDL: DDL statements written by DBA to define the schema are interpreted and stored in the data dictionary.
·       Compiler of data manipulation language statements: as any other compiler, DML compiler converts the DML statements in low-level instructions. I also optimizes the query i.e., perform “query optimization”
·       Query evaluation DML compiler converts DML statements into low level instructions which are evaluated by query evaluation machine.








1)Create a student table with attributes pino, name, marks ,avg.
2)insert the values into the tables at a time
Syntax: insert into <existing table> values(&attribute1, &attribute2,….);
Ex: insert into student values(‘&name’, &pino,&marks,&avg);
3) update <existing table> set attribute1=<value>,attribute2=<value> where (condition);
Ex: update student set marks=590,avg=60.25 where pino=345;
4)write a query to change the structure of student table by adding a new column.
Syntax:
Alter table <existing table > add attribute datatype(size);
Example: alter table student add address varchar(30);
5)write a query to modify the structure of student table by changing the size of address.
Syntax: alter table <existing table> modify attribute data type(size);
Example: alter table student modify address char2(40);

1)write a query to set some data for the name and avg in the records.
Syntax: update <exitsting table> set attribute1=<value>,attribute2=<value> where <condition>;
Example: update student name=’raj’, avg=76.89 where pino=56;

2)write a query to change the structure of student by adding a new column mobileno.
5) waq to select the names and marks of students whose marks are above 60;
Ex: select name, marks from student where marks>60;
6)write a query that sets the content data base from student in ascending order based on pinno.
Sysnax: select attribute(s) from <existing table > order by attribute;
Query(example): select * from student order by pino;




Database structure:

Database structure is divided into two parts:
1)   storage management
2)   query processor

1)   storage management:
storage management works as an interface between data stored in database and the application.

That is data is stored in disk as file system using operating system. The storage manager converts DML Statements into low level file systems.

i)transaction manager:
 as the name specifies, it manages the transactions such that data remain in consistent state even after the transaction. It also provides for optimal concurrent transaction executions.

·       File management: file management allocated space for the data on disk and provides a data structure to define the information saved on disk that provides for easy access.
·       Buffer management: buffer management handles the transfer of data from disk onto the main memory and decides on what data to be kept in main memory.
·       Authorization management: this module allows only authorized users to access the data.
·       Integrity management: this module handles on the integrity constraints that are said on the data.  Storage management uses the following data structureL i)data files ii)data dictionary iii)indices.
(II) query processor:
·       INTERPRETER OF DATA DEFINITION LANGUAGE STATEMENTS: DDL statements writtey by DBA to define the schema are interpreted and stored in the data dictionary.
·       Compiler of data manipulation language statements: as any other compiler, DML compiler converts the DML statements in low-level instructions. I also optimizes the query i.e., perform “query optimization”
·       Query evaluationL DML compiler converts DML satemts into low level instructions which are evaluated by query evaluation machine.




GENERALIZATION,SPECIALAZATION AND AGGREGATION:

Generalization:

Ø     Generalization is a special case of specialization
Ø     Generalization is the result of taking the union of two or more different entity sets to form higher level entity set
Ø     That is combinding low-level entity sets and producing a highlevel entity set is known as generalization

Example:

In a bank there are two types of customers
1.     current account customers
2.     saving account customers

Ø     these two are represented by two entity sets
Ø     if we generalize there entity sets we can get an entity set customers of the bank.

 
REDUCE THE ER DIAGRAMS TO TABLES

A database that is represented as an ER diagrams an ER diagrams can be represented by a collection of tables. for each entity set and for each relationship set in the database, that is a unique table that is assigned the name of the corresponding entity set (or) relationship set. each table has multiple columns, each is unique name.

For example, consider the entity set names employee of the employee entity set has the attributes eno, ename, sal,

The table corresponding to the EMPLOYEE has three columns as under.

ENO       ENAME    SAL
Em-001   ravi            6000
cm-002   anji             7000
ec-001     gopi           8000
me-003    venki         9000
ee-002     babu rao      10000

if we consider,the entity set dept of the ER diagram

imp quesitons for DBMS


RDBMS
SECTION-A

  1. Explain disadvantages in file based processing.(markch/ap09,oc/nov09)
  2. Differentiate between hierarchical model and network model.(mark/ap2009)
  3. Define instance and scheme( oct/nov09 08)
  4. List the responsibilities of database manager.
  5. What are symbols used in E-R diagrams?(March/April.2009,oct/nov.07)
  6. Explain data independence. (march/april.09,oct/nov.07/nov2010)
  7. What are the difference between generalization and specialization
  8. Explain about concept of aggregation. (oct/nov.09)
  9. What do you means by SQL? What are the benefits of SQL?.
  10. What is an embedded SQL?
  11. What do you meant by pseudo column? Explain with examples. (oct/nov.09,08)
  12. What are the differences between Char and varchar2 data types?(M/A.09)
  13. Write any four data functions with syntax and examples
  14. State the four features of SQL. (March/April 2009)
  15. What is the process of creating a Table
  16. Define a sequence
  17. Difference between view and table.
  18. Write the names of four schema objects.
  19. Define is PL/SQL global and system variables.
  20. List the features of PL/SQL.
  21. What are Naming Conventions in PL/SQL?
  22. List any four predefined PL/SQL exceptions.
  23. Compare various parameter modes.
  24. What is a cursor? Explain the management of explicit cursor.
  25. What is implicit cursor?
  26. What is a stored sub program
  27. List the advantages of packages
  28. How to compile a PL/SQL program?
  29. What is packaged procedure? Give example.
  30. Define package.


Section-b

  1. What is database model?(oct/nov08)
  2. What do you meant by generalization, specialization and aggregation. (Oct/Nov.09,08,07)
  3. Explain the various mapping cardinalities. (Oct/Nov.07)
  4. Explain the various normal forms in details. (Oct/Nov.09)
  5. What is database abstraction? Explain with the help of a diagram.(m/ap09,oc/no-09)
  6. Explain the functions of Database Administrator
  7. Explain various data types available in SQL. (Oct/Nov.2009, March/April.2009)
  8. Explain about any 12 function of SQL. (MARCH/APRIL 2009)
  9. Explain the following SQL statements (a) insert (b)update   (March/April.2009)
  10. (a)Explain the various data format models in SQL.                        (b)Explain set operators of SQL
  11. Explain group function of SQL. (Oct/Nov.2008, 2007)
  12. (a.)Explain about DML statements (Oct/Nov.2009)                                                             (b) explain about data types supported by SQL. (Oct/Nov.2009)
  13.  Explain the process of creating (a) sequence (b)cluster (c)synonym (d) index
  14. Explain the procedure for creating, altering and dropping a sequence
  15. (a.) Explain the space management of database table.  (b) Explain about indexes.
  16. What is an integrity constraint? List the various types of integrity constraints.
  17. What is a view? Explain the syntax for creating a view.
  18. Explain the procedure of creating, altering and dropping tables.
  19. Explain the following commands: (i.)commit (ii)rollback and save point.
  20. Explain the various data types of PL/SQL in detail.
  21. Explain propagation and re-raising of exceptions.
  22. What is an exception? Explain the rising of an exception.
  23. Explain about implicit and explicit cursor.
  24. (a)Explain recursion with an example.
  25. Explain package state and dependency.
  26. Explain procedure overloading in PL/SQL with an example.

Advanced PL/SQL

  1. What is stored Sub Program?
Ans: it is a sub program which may be procedure or function in a database object that are logically group of SQL and PL/SQL programming language statements together to perform a specific task.
A cursor is a temporary work area created in the system memory when a SQL statement is executed. A cursor contains information on a select statement and the rows of data accessed by it. This temporary work area is used to store the data retrieved from the database, and manipulate this data. A cursor can hold more than one row, but can process only one row at a time. The set of rows the cursor holds is called the active set.
There are two types of cursors in PL/SQL:

Implicit cursors:

These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed. They are also created when a SELECT statement that returns just one row is executed.

Explicit cursors:

They must be created when you are executing a SELECT statement that returns more than one row. Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row. When you fetch a row the current row position moves to next row.
Both implicit and explicit cursors have the same functionality, but they differ in the way they are accessed.

Implicit Cursors:

When you execute DML statements like DELETE, INSERT, UPDATE and SELECT statements, implicit statements are created to process these statements.
Oracle provides few attributes called as implicit cursor attributes to check the status of DML operations. The cursor attributes available are %FOUND, %NOTFOUND, %ROWCOUNT, and %ISOPEN.
For example, When you execute INSERT, UPDATE, or DELETE statements the cursor attributes tell us whether any rows are affected and how many have been affected.
When a SELECT... INTO statement is executed in a PL/SQL Block, implicit cursor attributes can be used to find out whether any row has been returned by the SELECT statement. PL/SQL returns an error when no data is selected.
The status of the cursor for each of these attributes are defined in the below table.
Attributes
Return Value
Example
%FOUND
The return value is TRUE, if the DML statements like INSERT, DELETE and UPDATE affect at least one row and if SELECT ….INTO statement return at least one row.
SQL%FOUND
The return value is FALSE, if DML statements like INSERT, DELETE and UPDATE do not affect row and if SELECT….INTO statement do not return a row.
%NOTFOUND
The return value is FALSE, if DML statements like INSERT, DELETE and UPDATE at least one row and if SELECT ….INTO statement return at least one row.
SQL%NOTFOUND
The return value is TRUE, if a DML statement like INSERT, DELETE and UPDATE do not affect even one row and if SELECT ….INTO statement does not return a row.
%ROWCOUNT
Return the number of rows affected by the DML operations INSERT, DELETE, UPDATE, SELECT
SQL%ROWCOUNT

For Example: Consider the PL/SQL Block that uses implicit cursor attributes as shown below:
DECLARE  var_rows number(5);
BEGIN
  UPDATE employee 
  SET salary = salary + 1000;
  IF SQL%NOTFOUND THEN
    dbms_output.put_line('None of the salaries where updated');
  ELSIF SQL%FOUND THEN
    var_rows := SQL%ROWCOUNT;
    dbms_output.put_line('Salaries for ' || var_rows || 'employees are updated');
  END IF; 
END; 
In the above PL/SQL Block, the salaries of all the employees in the ‘employee’ table are updated. If none of the employee’s salary are updated we get a message 'None of the salaries where updated'. Else we get a message like for example, 'Salaries for 1000 employees are updated' if there are 1000 rows in ‘employee’ table.