0% found this document useful (0 votes)
42 views17 pages

DBMS Part 3

The document discusses SQL commands and the different types of SQL commands - DDL, DML, DCL, and TCL. It provides examples of commands that fall under each type and descriptions of how each type of command is used. It also discusses how to create forms and queries in LibreOffice Base using the wizard or design view, and the steps involved in each method. Finally, it provides a brief overview of how to create reports in Base.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views17 pages

DBMS Part 3

The document discusses SQL commands and the different types of SQL commands - DDL, DML, DCL, and TCL. It provides examples of commands that fall under each type and descriptions of how each type of command is used. It also discusses how to create forms and queries in LibreOffice Base using the wizard or design view, and the steps involved in each method. Finally, it provides a brief overview of how to create reports in Base.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

VELAMMAL VIDYALAYA

X – INFORMATION TECHNOLOGY (402)


DATABASE MANAGEMENT SYSTEM

SQL Commands

🔾 SQL commands are instructions. It is used to communicate with the


database. It is also used to perform specific tasks, functions, and queries of data.

🔾 SQL can perform various tasks like create a table, add data to tables, drop
the table, modify the table, set permission for users.

Types of SQL Commands

There are five types of SQL commands: DDL, DML, DCL, TCL

1. Data Definition Language (DDL)

🔾 DDL changes the structure of the table like creating a table, deleting a
table, altering a table, etc.
🔾 All the command of DDL are auto-committed that means it permanently
save all the changes in the database.
Here are some commands that come under DDL:
🔾 CREATE
🔾 ALTER
🔾 DROP
🔾 TRUNCATE
2. Data Manipulation Language

🔾 DML commands are used to modify the database. It is responsible for all
form of changes in the database.
🔾 The command of DML is not auto-committed that means it can't
permanently save all the changes in the database. They can be rollback.
Here are some commands that come under DML:
🔾 INSERT
🔾 UPDATE
🔾 DELETE
3. Data Control Language

DCL commands are used to grant and take back authority from any database user.

Here are some commands that come under DCL:

🔾 Grant

🔾 Revoke

a. Grant: It is used to give user access privileges to a database.

Example

1. GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;


b. Revoke: It is used to take back permissions from the user.

Example

1. REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;

4. Transaction Control Language

TCL commands can only use with DML commands like INSERT, DELETE and UPDATE
only.

These operations are automatically committed in the database that's why they cannot
be used while creating tables or dropping them.

Here are some commands that come under TCL:

🔾 COMMIT
🔾 ROLLBACK

🔾 SAVEPOINT

a. Commit: Commit command is used to save all the transactions to the database.

Syntax:

1. COMMIT;
Example:

1. DELETE FROM CUSTOMERS


2. WHERE AGE = 25;
3. COMMIT;
b. Rollback: Rollback command is used to undo transactions that have not already
been saved to the database.

Syntax:

1. ROLLBACK;
Example:

1. DELETE FROM CUSTOMERS


2. WHERE AGE = 25;
3. ROLLBACK;
c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling
back the entire transaction.

Syntax:

1. SAVEPOINT SAVEPOINT_NAME;
BUILDING FORMS

Using the Wizard to create a form

Step 1: Select fields.

1. Under Tables or queries, select Vacations as the table. Available fields lists the
fields for the Vacations table.
2. Click the right double arrow to move all of these fields to the Fields in the form
list. Click Next.

Step 1: Select fields.

1. Under Tables or queries, select Vacations as the table. Available fields lists the
fields for the Vacations table.
2. Click the right double arrow to move all of these fields to the Fields in the form
list. Click Next.

Step 3: Add subform fields.

This step is exactly the same as step 1. The only difference is that not all of the fields
will be used in the subform.
1. Select Fuel under Tables or queries.
2. Use the >> button to move all the fields to the right.
3. Click the FuelID field to highlight it.
4. Use the < button to move the FuelID to the left (Figure 23).
5. Click Next.

Step 4: Get joined fields.

This step is for tables or queries for which no relationship has been defined. Since we
want to list all expenses by the day they occur in both the form and subform, we will
join the Date fields of these two tables (Figure 24).

Step 5: Arrange controls.

1. Arrangement of the main form: Click Columnar - Labels on top. (The labels will
be placed above their field.
2. Arrangement of the subform: Click As Data Sheet. (The labels are column
headings and the field entries are in spreadsheet format.) Click Next.

Step 6: Set data entry.

Unless you have a need for any of these entries to be checked, accept the default
settings. Click Next.

Step 7: Apply styles.


1. Select the color you want in the Apply Styles list. (I chose the beige which is
Orange 4 in the Color table.)
2. Select the Field border you want. (I prefer the 3-D look. You might want to
experiment with the different possible settings.)
3. Click Next.

Step 8: Set name.


1. Enter the name for the form. In this case, it is Fuel.
2. Click the circle in from of Modify the form. (This circle is called a radio button.)
3. Click Next. The form opens in Edit mode.
Creating forms

In LibreOffice Base you can create a Form using:


● Create a Form in Design View. Using this method you create a form from
scratch, having complete control of the form design. This option is suitable for
more advanced users.
● Use Wizard to Create Form. The Wizard guides you through a step by step
process to create the form. Unlike tables and queries, creating a form from
scratch is difficult for beginners. Therefore this is the recommended method to
create a form.
Select Use Wizard to Create Form form the Tasks window to start creating a form.
Step 1
The Form Wizard window appears. In this step you select the fields that the form must
contain. Select all the fields from table Books except the ID. The ID field is filled
automatically every time we create a new record.

Step 2
In relational databases a table can connect to another table and similarly a form can
contain a subform. Skip this step now because our database is flat and does not have
any relations.
Step 3
In this step we choose the form layout or arrangement. Click on all available options to
preview the result. For this form choose the Columnar - Labels Left layout.

Step 4
In this step we specify the data entry mode. You can create for example a form that the
user can only add records but not modify existing ones. In our example we will leave
the default options so that the form user has full rights.
Step 5
In this step you can quickly style the form using one of the predefined styles. Choose a
style (Bright Blue for example) and click Next.

Step 6
In this step we set the name of the form and how we want to proceed after creating the
form. Name the form Books or BooksForm and Choose Work with the form.
Using the Form
Navigating
When we open the Form it displays each record according to the chosen layout. Using
the navigation toolbar on the bottom we can navigate to each record of the table. The
toolbar on the bottom displays also the current record.

Creating and modifying a record


To add a record click on the Add New Record button on the navigation toolbar and
fill in the form fields. To modify or update an existing record simply edit one or more
field values. In both cases you must save your changes by pressing the Save Record
button .
Managing a form
To manage a form click on the Forms object type in Database pane and select the
form from the Forms pane. Use the Form toolbar to Open, Edit, Delete or Rename a
form.

Creating a query

LibreOffice Base allow us to design, execute and store a query. You can create a query
with one of the following ways:
● Create a Query in Design View. This method allows us to design a query
from scratch. Use this method because it will help you undestand the comcept of
queries.
● Use Wizard to Create a Query. The wizard will guide you to create a query
from a selected table.
● Create a Query in SQL View. SQL stands for Structured Query
Language. SQL is the standard language for relational database management
systems. If you want to really dive into databases you should learn the SQL
language. This lesson however does not cover SQL.
To create a query select the Queries object from Database objects types and click on
the Create Query in Design View Task.

A query needs at least one table or another query where it can retrieve the data. Select
the Books table from the list to add it to the query.

Once you add the table close the Add Table or Query window. Now the Query Design
window appears. The upper part of this window displays the data sources where the
query retrieves data from. In the bottom part we set the query parameters.
Query parameters
Let’s now for example design a query that will ask the question: What books are
available in my library? Show me the title and author of these books. To design a query
we must specify it's parameters:
● Fields. The table fields to show in query results or use in the query's
criteria.
● Sorting. You can specify sorting for the results by one or more fields.
● Criteria. This is where we actually set the conditions for the query. We can
set multiple criteria in a query.
● Visible. If enabled the field will be visible in query results.
For our query we set the following query parameters:

Reports

Reports give you the ability to present information from your database in an easy-to-
read, visually appealing printable format. For example, you can create a simple report
of phone numbers for all your contacts, or a summary report on the total sales across
different regions and time periods. Base makes it easy to create and customize a report
using data from any query or table in your database.
Creating Reports
In LibreOffice Base you can create a Report using
● Create a Report in Design View. Create a report from scratch.
● Use Wizard to Create Report. The Wizard guides you through a step by
step process to create the report. Unlike tables and queries, creating a report
from scratch can be difficult for beginners. Therefore this is the recommended
method for to quickly and easily create a report.
Select the Use Wizard to Create Report. The Wizard opens a dialog window. In the
following example we will generate a report that displays all book's title, author and
publishing date. The results will be grouped by author.

Step 1
In this step you select the Table Fields that you want the report to contain. In this
example we select the Title, Author and PublishingDate fields.
Step 2
The report generates a label for each field. By default Base chooses the field name for
the label name. In our example we change the "PublishingDate" field to "Publishing
Date".

Step 3
A report can group the results by one ore more fields. In our example we choose to
group the results by Author.

Step 4
As with queries, the results in reports can be sorted. By default results are sorted by
the group field (Author). You can specify more levels of sorting. Leave the default values.
Step 5
In this step we choose the Layout for the data and the headers and footers of the report.
Click on the available options to preview each layout.

Step 6
Here we specify the title and the type of the report. A dynamic report generates data
from the current table data. This means that if we update data on the table that feeds
the report, the report will change accordingly.
When you finish the wizard the report will be created and opened. The report is text
document and therefore it opens using the Writer component of LibreOffice.

Managing a Report
To manage a Report first select the Reports Object from the Database Objects Pane and
then select the report from the Reports List. Use the Reports toolbar to Open, Edit,
Delete or Rename a Report.
1. Expand DDL, DML, DCL, TCL
2. Differentiate alter and update command
3. command used to view all records of a table

You might also like