Module-II: Database and Database Management System
Module-II: Database and Database Management System
Difference between files and Relational database Files 1. Store data in one dimensional files 2. Stores, organize and retrieve information from one file at a time 3. Leave the management of data relationships to the applications that access the data.
Relational database 1. Store data in two dimensional tables 2. Store organizes and retrieve information is linked by a common column or field 3. Establish relationships between files and views within the database itself.
4. Require a
programmer to write code for data management functions. 5. Files are created and maintained by application programs. 6. Are often associated with older programs on mainframe and mid-range system.
Database
Database is an integrated and well defined data and information,centrally controlled in all its aspects,created and stored in atypical structure for an organization. In an organization the database could be one or more depending upon the needs and the operations of the organization. The data structure and its storage should be such that it facilitates sharability,availability,and integrity of data. Database excludes transient data such as reports,input documents,intermediate results obtained during processing
Objectives of Database
1. 2. 3. 4. 5. 6. 7. 8.
Controlled Redundancy Ease of learning and use Data independence More information at low cost Accuracy and integrity Recovery from failure Privacy and security Performance
All the three levels of management use the same database hence any report using the information will be consistent All the three levels of management view the database as per their needs. The application systems can be developed independent of the database. The data validation and updating will be once and same for all The data is shared by all user Data security and privacy can be managed AS the database is a storage of structured information the queries can be answered fast.
User programs Application program or queries Software to process Queries/Programs S/W to access Stored Data
1. 2. 3. 4. 5.
Distributed database
These are databases of local work groups and departments at regional office,branch offices manufacturing plant and other work sites.These database can include segments of both common operational and common user databases as well as data generated and used only at a users own site.
External databases
These can be accessed from large,privately owned databases or databanks available for a fee to end users and organisations from commercial information service networks.Data is available in the form of statistics on economic and demographic activity from statistical data banks; abstracts from hundreds of newspapers,magazines and other periodicals from bibliographic data banks.
DBMS
DBMS consists of a collection of inter-related data and a set of programs to access that data.The collection data is usually referred to as database which contains information about one particular enterprise. The primary goal of a DBMS is to provide an environment that is both convenient and efficient to use retrieving and storing database information. DBMS is the interface between the user of application programs on one hand and the database on other.
DBMS
DBMS as interface between application program and data base
User(or) Application program DBMS
Data base
Components to a DBMS These are:1. At least one person who owns' and is responsible for the database. 2. A set of rules and relationships that defines and governs the interactions among elements of the database. 3. People who put data into the database 4. People who get data out of the database 5. The database itself.
Components of DBMS
DDL DML SQL
Functions of DBMS
1.
2.
Organizes data:-Data are organised according to the specifications of DDL.These are specified by the DBA at the time of creation of database. Integrates data:- Data are interrelated or linked together at the elements level and can,therefore be assembled in many combinations during execution of a particular application program. Separates data:-A DBMS servers as a filter between application program and their associated data.It separates the logical description and relationship of data from the way in which the data are physically stored. Controls data: A DBMS appears to an application programmer to be an extension of the O.S S/W .As it receives data requests from host programs,it controls how and where data are physically stored. Retrieves data:A record of data can be obtained via DBMS1.Serially 2.Sequentially 3.Randomly by address 4.Randomly by key 5. By structural link Protects : A DBMS protects and secures both the content of a database and relationships of data element . Data are protected against by unauthorized users,physical damage,OS
3.
4.
5.
6.
Data dictionary
data element.It describes the data and its characteristics,such as location,size,type of data,it identifies the origin,the use,the ownership,and the method of accessing and securing data. 2. The data dictionary can exist either on paper or as a computer file.When it exist as a file,special S/W is necessary to create and maintain it,and make it available for use such S/w is called a data dictionary system(DDS).DDSs can be acquired as separate S/W packages or as DBMSs and computer aided S/W engineering tools. 3. A good data dictionary would ensure consistent definitions of data across different databases,and if there were a change to the data ,it would also
Language
Two languages are used to communicate with data base are: 1. Data description Language(DDL) 2. Data manipulation Language(DML)
Data manipulation language A language that processes and manipulates the data in the database is called data manipulation language. It allows the user to query the database and receive summary reports and/or customised reports. DML enables the user to access,update,replace,delete and protect database records from unauthorised access. The DML is usually integrated with other PLs,many of which are 4Gls,to implement sophisticated database functions.
SQL
It allows the user to access the data from the databases to specific queries,both on mainframes and on PCs.Here users can transform their experience from one database system to another without going into much detail. There are four basic operation in SQL Select Update Insert And delete
1. 2. 3. 4.
SQL
Select statement enables users to query the database for specific information Update statement allow users to update the data. Insert statement new data in the existing database. Delete statement delete existing data from the database Two types of question s can be asked by users in SQL: -Static Question & dynamic Question Static questions are routine and standardize and once defined,can be used repeatedly or generating weekly,monthly and quarterly reports, S/W packages generating static questions are sometimes referred to as report writers. Dynamic questions are ad hoc and specific to the decision maker.
Characteristics of DBMS
The capability to store large amounts of data necessary for users needs.They are stored on direct accessible devices for on-line support. The capacity to interrogating data files,retrieving and modifying data and recording the changes The data are combined to form operational units to minimise the duplication of data and increase access to all data in the database. The control in the systems limits the access to the database files and builds the confidentiality of all data in these files.
Objectives of DBMS
Provide for mass storage of relevant data. Make access to the data easy for the user Provide prompt response to user requests for data. Make the latest modifications to the data base available immediately Eliminate redundant Data Allow for multiple users to be active at one time Allow for growth in the database system Protect the data from physical harm and unauthorised access
2.
3. 4.
Data Independence
The ability to modify a schema definition in one level without affecting a schema definition in the next higher level is called data independence. There are two levels of data independence Physical data independence Logical data Independence
Entities
All the real world object such as an employee, a component in an inventory or a space or it may be intangible such as a even,a job description,identification numbers.All such items about which relevant information is stored in the database are called Entities.
Attributes
An attribute may be expressed as a number or as a text.It may even be a scanned picture,a sound sequence,a moving picture which is now possible in multimedia database Data processing normally concern with a collection of similar entities and records information about the same attributes of each of them
Schema
A schema is a logical database description and is drawn as a chart of the types of data that are used .It gives the names of the entities and attributes and specify the relationship between them.It is a frame work into which the data item can be fitted.Like an information display system such as that giving the arrival and departure time at airport and railway stations,the schema will remain the same though the value displayed in the system will change from time to time.The relationship between the entities occurring in the schema may be one-to-one or one-to-many or many to many or conditional.That means it is an overall chart of all the data item type and record types
Subschema
The term subschema refers to the same view but for the data-item types and record type which are used in a particular user.Therefore many different sub-schemas can be derived from one schema
User view
User view
User view
Conceptual view
This is the next higher level of abstraction which is the sum total of users views.This level describes what data are actually stored in database. This level contains information about entire database in terms of a small number of relatively simple structure. It represents the entities and there relationships. It contains integrity rules and authorization rules,but it does not contain information about how the data items are stored
Internal View
This is the lowest level of abstraction at which one describes how the data are physically stored And how we can access it. It includes information on ordering of records,block sizes,storage indexes,use of pointers,and access strategies being used.
Data Independence
Application Maintenance
Higher Low maintenance maintenance cost cost Provided by DBMS A query language can be used
Integrity controls Usually provided by programmer Unanticipated Queries A custom program has to
Cont.
Data relationship Handled by applications if at all Little CPU and Storage overhead An integral part of DBMS
Overhead
Database ownership
More processing power and storage is needed All data belongs to the DBMS
cont
Database design Data files may be designed as needed Not needed More time and effort is spent to develop a good database design to Needed coordinate and resolve the needs of the user community The average programmer needs to be trained to use database management
DBA
Data models
A data model is a collection of concepts that can be used to describe the structure of a database.By structure of a database we mean the data types,relationships and constraints that should hold on data. Most of the data models also include a set of basic operations for specifying retrievals and updates on the database. A database model is the method of organizing data and represents the logical relationship among data elements in database .
Data Models
Data model is of three types 1. Object based logical model:ER model,Object oriented model,binary model,Semantic data model,info logical model,functional data model 2. Records based logical models:Relational,Network,Hierarchic al 3. Physical data model:Unifying
Types of Relationship
One-to-one:This relationship indicates a unique relation between two entities(studentregd-no,person and employment no.) One-to-many:Here an entity can have multiple relationships with other entities in the database(Air bus and passengers,teacher and student) Many-to-many:Here every entity can be related to a number of entities.(teachers and students).
Chequing Application
Saving Application
Bank database
Hierarchical Model
It helps to establish explicit or logical relationships among various data elements of multiple files and arrange the elements in a hierarchy. Each box is a record,it is also termed as node. In this model each record in one level can be related to multiple records on the next-lower level. A record that has a subsidiary records is callec the parent and the subsidiary records are called children. It follows 1:M relationship with other data elements in the database
Entity type
The above figure provides the hierarchical model Here link fields establish the explicit relation ships. The links are represented by thin lines that connect data elements of the various records in the lower portion. Once a sales person record is retrieved the link in that record can lead to another record i,e logically related to that salesperson.A link field in the second record leads to a 3rd record,and so on creating a chain through an entire set of file. The system retrieve records from the hierarchy through pointers,which are pieces of data that identifies the link between different records.The data nodes in this are linked to one another through a series of pointers,one of which is attached to the end of each record in the database
Advantage
Well suited for modeling hierarchical data. Top-down nature makes programming efficient.
Disadvantage
Based on one-way access from superiors to subordinates. Not suited for manyto-many relationships. Difficult to inert subordinate records without superior records. Deleting superiors logically deletes subordinates. Difficult to update record stored in multiple locations. Not suited for databases where relationships change.
Network Model
In this model,each record in a database can have multiple parents. It maintain Many-to-Many(M:M) relationship In network model,databases can be translated from hierarchical form to network form and vice-versa. Data elements are linked through pointers. In this model a child can have a number of parents,where as in a hierarchical model a child can have only one parent. Like hierarchical model the records are not limited to only one superior. A record may have many superior records and many subordinate records.
Network Model
It allows entry into a database at multipoint A group of interconnected nodes is called a network. A subway map is an example of a network.The subway stations are the nodes,and the tracks are the interconnections or network. A common approach is multi pointers,especially with a link node record representing the connection between two entities.
Advantages
It promotes flexibility and data accessibility,since data elements at a lower level can be accessed without accessing the data elements above them. It is efficient ,easy to understand,and can be applied to many real world problems that require routine transaction.
Disadvantages
It is complex to design and develop It requires that the relationships among all data elements to be defined before development starts,and changes often demand a major programming efforts For large database ,operation and maintenance of the network model are time-consuming and expensive
Relational Model
In relational model , data is represented using two-dimensional tables,called relation of flat files The flat files are made up of columns and rows. Each column represents a field,also referred to as an attribute. Each row represent a record , also referred as a tuple. It is well suited for business needs because of their flexibility
Relational Model
Relational databases use three fundamental operations: SELECT PROJECT JOIN The select operation is used to selected the requested query. The project operation creates a subset of columns designed to meet the information needs of the user. The JOIN operation joins or links two or more tables ,if the information requested by the user is not found in one table Example:MS Access,dbase IV,DB2
Advantages
Query languages allow ease of use. It can relate data in a table as long as the two tables share at least one common attribute.Thats why most commercial databases for microcomputers use relational database It enables a computer system to accommodate a variety of file inquiries in an efficient manner. No need to know the inner structure of the database Data independence allow easy structure modification
Disadvantages
Query languages consume processing time and memory Data must be related to act upon Set processing is not suite3d to conventional PLs. Command affect system performance
Relational Database
A DBMS can be regarded as relational only if it obeys the following three rules. 1. All information must be held in tables 2. Retrieval of this data must be possible using the following types of operation Select, Join,Project 3. A relationship between data must be represented explicitly in that data itself.
Distributed Processing
It refers to an architecture in which a database resides on a different machine to the user process accessing it. To put this in a different way,the front and back end processes are on different machines.Such a machine will obviously necessitate some form of communication capability between the machine and depends entirely on a complex logical and physical separation between the front and back end processes and processing
Distributed database
A distributed data system is a collection of sites or connected by communication lines whereby: 1. Each participating node houses a relational database 2. These databases are themselves fully functional within their own location. 3. A logical global distributed database is defined incorporating elements of each of the participating databases in order to evaluate a single occurrence of a database.
Normalisation
It is the processes of simplifying the relationship between data elements in a record.Through normalization, a collection of data in a record structure is replaced by successive record structures that are simpler and more predictable and therefore more manageable.The reasons why it is carried out are: To structure the data to maintain the data an its relationship. To permit simple retrieval of data in response to query and report requests. To simplify the maintenance of the data through updated inventories and deletions. To reduce the need to restructure or reorganize data when application requirements arise.
1.
2.
3.
4.
Degree of Normalisation
1NF(First Normal Form) 2NF(Second Normal Form) 3NF(Third Normal Form) BCN(Boyce-codd Normal Form) 4NF(Fourth Normal Form) 5NF(Fifth or Projection-Join Normal Form)