Labwork-6- database
Labwork-6- database
Labwork-6- database
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 :
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
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
OUTPUT
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