Key Point

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

1

Definition: A database management system (DBMS) is the software that allows a computer to perform database functions of storing, retrieving, adding, deleting and modifying data. Relational database management systems (RDBMS) implement the relational model of tables and relationships. Examples: Microsoft Access, MySQL, Microsoft SQL Server, Oracle and FileMaker Pro are all examples of database management systems.

Key point:Primary key - Primary key means main key def:- A primary key is one which uniquely identifies a row of a table. This key does not allow null values and also does not allow duplicate values. For ex, empno empname salary 1 firoz 35000 2 basha 34000 3 chintoo 40000 it will not the values as follows: 1 firoz 35000 1 basha 34000 chintoo 35000

foreign key - a foreign key is one which will refer to a primary key of another table for ex, emp_table dept_table empno empname salary deptno deptno deptname In the above relation, deptno is there in emp_table which is a primary key of dept_table. That means, deptno is refering the dept_table.

Super Key:- superkey is a set of columns within a table whose values can be used to uniquely identify a row. A candidate key is a minimal set of columns necessary to identify a row, this is also called a minimal superkey. For example, given an employee table, consisting of the columns employeeID, name, job, and departmentID, we could use the employeeID in combination with any or all other columns of this table to uniquely identify a row in the table. Examples of superkeys in this table would be {employeeID, Name}, {employeeID, Name, job}, and {employeeID, Name, job, departmentID}.

2 The following diagram illustrates the five components of a DBMS.

Database Engine: The Database Engine is the core service for storing, processing, and securing data. The Database Engine provides controlled access and rapid transaction processing to meet the requirements of the most demanding data consuming applications within your enterprise.Use the Database Engine to create relational databases for online transaction processing or online analytical processing data. This includes creating tables for storing data, and database objects such as indexes, views, and stored procedures for viewing, managing, and securing data. You can use SQL Server Management Studio to manage the database objects, and SQL Server Profiler for capturing server events.

Data dictionary: A data dictionary is a reserved space within a database which is used to store information about the database itself. A data dictionary is a set of table and views which can only be read and never altered.Most data dictionaries contain different information about the data used in the enterprise. In terms of the database representation of the data, the data table defines all schema objects including views, tables, clusters, indexes, sequences, synonyms, procedures, packages, functions, triggers and many more. This will ensure that all these things follow one standard defined in the dictionary. The data dictionary also defines how much space has been allocated for and / or currently in used by all the schema objects.A data dictionary is used when finding information about users, objects, schema and storage structures. Every time a data definition language (DDL) statement is issued, the data dictionary becomes modified.

A data dictionary may contain information such as:


y y y y y y y

Database design information Stored SQL procedures User permissions User statistics Database process information Database growth statistics Database performance statistics

Query Processor : A relational database consists of many parts, but at its heart are two major components: the storage engine and the query processor. The storage engine writes data to and reads data from the disk. It manages records, controls concurrency, and maintains log files.The query processor accepts SQL syntax, selects a plan for executing the syntax, and then executes the chosen plan. The user or program interacts with the query processor, and the query processor in turn interacts with the storage engine. The query processor isolates the user from the details of execution: The user specifies the result, and the query processor determines how this result is obtained. The query processor components include
y y y

DDL interpreter DML compiler Query evaluation engine

3
Data definition language
DDL statements are used to build and modify the structure of your tables and other objects in the database. When you execute a DDL statement, it takes effect immediately. The create table statement does exactly that:
CREATE TABLE <table name> ( <attribute name 1> <data type 1>, ... <attribute name n> <data type n>);

The data types that you will use most frequently are character strings, which might be called VARCHAR or CHAR for variable or fixed length strings; numeric types such as NUMBER or INTEGER, which will usually specify a precision; and DATE or related types. Data type syntax is variable from system to system; the only way to be sure is to consult the documentation for your own software. The alter table statement may be used as you have seen to specify primary and foreign key constraints, as well as to make other modifications to the table structure. Key constraints may also be specified in the CREATE TABLE statement.
ALTER TABLE <table name> ADD CONSTRAINT <constraint name> PRIMARY KEY (<attribute list>);

You get to specify the constraint name. Get used to following a convention of tablename_pk (for example, Customers_pk), so you can remember what you did later. The attribute list contains the one or more attributes that form this PK; if more than one, the names are separated by commas. The foreign key constraint is a bit more complicated, since we have to specify both the FK attributes in this (child) table, and the PK attributes that they link to in the parent table.
ALTER TABLE <table name> ADD CONSTRAINT <constraint name> FOREIGN KEY (<attribute list>) REFERENCES <parent table name> (<attribute list>);

Name the constraint in the form childtable_parenttable_fk (for example, Orders_Customers_fk). If there is more than one attribute in the FK, all of them must be included (with commas between) in both the FK attribute list and the REFERENCES (parent table) attribute list. You need a separate foreign key definition for each relationship in which this table is the child. If you totally mess things up and want to start over, you can always get rid of any object youve created with a drop statement. The syntax is different for tables and constraints.

DROP TABLE <table name>; ALTER TABLE <table name> DROP CONSTRAINT <constraint name>;

This is where consistent constraint naming comes in handy, so you can just remember the PK or FK name rather than remembering the syntax for looking up the names in another table. The DROP TABLE statement gets rid of its own PK constraint, but wont work until you separately drop any FK constraints (or child tables) that refer to this one. It also gets rid of all data that was contained in the tableand it doesn't even ask you if you really want to do this! All of the information about objects in your schema is contained, not surprisingly, in a set of tables that is called the data dictionary. There are hundreds of these tables most database systems, but all of them will allow you to see information about your own tables, in many cases with a graphical interface. How you do this is entirely system-dependent.

Data manipulation language


DML statements are used to work with the data in tables. When you are connected to most multiuser databases (whether in a client program or by a connection from a Web page script), you are in effect working with a private copy of your tables that cant be seen by anyone else until you are finished (or tell the system that you are finished). You have already seen the SELECT statement; it is considered to be part of DML even though it just retreives data rather than modifying it. The insert statement is used, obviously, to add new rows to a table.
INSERT INTO <table name> VALUES (<value 1>, ... <value n>);

The comma-delimited list of values must match the table structure exactly in the number of attributes and the data type of each attribute. Character type values are always enclosed in single quotes; number values are never in quotes; date values are often (but not always) in the format 'yyyy-mm-dd' (for example, '2006-11-30'). Yes, you will need a separate INSERT statement for every row. The update statement is used to change values that are already in a table.
UPDATE <table name> SET <attribute> = <expression> WHERE <condition>;

The update expression can be a constant, any computed value, or even the result of a SELECT statement that returns a single row and a single column. If the WHERE clause is omitted, then the specified attribute is set to the same value in every row of the table (which is usually not

what you want to do). You can also set multiple attribute values at the same time with a commadelimited list of attribute=expression pairs. The delete statement does just that, for rows in a table.
DELETE FROM <table name> WHERE <condition>;

If the WHERE clause is omitted, then every row of the table is deleted (which again is usually not what you want to do)and again, you will not get a do you really want to do this? message. If you are using a large multi-user system, you may need to make your DML changes visible to the rest of the users of the database. Although this might be done automatically when you log out, you could also just type:
COMMIT;

If youve messed up your changes in this type of system, and want to restore your private copy of the database to the way it was before you started (this only works if you havent already typed COMMIT), just type:
ROLLBACK;

Although single-user systems dont support commit and rollback statements, they are used in large systems to control transactions, which are sequences of changes to the database. Transactions are frequently covered in more advanced courses.

4
Basic Characteristics of DBMS Represents complex relationship between data Controls data redundancy. Enforces user defined rules. Ensures data sharing. It has automatic and intelligent backup and recovery procedures. It has central dictionary to store information. Pertaining to data and its manipulation. It has different interfaces via which user can manipulate the data. Enforces data access authorization.

Advantages of using the DBMS approach

1. Controlled Redundancy In the file processing approach, each user defines and implements the files needed and software applications to manipulate those files. Various files are likely to have different formats and programs may be written in different languages and same information may be duplicated in several files. Data redundancy leads to o wasted storage space, o duplication of effort (when multiple copies of a datum need to be updated), o a higher likelihood of the introduction of inconsistency. Database design stores each logical data item at one place to ensure consistency and saves storage. But sometimes, controlled redundancy is necessary to improve the performance. Database should have capability to control this redundancy & maintain consistency by specifying the checks during database design. 2. Restricting Unauthorized Access A DBMS provides a security and authorization subsystem, which is used by DBA to create user accounts and to specify restrictions on user accounts. File processing system provides password mechanism and very less security which is not sufficient to enforce security policies like DBMS. 3. Providing Persistent Storage for Program Objects Object oriented database systems are compatible with programming languages such as C++ and Java. A DBMS software automatically performs the conversion of a complex object which can be stored in object oriented DBMS, such an object is said to be persistent due to its survival after the termination of the program.

4. Providing Storage Structures for Efficient Query Processing The DBMS utilizes a variety of sophisticated techniques (view, indexes etc.) to store and retrieve the data efficiently that are utilized to improve the execution time of queries and updates. DBMS provides indexes and buffering for fast access of query result, the choice of index is part of physical database design and tuning. The query processing and optimization module is responsible for choosing an efficient query execution plan for each query submitted to the system. 5. Providing Backup & Recovery Data should be restored to a consistent state at the time system crash and changes being made If hardware or software fails in the middle of the update program, the recovery subsystem of DBMS ensures that update program is resumed at the point of failure. 6. Multiple user interfaces DBMS provides a variety of user interfaces for the users of varying level of technical knowledge. These includes query language for casual users, programming language interfaces for application programmers, forms and command codes for parametric users, menu driven interfaces and natural language interfaces for stand alone users etc 7. Representing Complex Relationships among data A DBMS must have the capability to represent a variety of complex relationship among the data, to define new relationships as they arise, and to retrieve and update the related data easily and efficiently. 8. Enforcing Integrity Constraints The DBMS have certain integrity constraints that hold on data. These constraints are derived from the meaning of the data and of the miniworld. Some constraints can be specified to the DBMS at the time of defining data definitions and automatically enforced.

Database does not allow violation of constraints at the time of updating the database. 9. Permitting Inferencing and Action Using Rules Deductive database systems provide capabilities for defining deduction rules for inferencing new information from the stored database facts. Triggers can be associated with tables. A trigger is a form of a rule activated by updates to the table, which results in performing some additional operations to some other tables, sending messages and so on. Stored procedure can also be used as a part of the overall database definition and are invoked appropriately when certain conditions are met. Active database provides more powerful functionality by providing the active rules that can automatically initiate actions when certain events and conditions occur.

Disadvantages of file processing system


Disadvantages of File Processing Systems include: 1. Program-Data Dependence. File descriptions are stored within each application program that accesses a given file. 2. Duplication of Data. Applications are developed independently in file processing systems leading to unplanned duplicate files. Duplication is wasteful as it requires additional storage space and changes in one file must be made manually in all files. This also results in loss of data integrity. It is also possible that the same data item may have different names in different files, or the same name may be used for different data items in different files. 3. Limited data sharing. Each application has its own private files with little opportunity to share data outside their own applications. A requested report may require data from several incompatible files in separate systems. 4. Lengthy Development Times. There is little opportunity to leverage previous development efforts. Each new application requires the developer to start from scratch by designing new file formats and descriptions 5. Excessive Program Maintenance. The preceding factors create a heavy program maintenance load. 6. Integrity Problem. The problem of integrity is the problem of ensuring that the data in the database is accentuate. 7. Inconsistance data

8. Security

5
In ER Model attributes can be classified into the following types.
y y y y

Simple and Composite Attribute Single Valued and Multi Valued attribute Stored and Derived Attributes Complex Attribute

Simple and Composite Attribute Simple attribute that consist of a single atomic value. A composite attribute is an attribute that can be further subdivided. For example the attribute ADDRESS can be subdivided into street, city, state, and zip code. A simple attribute cannot be subdivided. For example the attributes age, sex etc are simple attributes.

Simple Attribute: Attribute that consist of a single atomic value. Example: Salary, age etc Composite Attribute : Attribute value not atomic. Example : Address : House_no:City:State Name : First Name: Middle Name: Last Name Single Valued and Multi Valued attribute A single valued attribute can have only a single value. For example a person can have only one 'date of birth', 'age' etc. That is a single valued attributes can have only single value. But it can be simple or composite attribute.That is 'date of birth' is a composite attribute , 'age' is a simple attribute. But both are single valued attributes. Multivalued attributes can have multiple values. For instance a person may have multiple phone numbers,multiple degrees etc.Multivalued attributes are shown by a double line connecting to the entity in the ER diagram. Single Valued Attribute: Attribute that hold a single value Example1: Age

Exampe2: City Example3:Customer id Multi Valued Attribute: Attribute that hold multiple values. Example1: A customer can have multiple phone numbers, email id's etc Example2: A person may have several college degrees Stored and Derived Attributes The value for the derived attribute is derived from the stored attribute. For example 'Date of birth' of a person is a stored attribute. The value for the attribute 'AGE' can be derived by subtracting the 'Date of Birth'(DOB) from the current date. Stored attribute supplies a value to the related attribute. Stored Attribute: An attribute that supplies a value to the related attribute. Example: Date of Birth Derived Attribute: An attribute thats value is derived from a stored attribute. Example : age, and its value is derived from the stored attribute Date of Birth. Complex Attribute A complex attribute that is both composite and multi valued.

6
Functions of a Database Administrator

One of the main reasons for using DBMS is to have a central control of both data and the programs accessing those data. A person who has such control over the system is called a Database Administrator(DBA). The following are the functions of a Database administrator
y y y y y

Schema Definition Storage structure and access method definition Schema and physical organization modification. Granting authorization for data access. Routine Maintenance

Schema Definition The Database Administrator creates the database schema by executing DDL statements. Schema includes the logical structure of database

table(Relation) like data types of attributes,length of attributes,integrity constraints etc. Storage structure and access method definition Database tables or indexes are stored in the following ways: Flat files,Heaps,B+ Tree etc.. Schema and physical organization modification The DBA carries out changes to the existing schema and physical organization. Granting authorization for data access The DBA provides different access rights to the users according to their level. Ordinary users might have highly restricted access to data, while you go up in the hierarchy to the administrator ,you will get more access rights. Routine Maintenance Some of the routine maintenance activities of a DBA is given below. Taking backup of database periodically Ensuring enough disk space is available all the time. Monitoring jobs running on the database. Ensure that performance is not degraded by some expensive task submitted by some users. Performance Tuning

7
Database Languages

Data Definition Language (DDL) Data Manipulation Language (DML)

Data Definition Language (DDL) We specify the database schema (Data fields , Data Types , Constraints) by a set of definition expressed by a language called DDL. Example: CREATE TABLE student(SNAME CHAR(10), ROLLNO CHAR(10)). This DDL statement creates a table student with fields SNAME and ROLLNO.This information (meta data) is stored in the data dictionary. Data Manipulation Language (DML)

Data Manipulation Language (DML) is used for data manipulation. Data manipulation is Retrieval of Information Stored in Database Insertion of Information to the database Deletion of information from the database Updating of information stored in the databas

Types of Data Manipulation Language (DML) Procedural DML Declarative DML (Non Procedural DML) Procedural DML: In procedural Data manipulation language user has to specify what data are needed and how to get it. Declarative DML (Non Procedural DML): In declarative Data manipulation language user has to specify what data are needed without specifying how to get it. Example : SQL (Structured Query Languages)

LAST Q KA ANS:Data Independence

A major purpose of a database system is to provide the users with an abstract view of data. To hide the complexity from users database apply different levels of abstraction. The following are different levels of abstraction. Physical Level Logical Level View Level Physical Level Physical Level is the lowest level of abstraction and it defines the storage structure.The physical level describes complex low level data structures in detail.The database system hides many of the lowest level storage details

from the database programmers. Database Administrators may be aware of certain details of physical organization of data. Logical Level This is the next higher level of abstraction which describe what data are stored in database, relation between data, types of data etc . Database programmers, DBA etc knows the logical structure of data View Level This the highest level of abstraction. It provides different view to different users. At the view level users see a set of application programs that hide details of data types. The details such as data type etc are not available at this level. Only view or Access is given to a part of data according to the users access right
Physical Data Independence The changes in Physical Level does not affect or visible at the logical level. This is called physical data independence. Logical Data Independence The changes in the logical level do not affect the view level. This is called logical data independence.

2ND LAST KA ANS:A record based data model is used to specify the overall logical structure of the database. In this model the database consists of a no. of fixed formats of different types. Each record type defines a fixed no. of fields having a fixed length. There are 3 principle types of record based data model. They are: 1.Hierarchical data model. 2.network data model. 3.Relational data model. 1. Hierarchical Model The hierarchical data model organizes data in a tree structure. There is a hierarchy of parent and child data segments. This structure implies that a record can have repeating information, generally in the child data segments. Data in a series of records, which have a set of field values attached to it.

It collects all the instances of a specific record together as a record type. These record types are the equivalent of tables in the relational model, and with the individual records being the equivalent of rows. To create links between these record types, the hierarchical model uses Parent Child Relationships. These are a 1:N mapping between record types. This is done by using trees, like set theory used in the relational model, borrowed from maths. For example, an organization might store information about an employee, such as name, employee number, department, salary. The organization might also store information about an employees children, such as name and date of birth. The employee and children data forms a hierarchy, where the employee data represents the parent segment and the children data represents the child segment. If an employee has three children, then there would be three child segments associated with one employee segment. In a hierarchical database the parent-child relationship is one to many. This restricts a child segment to having only one parent segment. Hierarchical DBMSs were popular from the late 1960s, with the introduction of IBMs Information Management System (IMS) DBMS, through the 1970s.

You might also like