Escolar Documentos
Profissional Documentos
Cultura Documentos
INTRODUCTION:
Database is a collection of information in a structured way. We can say that it is a collection of a group of facts. A database management system is a set of software programs that allows users to create, edit and update data in database files, and store and retrieve data from those database files. Data in a database can be added, deleted, changed, sorted or searched all using a DBMS. PURPOSE OF DATABASE MANAGEMENT SYSTEM: In the early days, database applications were built directly on top of file systems Drawbacks of using file systems to store data: Data redundancy and inconsistency Multiple file formats, duplication of information in different files Difficulty in accessing data Need to write a new program to carry out each new task Data isolation multiple files and formats Integrity problems Integrity constraints (e.g. account balance > 0) become buried in program code rather than being stated explicitly. Hard to add new constraints or change existing ones. Atomicity of updates Failures may leave database in an inconsistent state with partial updates carried out
Example: Transfer of funds from one account to another should either complete or not happen at all Concurrent access by multiple users Concurrent accessed needed for performance. Uncontrolled concurrent accesses can lead to inconsistencies. Example: Two people reading a balance and updating it at the same time.
EXAMPLE: CREATE TABLE Students (sid CHAR(9), name VARCHAR(20), login CHAR(8), age INTEGER, gpa REAL);
ALTER: This command is used to change the structure of the table. SYNTAX: i. ALTER TABLE <table-name> MODIFY(column-name datatype); ii. ALTER TABLE <table-name> ADD(column-name datatype); EXAMPLE: ALTER TABLE Students ADD phone CHAR(7);
DROP: This command used to remove the table from the database. SYNTAX: DROP TABLE <table-name>;
INSERT: Insert command is used to add rows of value in the created table. They are three types of insert commands. Inserting values for all the columns defined in a table Inserting values only for some particular columns Inserting more than one row values SYNTAX: INSERT INTO <table-name> VALUES(list of values); EXAMPLE: INSERT INTO Students VALUES (53688,Mark,mark2345,23,3.9);
UPDATE: Update command is used to change values in one or more columns in a row of a table. SYNTAX: UPDATE <table-name> SET column1=expression, column2=expression WHERE search condition; EXAMPLE: UPDATE Students S SET S.age=S.age+1, S.gpa=S.gpa-1 WHERE S.sid = 53688;
DELETE: Delete command is used to delete rows from the table. SYNTAX: DELETE FROM <table-name> WHERE search condition; EXAMPLE: DELETE FROM Students S WHERE S.name = Smith;
COMMIT: A Commit statement does what it says, and commits all the changes made to data that have been made during the current transaction. If a Commit statement does not take place at the end of a transaction and the computer crashes, then all data will be updated in its previous state. Another important point to remember is that if Commit has been written, it then becomes impossible to Rollback to the original data.
ROLLBACK: A Rollback statement, again does what its name implies, and rolls back, or rescinds, all changes to the current transaction. The ROLLBACK statement is the inverse of the COMMIT statement. It undoes some or all database changes made during the current transaction. SAVEPOINT: The SAVEPOINT statement names and marks the current point in the processing of a transaction. With the ROLLBACK TO statement, savepoints undo parts of a transaction instead of the whole transaction. GRANT: SQL GRANT is a command used to provide access or privileges on the database objects to the users. REVOKE: The REVOKE command removes user access rights or privileges to the database objects.
and over again. Minimizing redundancy can therefore significantly reduce the cost of storing information on hard drives and other storage devices. In contrast, data fields are commonly repeated in multiple files when a file management system is used. Accuracy: Accurate, consistent, and up-to-date data is a sign of data integrity. DBMSs foster data integrity because updates and changes to the data only have to be made in one place. The chances of making a mistake are higher if you are required to change the same data in several different places than if you only have to make the change in one place. Program and file consistency: Using a database management system, file formats and system programs are standardized. This makes the data files easier to maintain because the same rules and guidelines apply across all types of data. The level of consistency across files and programs also makes it easier to manage data when multiple programmers are involved. User-friendly: Data is easier to access and manipulate with a DBMS than without it. In most cases, DBMSs also reduce the reliance of individual users on computer specialists to meet their data needs. Improved security: As stated earlier, DBMSs allow multiple users to access the same data resources. This capability is generally viewed as a benefit, but there are potential risks for the organization. Some sources of information should be protected or secured and only viewed by select individuals. Through the use of passwords, database management systems can be used to restrict data access to only those who should see it.
systems to modern database technology measured in terms of dollars, time, and organizational commitment may prohibitive to an organization. Need for Explicit Backup and Recovery: A shared corporate database must be accurate and available at all times. This requires that comprehensive procedures be developed and used for providing backup copies of data and for restoring a database when damage occurs. A modern database management system normally automates many more of the backup and recovery tasks than a file system. Organizational Conflict: A shared database requires a consensus on data definitions and ownership as well as responsibilities for accurate data maintenance. Experience has shown that conflicts on data definitions, data formats and coding, rights to update shared data, and associated issues are frequent and often difficult to resolve. Handling these issues requires organizational commitment to the database approach, organizationally astute database administrators, and a sound evolutionary approach to database development. If strong top management support of and commitment to the database approach is lacking, end-user development of stand-alone databases is likely to proliferate. often seem