DBMS Notes
DBMS Notes
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.
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.
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.
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.
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.
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
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”;
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