0% found this document useful (0 votes)
7 views22 pages

I.T. Part-B Unit-3

The document provides an overview of Database Management Systems (DBMS), explaining their importance in organizing and managing data efficiently for businesses. It describes different types of databases, including Flat File and Relational databases, and highlights key concepts such as tables, records, and keys. Additionally, it introduces the process of creating a database using LibreOffice Base and the functionalities it offers.

Uploaded by

ovistar.2009
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)
7 views22 pages

I.T. Part-B Unit-3

The document provides an overview of Database Management Systems (DBMS), explaining their importance in organizing and managing data efficiently for businesses. It describes different types of databases, including Flat File and Relational databases, and highlights key concepts such as tables, records, and keys. Additionally, it introduces the process of creating a database using LibreOffice Base and the functionalities it offers.

Uploaded by

ovistar.2009
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/ 22

UNIT-II Database ManageMent

Introduction to D
(10 Management system Data
When we go to places like
known as database.
we are often
Collection asked
of data into organized way is
hotel, Bm,y
an provide our membership details which are filled in a register or acoOmput
Why is that information required? It keeps a track of how well and how often we are uusiing the t

strength of a system. The number of people turning up on da


feedbacks express the flaws and doing. Repetitive clients are
considered as valuable
a business is
an idea about how well they continue to visit the place.
benefits so that
are provided few
maintain records manually or in
however large set and
Small businesses
standalone business can spreadsheets
ups like hospitals, banks, corporates have complex system dealing with millions and
of different types of information. If these records are maintained manually, then searching and retie
lot of time, there can be instances of duplicate entries as well
information would take a
Software packages like database management systems allow businesses to manage their data in an
manner. Financial institutions depend on these databases for high level transactions. Ecommerce ve
such as Amazon, bigbasket has databases working at the backend to keep a record of all activiti
the website concurrently and place orders .
performed by the visitors online. Several users log into cauel
management system there is no confusion at all. It is able to handle and execute
database applications like oro
wonder how
simultaneously without breaking. Isn't this amazing? Do you ever
management systems running at the
or Paytm has simplified our lives. With the help of database achieve a lot v
we now have several applications that have made our lives simple and we are alble to
help of a single touch.

DID YOU KNOW ?


1960s. This first
Charles Bachman designed the first computerised database in the early
database was known as the Integrated Data Store, or IDS.

DATABASE MANAGEMENT SYSTEM


Adatabase management system provides a computerized data storing mechanism. Users or ui
Would be allowedto make
can be provided different levels of access. For example, an Admin person theacouts
into
to the records directly, users trying to access the database from a website can log Microsoft
retrieve or change information regarding their personal information. MySQL, DB2, Oracle, coompanies
LibreOffice Base are some of the databases extremely popular with software development
208
management system can be categorized as:
ase 2. Relational
Flat
File
CileDatabase:Flat ile stores the data in two
dimensions - rows and columns. Every row represents a
column represents an attribute of that record. The most common example for aflat file is
every
and excel sheet.
Hle oran
SY database an the other hand has data stored in collection of tables that are related to each other.
ionalstoresrecord in two-dimensional row and column format. Every row has a un
table unique lD or key which
record
identihyinga
in school database will have separate tables for teachers and students of different classes. The
3
PNgmple,
of
teachers and students will have separate
table. Similarly, a separate table will be used to
details table
t a
eCordsfor
abaseServer
machine that is solely dedicated to providing database related services. It is a crucial
serveris a
abase backend related application. All businesses dedicate separate machines for storing important
any line or
entof
The information in these servers are accessed by database expert through a command referred
mation. interface. The graphical user interface is the front end and the database servers are
cal user
thebackend.

antagesof Database x
and efficient interaction with the records.
Database allows quick
Database offers security and accuracy
at the time of execution of a program.
organized manner.
Allowseffective data integration of records of different areas of a business in a very
The possibility
of duplicate or redundant data is greatly reduced.
Allows accurate
datasharing throughout the organization.
Offers privacy and security of data. strategic
productivity as it allows businesses to spend more time on high-value activities and
Increases clearing or scrubbing data.
initiatives. Data is taken care of and no manual effort is required in
decision across an organization.
Allows business leader to take better of data. It is possible to restore
automatic backup and recovery
Database management system allows
failure.
the data in case of system
tures of a Database management system is for any organization. A good
important a Database
OW you have understood how is a must for every
data secure. In today's world DBMS
you to keep the
ase management system allows important features of database management
system.
look at some very tables
zation. Let's have a
form of a table. A database may have one or more
in the up in
Records in a database are stored scenarios are complex and several tables land
real-world
depending on the requirement. Most
the database. tables are
table consists of one type of record. These
manner that each managed.
dbies are created in such a associated with each other and also
thev are the help
eu In a database where uniqueness. Every row can be identified withidentifying
Ese management
system maintains record that stores unique value that
helps in
can be a column
Sunique key. The unigue kev 209
uniquely identified by HIS nissionprovide
nurnber, he
d combination of one or more fields;
can be for example, four members of a family
record
a student
number while shopping online. Insuch situation the customer can h individualy
d row, e.g.
id the
name. Without the unique
identification
of
combination of
difficult.
phone and first
Kecort
Database ManagementSystem of columns that can be
used to
Keys in
key in the
column or a group
database is a single uniquely
A different types of keys. identify a record,
that can uniquely
Let's take a look at
multiple key
group of
Super key is a single or a below:
example, look at the table given Years of Exp
For Gender | Department Email
Salary
id
1001
Name

Raghav M
IT
rgh@gmail.
Com
5
10,00,000 Contac
Sharma 2
Sales
Anks@gmail. 5,00,000
Ankita Rai F
1002 Com

the id key but


provided above' a record can be uniquely identified by besides
In the table contact number. Presence of id as
primary key
the email id or
can be uniquely identified by be used to identify the records.
too that can
the fact that there are other keys
Candidate
Acandidate Key
key is one of the Super Key that can uniquely identify records in a table. Contact
candidate key.
email id in the Employees table are examples of
Primary key
The key in a database table that distinctively identifies each record is known as Primarv Key

Foreign Key
Aforeign key is a column or group of columns in a table that references to the primary kev data in 2nid.

SUMMARY

" Adatabase is an organized collection of data.


" DBMS isa software package that is used along with software applications to create and maintain daa
DBMS can be of tWo types: 1. Flat File and 2. Relational Database
" Database servers are dedicated machines that only run DBMS
software.
" A database can have one or more tables.
" Each table is dedicated to specific type of
information.
Every row of a table represents a record and every
column is an attribute.
" Relational database
Management System comprises of tables that are associated with each other.
Record uniqueness is maintained with the help of
" Foreign keys help in defining Primary Key.
relationship in Relational Database Management system.
210
11
Creating and Usi
Tables & SOL
Commands
RELATIONAL DATABASE MANAGEMENT SYSTEM
Arelational database stores information in the form of relations. It has a
collection of
that store data. Every table stores
department etc.
information related to a real-world object
Such as tables
Properties of a Relation:
Every relation(table) has a unique name.
Q DID YOUKNOW?
" No duplicate records exist in a relation. E. F. Codd came up with the
data to the user as relations idea of
" Records have no specific order. at
1BM in
197% presentrg
" All attributes(columns) of a relation are atomic which means that each cell
of a relation
one value.
Containts
Rows
Arow of a table is referred to as record or tuple. It is a horizontal entity that contains the
sperife iot
of each entry in the table. In the Table Employee given below every row
has record of one emploues
note that no twO records are identical among row entries. All the records have same
number of emh
follow the same format. Records are identified by the content and not by the position hence records t
stored in any particular order.
Employee
Employee_jd Name Gender Department Email Years of Exp Sala

1001 Raghav IT [email protected] 5 10.0


Sharma
1002 Ankita Rai F Sales [email protected] 2

Columns: Acolumn is called an attribute. It is a vertical entity of a table. Each column provides ints"
specific to one field of the table. So, the column "Department" will only have information
departments of the employees and the Column "Name" will only have information about the
Employees. Please note that every attribute(column) has a name. You can allow columnscolumns
to havehichu
in cases where information is not mandatory). You can specify default values for the
thatus
entered automatically if no other value is provided. The attribute or the group of attributes
dentify a record ofa relation is known as the primary key.
212
LibreOfflceApplication
netogelstarted with LibreOffice Base and you are going to start with the process of creating a datatbase.
LibreOffice Base icon
desktop. ( ) on your
CckontheLibreOffice Base icon. The following
the you can also search for
window will appear: Alternatively LibreOfice:
Database Wizard
Welcenee te the LArOoe Dt
rAe

Use the Database Wizard to


More
createanw databese, pen n
1Setect databas sing databese Ale, or connect to detabese dod n serer
2.Save and proceed Whet do you want to do
OCrete a nw detabese
Click here Embedded databese HSOLD8 Embedded
O Open an eisting
LibreOffice Base database fle
Recentty used
App Click here
Open
OConect to an eisting databse
Open
Run as administrator
Frebird Externa!

Open ile location

Pin to Start

O Pin to taskbar

IG Uninstal!

systemwide Click here on


mode
ight
o
Alun
move to next step

Help < Back Next > Einish Cancel

The LibreOffice Base app Fig. 11.2 Opening screen


Fig. 11.1

a Database using LibreOffice.


ating Select database and click on Create a new database option. Click on Next.
on
Click

Note The next


window /s about saving the database.
register the database in LibreOfice?
VuWould be asked if you want to
exploring sake you need not select it. Generally, database is created
If vou are creating database for just
good option to register the database. The next option is "After the
for the long term. It is always a
do you want to do?"
database file has been saved what open up and you
database for editing". By doing so database will automatically
Select "Open the completed all the wizards. Click on Finish.
you have
willbe able to add data when X
Databse Wizard
the Dutahene
Decde Meow to reod After Seng ibreOtfice?
in
to register the databese
Do you went the wizard
databese lor me
O egister the
1.Select database
ONo do not vegister the database
do yOU Want to do?
Save atid proceed hes bn ved, whet
Aner the databese hle
editing
Open he database for
teble wizard
OCreste tables uing the
idk Finish to ve
the detabase. Click here to Finish

Concel
Next inish
<Bacy
Help database
Fig. 11.3
Saving of 213
"A Save As window will pop up for you. Here, you
will have to provide the
example is about creating a database for a grocery store. Type in
the name name for the
on Save button.

Decument
O Seach Oocuents
GroceryStor
Status Date nodifed
Narne Type
13 05-2022 0209
Deatoy fle tolder
20-09 2022 1057
Fle tolder
07-09 2022 1318
Fde loldet

Vaul Shde 201 05-07-2021 1541 fle tolder


Zoom
13-07-2022 0901 fde tolde

Rle amery Store


Enter name for database

Sove pE 00F Databane


Click here
Automatic file name
a Hde koldes extension Canoel

Fig. 11.4 Naming the database

This would open the following window for you:


Gocer Store odt-Lbce Sase
ocs indo Mp

Database Tasis

Soote ble in Design Vie


abies

Tables

Erddeed douta HSQLDN Ebedded


Fig. 11.5 Table creation screen in Base

As you can see in the window, there are two ways to create a table:
1. Create Table in Design View
2. Use Wizard to create a table

214
Table
to
Create a
Wzard
allowsyou to create
a database table using a Table Wizard.
option done.
itis
how
ClickonTables
see
icon under the database section and click on Use Wizard to Create Table
to Create
Tabie..) to open the table wizard.
Wizard
Ae
lbreOMce
Storecdt Window telp
Coazn

Desson View. Dosertydon


1Croste lable in
Table Chooe trom a selectson of budress doeonte noes àcutoNZO
Wizndto eate
ACeste View. Create a teble.

nes
Select this option
E
fors

Tables

Reports

HSaLDO Enbedded
Ernbeddeddetebose
Fig. 11.6 Using wizard to create table

window will open as shown below:


On doing so the Table Wizard X
Table Wizard

Select fakds for your table


Steps
your database. After selecting a table
1.Selectfields This wizard helps you to create a table forfields you want to indude in your table. You
category and a sample table, choose the
2.Set types and formats sample table.
can inchude fields from more than one
|3.Set primary key
4 Create tabie Category
OBysiness OPgrsonal
Sampletables
Tasks
Selected fields
Ayailable fieds
Notes
TasdD
EndDate
StartDate
Desciption

Eush Cance!
Next >
< Back
Help
wizard opens
Fig, 11.7 Table

have a look at the components of this window. 215


you will see the four steps that
Under the Steps section on the left-hand side, the wizard
through. The steps involved are as follows:
1. Select fields 2. Set types and formats
4. Create table
3. Set primary key
the dialog box:
There are five buttons on the bottom of
Button Name Description

Help If you have any doubt, click on help and refer to the relevant topic.
Back This button gets activated on the second page.

Next
Once you have filled up all the details, you can click on this
on to next step.

Finish On completion of all four steps, click on Finish to apply the


Cancel On clicking this button the wizard will close and n0
changes.
applied. changes Ni
Now, let's say we want to create a table named Categories for the store to define different
items in the store. types o
Click on step 1: Select fields. On the left-hand side click on Sample tables
Category.
dropdown menu and
Tabie Wd Tabe WizHd

Selest ryour te Solect eld for your tale

This wzard helps you to creste a able tor you database. Aher eecing a ble Solecttielde This wizard heips you to creste a wble for
eategoy and a sample table. choose you Gatabe Ahgr mce .
2Set types and fomats category ad sample table, choose the heids you wart to inchude in you table. You 2 Set types ând forma té the fields you want to inchd
con incude lelds from more then one sample table. Can lnclude helds rom more thsn one ample table
Set prmary key 1 set pary key
CHeAte tatbie Coyegory 4 Create tabie
Cajegory
OByiness OPonl OBygines Oon
Somple ables Sample sbles
Task ategoie
Teds
Selecsed alds Ayeilable felds
Agsets elected helds
tvents CategoryiD
Orders CotegoryName
Contacts
Experses
voices
Paymerts
Products
Projects
Cutomer
Employees firish
Suppliers Concet Help ck Nest

Fig. 11.8 Step 1 of Table wizard Fig. 11.9 Fields selection

Note Under the Available fields section, you will see the names of fields that this table can nait
want to add all the fields to your table lick on button. To add selectively. click and select the te
Available fields that you want to add click on the
button. On reviewing if you fel like removing all
from Selected Fields, click on <« button. To remove fields
one by one you can use button.
For the Categories table both Categoryld and CategoryName are required so click on >» butto
Next.

216
Cgan

Cregore

CatgoryD
Catagoryan

Click here to
move to

righ Cce

Fig. 11.10 Selection of fields


done
Cick on Next button to move on to Step 2 Set types and formats.
values.
elect CategorylD and set the
Field name CategorylD
Feld ype Integer
Aio Value No

Entryy required Yes

Lengtn 10

Set ald types and farmats

Selected fields Fieid infomaion


1.Select 5eids
ategaryD Field name CategoryiD
CategoryName
Set primary key lInteger INTEGER)
Field ype
4Cese tle
Autovlue NO

Entry required
10
Length

Click here to move


to next step

Cancei
Net
Einish
jeck
Help
for fields
Setting data types
Fig 11.11
details.
Category Name to fill in the
Cick on the next field name 217
Field name CategoryName
Field type Text

Entry required Yes

Length 200

Dbie Wizrd
X
Set leld types and formats

1.Select felds Selected fields Field infomation


Set types and formats CategoryD Field name
3. Setprimary key
4Create table
CategoryName
Field ype Text VARCHAR 1
CategoryName
Entry required Yes
Length 20d

Click here

Hetp <Back Next > Finish Cancel


Fig. 11.12 Setting data types
" Click on Next.
Define the primary key for the table. The
key. Therefore, select Use an existing fieldCategorylD is the correct field to be
as primary key option. considered ax s..
Tabie Wizrd
X
Set prmary ly
1.Select felds A primary key uniquely identufes each reord in a database
2 Set types and formats linláng of information in separate tables, table. Primay lkeys ese the
and it is
3.Set peimary kry primary ley n every table. Wirthot a primary key, ecommended
it
that you have a
witt not be possible to enter data
into this table.
4.Ceste table
greste a primary key
OAusomaticalty sdd a primary key
Auto yalue
O Use an existing held as a primary key
Fjeldname CategorylD OAuo yalue
O Deine pomary keysa
combination veral felds
of
Ayailable fields rimary key tields
|C|CategorName
ategorD

Hetp Back Next> Einish Cancel

Fig, 11.13 Setting the primary key


218
select CategoryiD and click on Next button to
dropdown menu,
Feldname move on to step 4
name(Categories) as shown
below and select Insert data
he

Provde
the table immediately Click on
Finish
Button

Geete table

What do you want to name you tuble?


1 Selecthekds
fomats Categornes
typesand
2Set
primarykey
1Set
Cestetable Congratulations. You have entered all the infornation needed to reste you table.
What do you want to do next?
O Insert data immediatety
OModity the table design
O
Ceatea form based on this table

Help <Back Next > Finesh Cance!

Fig. 11.14 Naming the table and others


shownbelow.
table will appear
Eile Edit ew Insert Dta Iools Window Help

CategorylD CategoryName

Fig. 11.15 Table data being entered

n the details as shown below.


Ejile Edit yiew sert t Jools Wind

CategoryiD CategoryName
104 Bronds
105 Deiry Products
106 Cold Drins
107 Small Eats
108 Bevernges
109 Condiments
110 Pulses
111 Caros
Fig. 11.16 Table populated
219
Create Table Using Design View
Let's now have a ook at how to create a table in Design view
" Click on Create Table in Deign View to create a table in design view
window This wil
" Define the name of fields, their types and description Create a table ogen
available in the grocery store that has
" Click on the Field type for each Field name and then provide the field
detals,
Item 1D ID assigned to that particular item properties
Item Name Name of the Item

Category ID ID of the category to which the item belongS


Cost Cost of one unit of the item

Available yes or No

Quantity How much quantity is available

Decimal
Field Name Field Type Description AutoValue Entry
ItemiD
places
No
Required Length
Integer 10 yes 10

ItemName Varchar 50 yes 50


CategoryiD Integer 10 No yes 10

Cost Decimal 10 2 No yes 10

Available Varchar 4 yes 4

Quantity 10 No
Integer 10

Felg hiame Feld ype Description


inager INtEGER 10
am atVARCHAR
Caegory eger [ NTEGER
DecamsDHCIMAL 9
Agiie

Fig. 11.17 Table with description also added

220
illedin the details for the table. Click on File Menu then click on the Save As option.
Store
odh Tabte1 ibreOfice Bate Table D
Groceny
Tools Window Hetp
file Edit Mew
DNew CtrfO

D Open
RecentDocyments

GER ) 10
[ Cose
Wizerds AR J
Crls
GER) 10

IMAL) 10 Save As
ARI
heckDt
|GER) 10 Able Name Grocerytems

Exit LibreOffice Ctrl+0 Heip Cancel

the table Fig. 11.19 Table being named


EIg. 11.18 Saving

dialog box
will appear and ask you to UbreOfice Base
As
Let's save the table by the name No prlmary lay
Talble name.
Save
4
a
provide and click on OK to save the table. Aunique index or primary key is required for data record identifcation in tis
Groceryltems database.

message will be displayed to you. Click on You can onty enter data ido this table when one of t e wO structural conditiors
has been met.
following
The selectthe primary keyfor the table. Should a primary key be created now? Click here

left side of itemld and tick Primary


to
Ves Cancel
clickon the
es No

Right Fig. 11.20 Primary key creation nequest


Keyoption.
and click on Save option as
shown below.
File
Cickon e) Grocery_Store.odb: Groceryltems - LibreOffice Base:
Grocery_Store.odb :Groceryltems - LibreOffice
Window Help File Edit View Iools Window Help
File Edit View Iools
D New
Open... Ctrl+0
Recent Docyments De
Field Name Field Type B Close GER
linteger INTEGER) Wizards GER] 10
Cut TEGERJ 10
ARJ 50
Copy CHARJ 50 Save As.. Ctrl+Shift+S
GER I 10
Delete TEGER] 10 Save All
Insert Rows CIMALJ10
DECIMAL J 10 Check Out
ARI 4
Primary KeyTeXTTVANCHARI Cancel Checkout.
TAVataDre
Check in.
GERJ 10
Quantity |Integer [ INTEGER ] 10
Exit LibreOffice Ctrt+Q

Fig. 11.22 Table design being saved


Fig. 11.21 Primary key being set

fields can be of different datatypes. The various datatypes are:


oU can see, different mobile
data types are used to store numbers such as marks obtained, quantity,
Numeric type: Numeric
types are as follows:
umber etC. Various types of Numeric data
la) Boolean(BOOLEAN): Values 0 or 1 only.
the range 0 to 255.
iny Integer (TINYINT): Stores integers in 215-1.
c) Small Integer(SMALL INT): Integers in the range -215 -
231-1.
(d) Integers between -231 to
le) BiIntg eger(|NTEGER): Integers between -263 to
263-1.
Integer(BIGINT): el)231,
Maximum precision of
NumberNUMERIC): 221
(g) Decimal(DECIMAL): Maximum precision of e".
(h) Real(REAL): 2 1014 to (2 2 ")*2 nn
() Float(FLOAT): 21n" to (2- 2)*21099
() Double(DOUBLE): 2 0'4 to (2 2")°21021
2. Alphanumeric Types: This is a text datatype. The different types of
follows
(a) LONGVARCHAR: Accepts any 8 UTF character. Can store up to the
alphanumerie
(b) CHAR: Accepts any UTF 8 Character but has to be of the length
length specified
specified by the
(c) YARCHAR: Stores value up to the length specified. user
(d) VARCHAR_IGNORECASE: Stores up to the specified length but t is not
Case
3. Binary Types: Binary data types are used to store data in binary formats sensitivaree.
There
binary data types:
(a) LONGVARBINARY: Storage size is the actual length in bytes of the data entered
(b) BINARY: Stores fixed length of binary data. It can be between 1 to 255.
(c) VARBINARY: Stores data of variable length.
4. Date Time: This data type is used to store information related to date or time.
types in this category. There are thrg
(a) Date:Stores information related to month, date and year.
(b) Time: Stores information related to hour, minutes and second.
(c) Timestamp: Stores information of timestamp which includes date and time details.
Besides these there can be other datatypes such as serialized Java objects provided by user applicai

SUMMARY
" A relational database stores information in the form of relations.
" A row of a table is referred to as record or tuple.
" A row is a horizontal entity that contains the specific information of each entry in the table.
" Acolumn is called an attribute. It is a vertical entity of a table.
. LibreOffice Database allows you to create a table in two ways:
(a) Create Table in Design View
(b) Use Wizard to create a table
" You can create atable using the table wizard that guide you through four main steps:
(a) Select fields (b) Set types and formats
(c) Set primary key (d) Create table
" In Design View you will have to define the fields and set their permissible values.
" Data types in Database Management System can be of the following types: (d) Date time
(a) Numneric (b) Alphanumeric (c) Binarytypes
(e) Other objects
12, Operations of Table
In this section you will learn how to perform the following actions on a table:
1. Inserting data
2. Editing/Modifying
3. Deleting DDatabase Wizard
Welcome to the Ulbreonica Detal
INSERTING DATA LHFW86DOUQ Use the Database Wizard to
createto anew d
existing database tile, or connect
1.Select database a database so
Start LibreOffice. Click on Select Database. What do you want to do?
OCreate a rgw database
This will open the Database Wizard window
Embedded databas HSOLDe Erteet
for you. Select option and click on the Finish oOpen anexisting database file
button. Becenty used: Grocery Store
Open
" In the next window, under databases, select Connect to an existing databse
Tables and then under the Tables section fireb1ró Extetnal

select the table where you want to insert


values. In this case it is Groceryltems. So Help <Back Next > Enish

double clickon Groceryltems table. This will Fig. 12.1 First step in creating database
open the Groceryitems table for you.
Grocery Storesdb ubreoice Base X

Bile dit yew jrsert Joos Wneow Meip

Database Tasls

dCete able in Desgn View. Desertpon

Select this
option

Tables
Bopors
Categones
GOCerle

Select the table

Entedded databee HSOLDE Lntedded

Fig. 12.2 Table created


224
the
details as shown below:
in
filing current record) button to save the records.
Sart (Save
on
Chck
TING RECORDS

records can be done by


clicking on (Edit Data) button or by double clicking on the cell
of
Fditing
Wantto eddit.
Change the value that you want to change (Here name of tea was changed trom
ou
Tata
Tea). Click on to save the record.
that
Teato
Table Data View DGrocerytems -GroceryStore -LibreOMce Base Tatse Data Vven
ubreOffice Base:
Groen_Store
Jools Window Help Eile £dit yew jnsert Pata Joos Window Hep

Available temiD RemNeme Categor1D Cot Quarntity


Cost Quantity
CategoryiD 100 Tata Tea 108 10 100
InemName 100 Yes
106 Sunise Coffee 108
AssemTes 75 No
SonseCotfee 108 Green Cardema 109 250
250 Yes S0
GreenCerdem109 Brown Bread 104 3
50 Yes 38 S2
BrownBreod 104 Sandwich Brea 104
Yes 52 15
SandwichBrea 104
50 Cottage Chees 105 172 We

172 Yes 15
CottageChees105
Fig. 12.4 Edited data
entered
Fig 12.3 Data

FROM ATABLE
F
LETING RECORDS
records from the table, select the data you want to delete by double clicking on the cell. Then
To delete
it. Select Delete option as shown below:
Right Click on
Groceryitems - Grocery_Store - LibreOttlce Base: Tabile Deta View
Ble Edit ylew Insert Data Iools Window Hetp

Item/D ItemName CategoryD Cost Available Quantity


Tata Tea 108 100 Yes 100
Sunrise Cotfee 108 75 Yes 50
Green Cardam 109 250 Yes 50
Brown Bread 104 50 Yes 36
Sandwich Brea 104 Yes
15
Undo Ctri

Cug Ctrd+X
Copy Ctri+C
Paste Ctrt+V

Select A Ctrl A
Special Character. Ctrl-Sht+S
Fig. 12.5 Selecting data to delete

eting the table will look as follows:


Groceryitems - Grocery _Store - LibreOffice Base: Table Data View
File fdit Mew Insert Data Tools Window Help

ItemiD ItemName Categor1D Cost Avallable Quantity


Teta Tea 108 100 Yes 100
Sunrise Coffee 108 75 Yes 50
Green Cordam 109 250 Yes 50
Brown Bread 104 50 Yes 38
Sandwich Brea 104 50 Yes 52
105 172 Yes 15
6

Fig. 12.6 Field value deleted


225
side of
" You can also delete the entire row by clicking on the left the roW on tha
View
GroveyemGroren Store LbreOfice Race Table Data
ile Edt Vew net Data oots Window Hetp

Available Quantity
Ihemi hemName Categony0 Cost
Vee 100
tata le
Surrier Coffee 108 Ve

Green Cardam 109 250 Ye

Brown Bread 104 S0 Yes 38


Sandwich Brea 104 $0 Yes 52
105 172 Ves 15
Jable Format
Row Height
Copy
Click here to delete record
Save Record
Undo: Data entry
Fig. 12.7. To delete row

" On clicking Delete Rows the table will look as follows: After deletion the table would
Grocerytems - Grocery Store -LibreOffice Base: Table Data View \ook as folo
File Edit View !nsert Data Tools Window Help
X

ItemiD IternName CategorD Cost Availabie Quantity


Tata Tea 108 100 Yes 100
Sunrise Coffee 108 75 Yes 50
Green Cardame 109 250 Yes 50
Brown Bread 104 50 Yes 38
5 Sandwich Brea 104 50 Yes 52

Fig. 12.8 Row deleted

Toedit the fields of a table you can right click on a table and click on Edit button.
Gocery Store Ddt -Ubreoice Base X
Ee a ye nsert ocs Wndow Hetp

Dt

SCeete Table in Desgn Vew. Desatptlon


AUse Wzrd to Cee ble
DCete Mew.

Oes

Tables
Bepons None

Gocy Cooy CtrtoC


Pasgte

Select CrnA
Deiee
Benae..
form Wzard.
Report id
Open.
Emteddeó Getsbas Click here
Dateose

Fig. 12.9 To edit a table

226
click on the Field properties that you want to change and make the edits.
oU
Can
then

Poperties

Fig. 12.10 Table open in Design view

ing
Data
column can
be sorted by selecting the column and clicking on any one of the sorting buttons
of a
n below:
Click here to sort
Categories - Grocery_Store - LibreOffice Base: Table Data View the data

File Edit View Insert Data Iools Window Help

CategoryD CategoryName
lh04 Breads
105 Dairy Products
106 Cold Drinks
107 Small Eats
108 Beverages
109 Condiments
110 Pulses
111 Cereals

Fig. 12.11 Sort order to be set

Sort Ascending would look like the following figure:


Categories - Grocery Store- LibreOffice Base: Table Data View
File Edit View Insert Data Tools Window Help

Category1D CategorytName Sort Ascending


104 Breads
105 Dairy Products
106 Cold Drinks
107 Small Eats
108 Beverages
109 Condiments
110 Pulses
|111 Cereals
+

Fig. 12.12 Field sorting completed


227
Sort descending would look as follows:
(ategories Grocery Store libreOffice Base lable Data View

Edit View jnsert Data lools Widow Help

Categoryb CategoryName Sort Deserxiingl


ereals
Pulses
109 Condiments
108 Beverages
107 Small Eats
106 Cold Drinks
109 Dairy Products
104 Breads

Fig. 12 13 Records displayedin descending order

REFERENTIAL INTEGRITY
What is Referential Integrity?
Relationships in database design are described with the help of Referential integrity. For
accuracy and consistency of data is very important. With Referential integrity one can, be every
fact that incorrect records cannot be added, records cannot be incorrectly modified or
integrity is obtained by putting a constraint on the database design which makes the
aau cdeoniledteedn.ctompay
point towards the primary key of another table. This protects data quality and does foreign key Redilerave
not allow
What are the benefits of Referential Integrity?
The benefits of referential integrity are as follows:
1. Helps in maintaining data consistency.
2. Helps in maintaining data integrity.
3. Increases productivity.
4. Allows programmer to complete task in fewer programs.
5. There is reduction in data entry errors.
6. The same data need not be entered in different tables.
7. Also, Makes it easier to summarize data from related tables.
GrocerySOVe ode eDteBase
Yiee Joos ndow Hetp
Add Tables

We Admreaaticr
Click here 1 Categones
Tatbie Fter
m Grocerytems
Mecos
sason Mereger. Cut+At+f Descrlytion
use
Cstomize
At+f12

None
re

Help sdd

addtabie
fig, 12.14 Tools Relationships ig. 12.15To
228
need to create an
,relationship,you les?
nte
a,
relatlonship between tables- ass0cation between them without
) relationship, any select adding, or removing data
create
a
Tools > Relationships, table(n the figure
fo click on below Categorles is
and
the
Add Tables window that appears, select
shown in the the table
selected) as shown
below
In
wndow
will look as
Tile
figure below: Categorles and click on Add button.
m Cotegornes
CategoryiD
CategoryNarr Categories Md tatses
displayed
eryens Category
selected

Click here
to add

Help Cose

Fig. 12.16
in the similar way select
Categories table selected
Groceryltems and click on Add button.
Grocery_Store.odb:Grocery_Store - LibreOffice Base. Pelatson Desian
File Edit View Insert Tools Window Help

Categories B Grocerytems
CategorylD | ItemiD Add Tables
X
CategoryNar ItemName
ratenor
CategoDes
Grceryites

Add ed table

Help Oose

Fig. 12.17 Both tables added


To
YouCreate
a
relation Click on Insert > New Relation option.
can also simply drag the primary key from one table to the other table. This would open the
Relations window as shown below:
229
tables is defined by Categoryld.
The relaton betweven the two
Retanice

steges oerftes

Tateg Categetn
Chck here

Delete Oons
OND tion ONo action
nSoeot Grocey Saelbeoce Rase Reia
Obdate cascade
Set NLA
ODelete çascade
ONoecton
Set detau OSet delaut
O
Aad bbtes Çancet
Help
Eg1218 insert New Relation Fig. 12.19 Relations dialog box
Fig. 1220
Look at the options shown below:
Update Options: options that take effect when there are changes to a primary key
Option field.
No Action
Description
Specifies that any change made to a primary key does
not affect
Updating Cascade Updates all the external key fields if the value of other eterNA
the
Set Null
been modified (Cascading Update).
If the corresponding primary key has been
modified, use
corresponding
pima
NULL" value to all external key fields. IS
NULL means that the this option to 2
Set Default If the corresponding primary key has been
modified,
field is emp
value to all external key fields. During the use this
creation of the option to set
default value of an external key field will be defined
properties. when correyouspondiasnsiggp t
" Delete options: select options that take effect
when a primary key field is deleted.
Option
Description
No Action Specifies that the deletion of a primary key will not have any effect on ote
key fields.
Specifies that all external key fields will be deleted if you delete the corem
Updating Cascade primary key field. When you delete a primary key field with the Delete casa
allrecords from other tables that have this key as their forejgn key are adso e
Set Null If you delete the corresponding primary key, the "IS NULL" value willbeas
all external key fields.
toals
be sset
Set Default If you delete the corresponding primary key, a set value will
key fields.
230
Delow.
Grocery Store odb
Grocery Store -
Fle dit VVew Insert ools LibreOffice Base Relation Desgn
Window Help
Categornes
CategoryiD
CategoryNam Groceryt ems
temlD
temNarme
CategoryD
Cost
Fig. 12.21
Relation drawn
can be
of three types:
toOne Relationship
Many Relationship Click here
to Many Relationship
Relationship is when one record in one table Grocery_Store.odb: Grocery Store LibreOffice Base Relaton Design
File Edit View Insert Tools
OTESDONding one record in the other table. In One Window Help
relationship, one record in a table has multiple
table, In Many to many relationship Categoies
inthe other Grocerytems
records in one table can have multiple records CategorylD
tinie CategoryNam pName
nathertatble. goryD
Edit..
rASe for one category there can be several items.
rsiore, there can be one to many relationships
Fig. 12.22 Deleting relationship
en Categories and Groceryltems table.
To remove a relationship, click in the thread between the two tables and right click on it and select the
Delete option.

SUMMARY
Ne atable has been created you can perform the following three tasks on it:
a Inserting data (b) Editing/Modifying (c) Deleting
protects data quality
Relationships in datatbase design are described with the help of Referential integrity. It
and does not allow it to get lost.
LbreOffice Base allows you to create relationships between
tables.
Melationship can be of three types:
a) One to One
D) One to Many
Relationship
C) Many to ManyRelationship
Relationship
231

You might also like