03 Database Management System Revision Notes
03 Database Management System Revision Notes
03 Database Management System Revision Notes
REVISION NOTES
DATABASE SERVERS
Database servers are dedicated computers that hold the actual databases and run only the DBMS and
related software.
ADVANTAGES OF A DATABASE/DBMS
The centralised nature of database system provides several advantages, which overcome the
limitations of the conventional file processing system. These advantages are as follows
1. Reduce Data Redundancy: Redundancy means ‘duplication of data’. This eliminates the
replication of data item in different files, extra processing required to face the data item from a
large database. This also ensures data consistency and saves the storage space.
2. Enforcing Data Integrity: It means that, the data contained in the database is accurate and
consistent. Integrity constraints or consistency rules can be applied to database, so that the correct
data can be entered into the database.
3. Data Sharing: The data stored in the database can be shared among multiple users or application
programs.
DISADVANTAGES OF A DATABASE/DBMS
There are many advantages of database, but database also have some minor disadvantages. These
disadvantages are as follows
1. Cost of Hardware and Software: Through the use of a database system, new costs are generated
due to additional hardware and software requirements.
2. Complexity: A database system creates additional complexity and requirements.
3. Database Failures: If database is corrupted due to power failure or it is corrupted on the storage
media, then our valuable data may be lost or the system will stop working.
4. Lower Efficiency: A database system is a multi-user software, which is less efficient.
COMPONENTS OF A DATABASE
A database consists of several components. Each component plays an important role in the database
system environment.
The major components of database are as follows
Data: It is raw numbers, characters or facts represented by value. Most of the organisations
generate, store and process large amount of data. The data acts as a bridge between the hardware
and the software. Data may be of different types such as User data, Metadata and Application
Metadata.
Software: It is a set of programs that lies between the stored data and the users of database. It is
used to control and manage the overall computerised database. It uses different types of software
such as MySQL, Oracle, etc.
Hardware: It is the physical aspect of computer, telecommunication and database, which consists
of the secondary storage devices such as magnetic discs, optical discs, etc., on which data is
stored.
Users: It is the person, who needs information from the database to carry out its primary business
responsibilities.
TYPES OF USERS
The various types of users which can access the database system are as follows
WORKING OF A DATABASE
Database is created to operate large quantities of information by input, store, retrieve and manage the
information. It is a centralised location which provides an easy way to access the data by several
users. It does not keep the separate copies of a particular data file still a number of users can access
the same data at the same time.
As the diagram shows, DBMS works as an interface between the user and the centralised database.
First, a request or a query is forwarded to a DBMS which works (i.e. a searching process is started on
the centralised database) on the received query with the available data and if the result is obtained, it
is forwarded to the user.
If the output does not completely fulfill the requirements of the user, then a rollback (again search) is
done and again search process is performed until the desired output is obtained.
DATA INTEGRITY
Data Integrity ensures the accuracy, reliability and consistency of the data during any operation.
Each type of data integrity are as follows
Entity Integrity: It defines the primary key of a table. Entity integrity rule on a column does not
allow duplicate and null values.
Domain Integrity: It defines the type, range and format of data allowed in a column. Domain
integrity states that all values in a column must be of same type.
Referential Integrity: It defines the foreign key concepts. Referential integrity ensures that data
in related tables remains accurate and consistent before and after changes.
User Defined Integrity: If there is some business requirements which do not fit any above data
integrity then user can create own integrity, which is called user defined integrity.
Candidate Key: The set of all attributes which can uniquely identify each tuple of a relation are
known as candidate keys. Each table may have one or more candidate keys and one of them will
become the primary key. The candidate key of a relation is always a minimal key. e.g. Column
StudentId and the combination of FirstName and LastName work as the candidate keys for the
student table.
A candidate key must possess the following properties
For each row, the value of the key must uniquely identify that row.
No attribute in the key can be discarded without destroying the property of unique
identification.
Alternate Key: From the set of candidate keys after selecting one of the keys as a primary key, all
other remaining keys are known as alternate keys. e.g. From the candidate keys (StudentId,
combination of FirstName and LastName), if StudentId is chosen as a primary key, then the
combination of FirstName and LastName columns work as alternate keys.
Foreign Key: A field of a table (relation) that references the primary key of another table is referred
to as foreign key. The relationship between two tables is established with the help of foreign key. A
table may have multiple foreign keys and each foreign key can have a different referenced table.
Foreign keys play an essential role in database design, when tables are broken apart, then foreign keys
make it possible for them to be reconstructed. e.g. CourseId column of student table (reference table)
works as a foreign key as well as a primary key for course table (referenced table).
Data in a relational database management system (RDBMS) is organized in the form of tables.
DATABASE OBJECTS :
1) Table: A table is a set of data elements (values) that is organized using a model of vertical
columns and horizontal rows. A table has a defined number of columns, but can have any number
of rows. Each row is identified by the values appearing in a particular column identified as a
unique key index or the key field.
2) Columns or Fields or Attributes: A column is a set of data values of a particular simple type,
one for each row of the table. The columns provide the structure according to which the rows are
composed. For example, cFirstName, or cLastName are fields in a row.
3) Rows or Records or Tuples: A row also called a Record or Tuple represents a single data item in
a table. Each row in a table represents a set of related data, and every row in the table has the
same structure.
CREATE TABLES:
Tables are the basic building blocks of a database. You store the data in the database in the form of
tables.
There are different ways to create a table:
DATA TYPES:
Datatypes are used to identify which type of data (value) we are going to store in the database. Data
types in OpenOffice base are broadly classified into five categories listed below.
Numeric Types
Alphanumeric Types
Binary Types
Date time
Other Variable types
Numeric Types: Numeric data types in a database can be used for storing information such as mobile
number, roll number, door number etc. The different types of numeric data types available are listed
here.
Binary Types: Binary data types are used for storing data in binary formats. Binary data types in a
database can be using for storing photos, music files, etc.
Date time: Date time data types in a database can be used for storing information such as date of
birth, date of admission, date of product sale, etc.
FIELD PROPERTIES:
To set the field properties: Select the table > Right click > Select the option Edit > the table will open
in Design View.
In design view there are different properties of fields according to the data type set for each field.
SORTING DATA: Sorting means to arrange the data in either ascending order of descending order.
REFERENTIAL INTEGRITY:
Referential integrity is used to maintain accuracy and consistency of data in a relationship. In Base,
data can be linked between two or more tables with the help of primary key and foreign key
Referential integrity helps to avoid:
1) Adding records to a related table if there is no associated record available in the primary key table.
2) Changing values in a primary if any dependent records are present in associated table(s).
3) Deleting records from a primary key table if there are any matching related records available in
associated table(s).
You can create a relationship between any two tables by selecting Relationships option from the
Tools menu.
There are three types of relationships which can be created in tables:
1) ONE to ONE Relationship: In this relationship, both the tables must have primary key columns.
2) One to Many Relationship: In this relationship, one of the table must have primary key column.
3) Many to Many Relationship: In this relationship, no table has the primary key column.
SELECT STATEMENT :
A SELECT statement retrieves zero or more rows from one or more tables. SELECT is the most
commonly used Data Manipulation Language(DML) command. To retrieve all the columns in a table
the syntax is: SELECT * FROM <Table Name>;
For example, if you want to display all the data from table emp (short form of employee), the
command is
The above query will show result of a particular employee named “Ravi”.
Select * from emp order by Salary;
The above query will show all the records of table emp according to ascending order of column
Salary.
PERFORMING CALCULATIONS :
In Base, simple calculations can be done on the data using arithmetic operators. Example:
1) To display the salary of all the employees after incrementing by 1000 then the following SQL
command will be executed in Base. (Fields of table Employee are EmployeeID, FirstName, Salary)
Select “EmployeeID”, “FirstName”, “Salary” +1000 from “Employee”;
UPDATE STATEMENT :
Update statement is used for modifying records in a database. The general syntax of the update
statement is as follows:
UPDATE <table name> SET <Column name > = value [WHERE <Condition>];
for example :
1) To increase(update) the salary of employee “Ravi” by Rs 2000 (in table Employee)then the SQL
command will be:
Update Employee set Salary = Salary + 2000 Where FirstName = “Ravi”;
Creating Form Using Wizard : Steps To Create Form Using Wizard are :
1) Click Use Wizard to Create Form… option under Tasks group. The Form Wizard dialog box
appears.
2) Select selective fields to be sent onto the form by selecting the field name and clicking >button
and click Next.
3) Select the option Add Subform if you need to insert the contents in the table in a separate form
and click Next.
4) Arrange selected fields in a form and click Next.
5) Select the data entry mode and click Next.
6) Specify the styles to be used in the form and click Next.
7) Specify the name of the form. Click Finish.
REPORT: A report helps to display the data in a summarized manner. It is used to generate the
overall work outcome in a clear format.
Creating Reports using wizard : Steps To Create Report Using Wizard are :
1) Click on Use Wizard to Create Report… option available under Tasks.
2) Select all the table fields by selecting the >> button.
3) Redefine the label of the fields in the reports or else you can set the default name and click Next.
4) Define grouping for the fields of the table if required and click Next
5) Sort the field in the report by selecting the appropriate field name and sorting method(if required)
and click Next.
6) Select the layout of the report and click Next.
7) Define a name for the report and click Finish.