0% found this document useful (0 votes)
3 views19 pages

Labwork-6- database

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 19

A database is a collection of related data that is organized so that you can easily view

the data
.Software like libre Office Base,MS Access,Oracle,SQL server etc are most commonly used
for data- base management.
While designing this database a clear understanding of the following is required.
• Type of data to be stored
• Size and volume of data to be handled
• Type of users and their requirements
• Frequency of data mobility (ie., data capturing, modification & retrieval)
• Type of data network used for data access (LAN/WAN).
• Data security requirements.
• Evolution of Databases
Databaseshaveevolvedearlyduringthe1960s.
Theywereintheformofhierarchicalandnetwork databases. In
1970stheeraofrelationaldatabase managementstarted. Laterduring
Used1980stheyturnedoutas
as desktop database or object-
serverorienteddatabases.
database
DataBase Management System (DBMS) : It is a software application that facilitates
interaction with administrators, end users, other applications, and to the database itself to
capture and analyse data. Usually DBMS allows the creation, storage, updation, and
maintenance and administration of databases
LOGICAL STRUCTURING OF DATA IN TABLES
In a database management system, the information is stored in database in the forms
of table having data fields and attributes.
Entities :Anything which has a real life existance is called an entity.It may be a
person,place or thing.
Eg:-Student is an entity
Attributes:These are characteristics of
an entity.
Eg:- Name,Class,Date of Birth,Catagory etc
Identifiers :An entity may have different attributes,but one among them shall be unique
which can be called an identifier.This is also called PRIMARY KEY.
Relational database:
A relational database refers to a database in which data is stored in multiple tables.
These tables are linked to one another through common fields. It consists of collection of
schemas, tables, queries, reports, views and other elements
CREATING DATABASE
Step 1: To start the LibreOffice Base, click on the Application Menu and point to Office; then
click Libre Office Base. ( Application Office LibreOffice Base ).
Step 2: Select Database - Select Create a new database option and click on Finish button.
Then we get Save dialogue box
Step 3: Type appropriate file name . The default extension of LibreOffice Base “.odb” will be
automatically added by the application. select location and click on Save
Opening an Existing Database
Step 1 : Open LibreOffice Base, from the Database wizard select Open an existing database
file option and click on open button.
HSQLDB {Hyper SQL Data base) is a relational database management system
written in Java.
HSQLDB provides a rich set of data types to build our database. 4
2019-2
Ste
p 2 : Choose the file from the destination and click Open.
COMPONENTS OF BASE
1) Table : Rows and columns to present the data in the database—rather like a
spreadsheet
2) Query : makes a request to the database,asking it to find for you some data, are
stored in the database
3) Form : It is a graphical interface, which allows the user to display the data in a
table or query. Through a form, the user can add new data into the table, delete or edit
existing data
4) Report : It is used to present a selected set of contents from the database in a
format that is easilyreadable
CREATING DATABASE TABLE
Click on Tables component’ in the panel. This provides three options
Create table in Design View : This option is used to create a table by specifying the field
names and properties, as well as the data types.
Use Wizard to create Table : This option allows choosing from a selection of business and
table samples, which we can customise to create a table.
Create view : This option can be selected for creating tables and field names of our choice
and the same could be made visible.
Creating Table in Design view
1. Click Tables from Database pane.
2. Click Create Table in Design View in Tasks area

The Design View of the new table will appear in the working area of the
window In Design View, we can see three columns viz, Field Name, Field
Type and Description
In the Design view, we can now create required fields for our table.
● Click the Field Name cell and enter a field name for each data field. Eg. EmpId.
Enter new fields from top to bottom
● Right click on the Field Name required to set as unique identifier for the table, select
Primary Key
option from the pop-up menu.
● In the Field Type, we can select a appropriate field type from the combo box for the
each fields.
● In Description field, we can enter a brief description for each attributes. It is optional.
● Besides the Field type, there are several other properties that can be set
independently for each field. Appearing as ‘Field Properties’ at bottom part of the design
view, these parameters of a field will vary with the choice of data type.
● Save the table by providing table name and again Save the Database by clicking
Menu or Tool
RELATIONSHIPS
Relationship are used for connecting tables in database to get the advantage of data
redundancy.
5
2019-2
H
aving completed the designs of all data tables, we will now move on to the task of
establishing relationships between different tables. Click on the Tools Menu and then
Relationships...menu
Meaning of Data Types
In Computer Programming, a data type is simply a classification of data. Data types
define particular characteristics of data that we intend to store or manipulate.

CREATION OF FORMS
In a database context, a form is a window or screen that contains numerous fields, or
spaces to enter data. Each field holds a field label so that any user who views the form gets an
idea of its contents
Methods of creating forms
● Use Wizard to create form
● Create Form in Design View
Creating Forms using wizard :

Under the form component, click on the


“Use Wizard to Create Form”. The following Form Wizard window appears
Select the Table or Query, Add sub-form, Arrange controls, Select
the data entry mode, Applying style of your form, Set the name of the Form, Then click
Finish button Modifying the Form.
In order to change lables,apperance or to set field properties , the form need
necessarily be opened in Design Mode. Use the following procedure.
Right Mouse Clickon Form name-> Edit
51
2019-20
Create Form in Design View
Click-on “ Create Form in Design View”
This opens up a Design page with enhanced tools designed to build samrt forms

Enter a Title to the Form :


Click on Label tool Drag and drop on an empty space. Right Click-on the label box
Click Control Open Properties Window Change Label, Font, Font size
etc.
Connecting Tables with Form :
Data entered through the form will not be added unless the form is connected with the
data tables How to set up connection with tables
Right Click Form Form Properties
Click-on Data Tab Content type
Table Content Click and select required
table name
Adding Labels and Text Boxes
Click on Label Tool Mouse pointer Changes to a plus (+) sign
Move the mouse to an empty area Drag and draw and drop rectangular like label
boxes
one by one.Right Click Control Label Properties Change Lable, Font ,style,size colour
etc
Adding Text Boxes
Click on Text Box Tool Mouse pointer Changes to a plus (+)
sign Move the mouse to an empty area
Drag and draw and drop rectangular like text boxes one by
one. Right Click Control Textbox Properties
Set up text box properties such as Font , style , size color etc
Click-on Data Tab Data Fied Click to pop up avalable field
list Click and select required Field.
Follow these steps to set properties for each text box
Adding List Boxes
A list box helps to select a value from among a list of values, by limiting erroneous
entries.
Click on List Box Tool Mouse pointer Changes to a plus (+)
sign Move the mouse to an empty area
Drag and draw and drop rectangular like list
box Right Click Control
Click on Data Tab
Data Field: specify the name of the data field to contain
selection Input requied : Yes
Type of List Contents: Value List
List Content : Type option_1, hold down shift key + enter Key to type other
value. Press enter key at the end.
General tab List Entries click and type options inside.
For each press Shift+Enter key,and for the last option press Enter key only Save and close the
wizard Switch the design mode off and see the changes reflected.
Working with Sub Forms
A sub form is a form inserted in to a Main Form, which works together with it. Sub
Forms are used to input data into tables or show data from table or queries with one- to -many
relationships.
Adding Push Buttons
A push button is a visual representation of a button that executes a task when clicked
or pressed. There will be some instructions attached to these buttons. On execution of these
instructions it will perform a specific task.

Click on Push Button Tool Mouse pointer Changes to a plus (+) sign
Move the mouse to an empty area
Drag and draw and drop rectangular like push button boxes one by one.
Right Click Control Properties Click on General Tab
Change or set up push button properties such as label ,Font ,style ,size colour etc
General Tab Action (scroll down to see and locate “Action” in the property box)
Click on Action pop up with list of action appears.
Select the required action from among the list (New Record, Delete Record, List record
etc..)
CREATION OFQUERY

A query is a request for data or information


from a database and query languages are used to make queries in database. Queries are also
used to manipulate the database content. Structured Query Language (SQL) is the most well-
known and widely-used query language. LibreOffice Base also uses SQL commands for
querying its database.
Running Queries
A query is run from the Edit menu by clicking run query option or by selecting ‘Run
Query’ button from the tool bar or by pressing the F5 key.
CREATION OF REPORTS
Information from a database can be generated through the Reports option .The
reports can be printed , it allows to design the layouts and formats as per the requirements of
user. It can be edited, printed and exported to PDF format.
Reports can be static or dynamic.
1 Static Reports : Static reports are meant to present information that is not likely to change
over time. The system retrieves data from database at the time the report was created, and
there after the information in a static report does not get updated.
2 Dynamic Reports : Dynamic Reports are meant to present information that changes over
time. Dynamic reports always get updated to show the latest changes in data.
LAB WORK 31
1. Enter the following in a database table with the file name Emp_details.
EMP_ID EMP_NAME EMP_SE EMP_BASICPA
X Y
100 ARUN M 30000
101 NISHA F 60000
102 ANIL M 40000
103 ROOPA F 80000
a) Display the name of employees drawing BASICPAY greater than or equal to 60000.
b) Display the name of employees begin with ‘A’.
2019-20 53
Procedure
Step 1: Open LibreOffice Base
Application Office LibreOffice Base
Step 2 :Click Create new data Base, and click finish
button, to save the file,give the file name
Step 3: In the left pane click on the icon ‘Tables’ and
below the Tasks section click on ‘Create Table
in Design View’. This will open the table
creation screen.
Step 4: Set ‘emp_id’ as primary key
Right Click on the row selector of
emp_id and select the ‘Primary Key’
Step 5: Enter‘TblEmp_details’in Save dialogue
box Then close the Table Creation screen
we can see the created table under the head
‘Tables’ Double click on this to open it in
Data View mode. and Enter the details

Step 6: Making the Query:


In the left pane of the database window, click on the Queries button and click on
‘Create Query in Design View’. This will open a Add Table or Query window.
Add the table,‘TblEmp_details’.Then close the window.

Ste
p 7: Add all fields into different columns of Query Design
grid Step 8: Against the criteria in the ‘emp_basicpay’
field,enter >=60000 Step 9: Press F5 or click on Run Query
Button to display the result.
Step 10: Against the criteria in the ‘emp_name’ field,enter LIKE'A*'
Step 11: Press F5 or click on Run Query Button to display the result.
OUTPUT
a)Name of employees drawing BASICPAY greater than or equal to 60000

LAB WORK 32

Create a database table named TABLE_EMPLOYEE and enter the following details using a
form.
EMP_ID EMP_NAME BP HRA
1001 MAJEED 10000 1500
1002 ABHILASH 20000 1500
1003 SUNIL 30000 1500
Also create a query to display EMP_NAME and BP.
54
Procedure
Step 1:Tables Create Table in Design View
This will open the table creation screen.Enter the following field and Data types
EMP_ID EMP_NAME EMP_BP HRA
Text:[VARCHAR] Text:[VARCHAR] Number[Numeric] Number[Numer
ic]
Step 2: Set emp_id as primary key
Step 3: Enter‘Tblemployee’in Save as dialogue
box Step-6 : Forms ‘Use wizard to create a
Form’.
This will open a Form Wizard window
In the Form WizaRd Dialogue box ,select the table’Tblemployee under Table/Query field.
Select all fields using a mouse click at double arrow sign (>>) and then click next and
finish
Form

A data entry form will be displays

OUTPUT

Queries Create Query in Design View


Add the table,’tblemployee’.Then close the
window. Run Query Button to display the
result.
LAB WORK 33
Create STUDENT table in database with the following fields.
Field name Data type Field width
STUD_NO Text 5
STUD_NAME Text 25
SEX Text 1
PLACE Text 20
CLASS Text 10
(Hint: Classes are Science, Commerce and Humanities)
c) Enter six records with imaginary details.
d) Prepare of report of students from commerce class.
Procedure
Step 1:Tables Create Table in Design View
This will open the table creation screen.Enter the field and Data types as
above table Step 2: Set STD_NO as primary key
Step 3: Enter‘TBL_STD’in Save as dialogue box
Step 4: Open the table ‘TBL_STD’in Data View mode and enter imaginarydetails for anysix
students. Then close the table
Step 5 : Making the Query:
Queries Create Query in Design View
Add the table,’TBL_STD’.Then close the window.
Step 6: Add all fields into different columns of Query Design grid
Step 7: Against the criteria in the ‘CLASS’ field,enter COMMERCE
Step 8: Press F5 or click on Run Query Button to display the result and Save the
query’Qrystd’ Step 9: Making Report
Report Use Wizard to create a Report’. This will open a Report Wizard.
Step 10: In Field Selection step, under Tables or Queries, select Qrystd. Select all
fields using
a mouse click at double arrow sign (>>) and then click next and finish.A report will be displays

OUTPUT

LAB WORK 34
Create database tables named EMPLOYEE and PAY_DETAILS with the Following field
names.
TABLE NAME FIELDS
EMPLOYEE EMP_ID, EMP_NAME,
EMP_SEX
PAY_DETAILS EMP_ID, BP,DA,HRA
Create relationship between these two tables.
Procedure
Step 1 : In the database window select tables and click create table in design view' under the
the tasks section. Atable creation screen will be opened.
Step 2 : Enter the field name and field types
Field Name Field
Type EMP_ID
TEXT[VARCHAR] EMP_NAME
TEXT[VARCHAR] EMP_SEX
TEXT[VARCHAR]
Step 3 : EMP_ID as primary key. Save table name as 'EMPLOYEE' and
close it Step 4 : Create another Table in Design View with the following
fields
Field name Field
Type EMP_ID
TEXT[VARCHAR]
BP NUMBER[NUMERIC]
DA NUMBER[NUMERIC]
HRA NUMBER[NUMERIC]
56 Step 5 :Set Emp_ID as Primary Key and save it as 'Pay_Details'
Step 6 : Create Relationship between the tables Tools Relationship
Add both tables to the relationship window and close the dialogue box.
Step 7 : In the Relationship window click on EMP_ID field of one table and drag and drop on to
the EMP_ID field of other table. Then a connecting line is formed between these two tables,
which indicates the relationships between these two tables.
Step 8: Click ' save' button and close the window

OUTPUT
LAB WORK 35
From the following details calculate Total cost and profit/lost of each quarter for the
year 2016 - 2017 by using appropriate query.
QUARTE SALE COST ADM_EXP SELLING_ EXP TOTAL_COST PROFIT_LOSS
R S
Q1 8000 4500 5000 2000
0 0
Q2 6000 3500 5000 3000
0 0
Q3 5000 3000 6000 4000
0 0
Q4 4000 300 7000 5000
0 00
Procedure
Step 1 : In the database window select tables and click create table in design view' under the
the tasks section. Atable creation screen will be opened.
Step 2 : Enter the field name and field types
Field Name Field Type
QUARTER TEXT[VARCHAR]
SALES NUMBER[NUMERIC]
COST NUMBER[NUMERIC]
ADM_EXP NUMBER[NUMERIC]
SELLING_ EXP NUMBER[NUMERIC]
Set QUARTER as primary key. Save table name as ‘TBL_SALES’ and close it
Step 3: Open the table’ TBL_SALES’ and enter the sales and cost details of each quarter as
seen in the question.
Step 4 : Create query
In the database window ,click on the queries button and under the task section, click
‘create queries in design view’
Step 5 : Select the table ‘TBL_SALES’ and click add button. Close the
window. Step 6 : Select all the fields by double clicking on it.
Step 7 : In the next column against the field ,type the formula to calculate TOTAL COST
“COST” + “ADM_COST” + “SELLING_EXP”
and in the ‘alias’ column, type ‘TOTAL_ COST’
Step 8 : In the next column against the field, Type the formula to calculate Profit or Loss
“SALES”-(“COST” + “ADM_COST” + “SELLING_EXP”)
and in the ‘alias column , Type ‘PROFIT_LOSS’
Step 9 : Press F5 or click on Run Query button to display the result
OU
TPUT
QUESTIONS
1. ’DBMS’stand for
● Data Base Managemnt System
2. The common fields used in a relationship between tables are called........................
● Key
field 3.SQL stands
for:
● Structured Query Language
4. The default extension of Libre OfficeBase file is...........................
● .odb
5. ’Join Line’in the context of Libre OfficeBase Table means
● Graphical representation of relationship between tables
6. To expect a well formatted printable data from Libre OfficeBase database,we may use
● Report
7. The data type suitable to the age of a person is:
● Number (Numeric)
8. The data type suitable to the name of a person
● Text:[VARCHAR]
9. The data type suitable to basic pay of employee
● Number (Numeric)
10. The blank columns that represent columns in the Query results datasheet are called:
● Design Grid
11. The results of Query can be displayed by clicking on
● Run
Button 12.ODBC
stands for
● Open Database
connectivity: 13.Different ‘views ‘of
a form
● Form view, Layout view, Design
view 14.In design view,name of columns
are:
● Field name, Data type
15. In datasheet view,what appears at the top of each column
●Field name
16. Name of database object to hold data
● Table
17. What field type is used to store picture in a table
● OLE object
18. What criteria is used to get return a text starts with S
● LIKE'S*' Simple Criteria for
19. A query criteria like '*Bimal*' returns
Criteria all names that Function
Format
Name LIKE'*x*' Searches for all values that
Contains LIKE'x*' contain x Searches for all values
Begins LIKE'*x' beginning with x Searches for all
Contains Bimal
58

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy