0% found this document useful (0 votes)
48 views14 pages

DBMS Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views14 pages

DBMS Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Relational Database Management System (RDBMS)

Database – A database is an organized collection of data. For example:- In a


stationary shop, detailed records of the materials available in the shop is
database. Similarly in a computerized system, we need to maintain several
files, we would used database programs such as Microsoft Access,
OpenOffice.org Base, and MySQL. These database programs are used to
organize the data as per our needs in the computer system.
Database Management System (DBMS) - A database
management system is a software package with computer programs that
controls the creation, maintenance and use of a database. A DBMS allows
different user application programs to concurrently access the same
database. Some of the DBMSs are Oracle, IBM DB2, Microsoft SQL server,
Microsoft Access, PostgreSQL, MySQL, FoxPro and SQLite.
Advantages of Database
1.Reduces Data Redundancy : no chance of encountering duplicate
data
2.Sharing of Data : the users of the database can share the data among
themselves
3.Data Integrity : Data integrity means that the data is accurate and
consistent in the database
4.Data Security : Only authorised users are allowed to access the
database and their identity is authenticated using a username and password
5.Privacy : The privacy rule in a database states that only the authorized
users can access a database according to its privacy constraints
6.Backup and Recovery : Database Management System automatically
takes care of backup and recovery.
7.Data Consistency : Data Consistency means there should be multiple
mismatching copies of the same data
Data can be organized into two types:-
1.Flat File: Data is stored in a single table. Usually suitable for less
amount of data.
2.Relational: Data is stored in multiple tables and the tables are
linked using a common field. Relational is suitable for medium to
large amount of data.
Database Servers – Database servers are dedicated computers that hold
the actual databases and run only the DBMS and related software. Databases
on the database servers are accessed through command line or graphic user
interface tools referred to as Frontends; database servers are referred to as
Back-ends. Such
type of data access is referred to as Client-server model.
RDBMS:- A relational database management system
(RDBMS) is a database management system that is based on the relational
model. In the relational model of a database, all data is represented in terms
of tuples (rows), grouped into relations(tables). A database organized in terms
the relational model is a
relational database.
Database Concepts:- Database contains objects that are used for storing
and managing information.
1. Item : - Item is about which information is stored in the
database.
2. Field:- Each question that we ask about our item is a Field.
3. Record:- Record is a set of information (made up of fields)
stored in your database about one of the items.
4. Value:- Value is the actual text or numerical amount or date
that you put in while adding information to your database.
For example, Database : Employee
Emp_Code Emp_Name Emp_Address Emp_Designat
ion Emp_ContactNo Emp_Salary
(E001 ABC Meerut Manager 9876543210 Rs.50000)
Item : Employee
Field : (Emp_Code , Emp_Name , Emp_Address ,
Emp_Designation ,Emp_ContactNo , Emp_Salary)
Record :
(E001 ABC Meerut Manager 987654321 Rs.50,000)
Value : E001 , ABC , Meerut , Manager , 9876543210 , Rs. 50,000
5. Key Field :- Key Field is a value in a Field that uniquely
identifies the record. Eg. E001 which is unique to every employee.
How data is organized in a RDBMS ?
In RDBMS, data is organized in the form of inter linked tables.
1.TABLE :- A table is a set of data elements that is organized
using a model of vertical columns and horizontal rows. Each row
is identified by a unique key index or the key field.
2.COLUMNS OR FIELD :- A column is a set of data values of a
particular simple type, one for each row of the table. For eg.
Emp_Code , Emp_Name , Emp_Address etc.
3.ROWS OR RECORDS OR TUPLES :- A row represents a single,
data items in a table. Each row in a table represents a set of
related data, and every row in the table has the same structure.
DATA TYPES
Datatypes are used to identify the type of data
we are going to store in the database.
Categories of data types:- Data types can be broadly classified
into five categories:-
1. Numeric Types
2. Alphanumeric Types
3. Binary Types
4. Date Time
5. Other variable Types

1.NUMERIC TYPES:- They are used for describing numeric values


like mobile number, age, etc.
The different types of numeric data types available are-
1. Boolean (Yes / No) 6. Numeric
2. TinyInt (Tiny Integer) 7. Decimal
3. SmallInt (Small Integer) 8. Real
4. Integer 9 Float
5. BigInt (Big Integer) 10. Double
2.ALPHANUMERIC TYPES:-
The list of different datatypes available in alphanumeric types
are
1. LongVarChar (Memo) (Long Text)
2. Char (Text-fix) (Small Text)
3. VarChar (Text) (Text of specified Length)
4. VarChar_IgnoreCase (Text) (Comparisions are not case
sensitive)
3.BINARY TYPES:-
Binary types are used for storing data in binary formats. It can be
used for storing photos, music files or (in general file of any
format) etc.
The list of different datatypes available in Binary types are :-
1. LongVarBinary (Image)
2. Binary (Binary (fix)
3. VarBinary (Binary)
4.DATE TIME:-
Date time data types are used for describing date and time values
for the field used in the table of a database. It can be used for
storing information such as date of birth, date of admission etc.
The list of different data types available in Date Time type are :-
1. Date (Stores month, day and year information)
2. Time (Store hour , minute and second information)
3. Timestamp (Stores date and time information)
KEYS
1.PRIMARY KEY:- A primary key is a unique value that identifies a
row in a table. These keys are also indexed in the database,
making it faster for the database to search a record.
2.FOREIGN KEY:- The foreign key identifies a column or set of
columns in one (referencing) table that refers to a column or set of
columns in another (referenced) table.
Note:- The “one” side of a relation is always the parent, and
provides the PK(Primary Key) Attributes to be copied. The “many”
side of a relation is always the child, into which the FK(Foreign
Key) attributes are copied.
Memorize it : one, parent, PK (Primary Key) ; many, child , FK
(Foreign Key)
There are two types of languages:-
1. DDL (Data Definition Language)
2. DML (Data Manipulation Language)
DATA DEFINITION / DESCRIPTION LANGUAGE:-
it is a standard for commands that define the different structures in a
database. DDL statements create, modify and remove database
objects such as tables, indexes and users.
Common DDL Statements are:-
1. Create :- Used to create database objects.
2. Alter :- Used to modify database objects.
3. Drop :- Used to delete database objects.
DATA MANIPULATION LANGUAGE:-
It is a standard for commands that enables users to access and manipulate data in a
database.
Common DML Statements are:-
1. SELECT :- Used for retrieval of information from the database.
2. INSERT :- Used for insertion of new information into the the database
3. DELETE :- Used for deletion of information in the database.
4. UPDATE :- Used for modification of information in the database.

Types of DML:-
1. Procedural:- The user specifies what data is needed and how to
get it.
2. Non Procedural :- The user only specifies what data is needed.
Note:- A popular data manipulation language is SQL (Structured
Query Language.)
consider the below database as an example, to show you how to write commands.
1.CREATE : To create Table
CREATE TABLE Employee_Info
2.DROP : To Delete
DROP DATABASE Employee (complete information
present in the database will be lost)
DROP TABLE TableName (complete information present
in the table will be lost)
3.TRUNCATE Table Employee_Info (your information will be
lost, but not the table)
4.ALTER : This statement is used to add, delete, modify columns in an existing table
ALTER TABLE Employee_Info ADD BloodGroup varchar(255);.
5.INSERT : This statement is used to insert new records into the table.

INSERT INTO Employee_Info VALUES ('02', 'Anay','Soumya', '9432156783', '


Marathalli House No 23', 'Delhi', 'India');
6.UPDATE : This statement is used to modify the records already
present in the table
UPDATE Employee_Info SET EmployeeName = 'Aahana', City= 'Ahmedabad' WHERE
EmployeeID = 1);
CREATING DATABASE USING OPENOFFICE:
1) Open the OpenOffice Base Application by Clicking on
Start>Programs>OpenOffice.org 4>OpenOffice.org Base.
2) Create a new database by selecting the option Create a new database
3) Database wizard appear. Click Finish. The Save As dialog box appears.
4) Specify a name for the database in the File name: field and click Save.

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:
a) Use Wizard To Create Table:
The following are the steps to create a table:
1) Click on Tables > Use Wizard to Create Table
2) Click the Select Fields > Choose Category > Select the table > Click on Next Button.
3) Select the fields as per the requirements. Click on Next button
4) Set the data types and properties of the selected fields. Click on Next Button
5) Set the Primary Key and Click on Next Button
6) Window to rename the table will open. A user can either go ahead with the same
table name or can change it.
7) Click on Finish to insert the data in the table.

b) Creating table using Design View


1) Click on Create Table in Design View.
2) Specify the field name and data type of the field.
3) Save the table by clicking on File > Save
4) Specify the table name. The default name is Table1. Click OK.
5) An alert appears, if there is no primary key in the table.
6) Click yes and set the primary key and finally save the table.
PERFORM OPERATIONS ON TABLE
In OpenOffice Base, data is stored in tables which can be inserted, modified and
removed using appropriate options.

Inserting Data In The Table:


To insert the data in the table, follow the steps:
1) Select the table -> Double click on it.
2) The table will open in Datasheet View.
3) Insert the required number of records in Datasheet View.

Editing Records In The Table:


To edit the data in the table, follow the steps:
1) Select the table -> Double click on it.
2) The table will open in Datasheet View.
3) Edit the required record in Datasheet View.

Deleting Records From The Table:


To remove the data from the table, follow the steps:
1) Select the table -> Double click on it.
2) The table will open in Datasheet View.
3) Select the data -> right click on selected data > select the Delete option

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.

The properties of numeric type data is given below :


1) AutoValue – if set to yes then field will get the auto numeric values.
2) AutoValue – if set to yes then field will get the auto numeric values.
3) Length – By default length of the field is 10 but the size of the field can be set
to maximum length.
4) Default Value – A default value can be set for a field if user don’t provide any
value while entering the values in the table.
5) Format – This property helps to set the format of the data entered in the field such as
91-222-333.

The properties of character type data is shown below :


1. Entry Required – if set to yes then it will be must to insert the value in the field.
2. Length – By default length of the field is 10 but the size of the field can be set to
maximum length.
3. Default Value – A default value can be set for a field if user don’t provide
any value while entering the values in the table.
4. Format – This property helps to set the format of the data entered in the field such
as 91-222-333.

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).

CREATING AND EDITING RELATIONSHIPS BETWEEN TABLES:


A relationship refers to an association or connection between two or more tables.
Relationships between tables helps to:
 Save time as there is no need to enter the same data in separate tables.
 Reduce data-entry errors.
 Summarize data from related tables.

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.
REMOVE THE RELATIONSHIPS:
The relationships applied on the tables can be removed also with the help of Delete
option. Right Click on the relationship thread and select Delete option.

RETRIEVE DATA USING QUERY


A query is to collect specific information from the pool of data. A query helps us join
information from different tables and filter that information
OR
Queries are commands that are used to define the data structure and also to manipulate
the data in the database.

There are two types of languages:-


1.DDL (Data Definition Language)
2.DML (Data Manipulation Language)

1.DATA DEFINITION LANGUAGE (DDL)


DDL is used to define the structure of your tables and other objects in the
database. In DBMS, it is used to specify a database schema as a set of definitions
(expressed in DDL). In SQL, the Data Definition Language allows you to create, alter
and destroy database objects. Basically, a data definition language is a computer
language used to create and modify the structure of database objects in a
database. These database objects include views, schemes, tables, indexes, etc.
This term is also known as data description language in some contexts, as it
describes the fields and records in a database table.

Data definition language consists of various commands that lets you to perform some
specified tasks as follows
1) CREATE: Uses to create objects in the database.
2) ALTER: Uses to alter the structure of the database table. This command can add up
additional columns, drop existing columns and even change the data type of
columns involved in a database table.
3) DROP: Uses to delete objects from the database.
4) TRUNCATE: Uses to remove all records from a table.
5) RENAME: Uses to rename an object.

2.DATA MANIPULATION LANGUAGE (DML)


DML provides various commands used to access and manipulate data in existing
database. This manipulation involves inserting data into database tables, retrieving
existing data, deleting data from existing tables and modifying existing data.
DML is mostly incorporated in SQL database. The basic goal of DML is to provide
efficient human interaction with the system.
The DMLs are of two types
Procedural DMLs These require a user to specify what data is needed and how to get
it.
Non-Procedural DMLs These require a user to specify what data is needed without
specifying how to get it.
Various data manipulation language commands are as follows
1) SELECT: Used to retrieve data from a database.
2) INSERT: Used to insert data into a table.
3) UPDATE: Used to update existing data within a table.
4) DELETE: Used to delete all records from a table, the space of the records remains.
5) LOCK TABLE: Used to control concurrency.

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

Select * from emp;

The SELECT statement has many optional clauses:


 WHERE specifies which rows to retrieve.
 ORDER BY specifies an order in which to
return the rows. for example : Select * from emp
where name = “Ravi”;

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”;

2) To display the salary of all the employees after decreasing by 10000 then the SQL
command will be:
Select “EmployeeID”, “FirstName”, “Salary” – 10000 from “Employee”;
3) To display the salary of all the employees after incrementing it as twice the
amount of present salary, then the SQL command will be .
Select “EmployeeID”, “FirstName”, “Salary” * 2 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 First Name = “Ravi”;

CREATE FORMS AND REPORTS USING WIZARD FORM:


A form provides the user a systematic way of storing information into the database. It is
an interface in a user specified layout that lets users to view, enter, and change data
directly in database objects such as tables.

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.
12
13
14

You might also like