I.T. Part-B Unit-3
I.T. Part-B Unit-3
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
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
Foreign Key
Aforeign key is a column or group of columns in a table that references to the primary kev data in 2nid.
SUMMARY
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
Pin to Start
O Pin to taskbar
IG Uninstal!
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
Database Tasis
Tables
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
nes
Select this option
E
fors
Tables
Reports
HSaLDO Enbedded
Ernbeddeddetebose
Fig. 11.6 Using wizard to create table
Eush Cance!
Next >
< Back
Help
wizard opens
Fig, 11.7 Table
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.
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
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
Lengtn 10
Entry required
10
Length
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
Length 200
Dbie Wizrd
X
Set leld types and formats
Click here
Provde
the table immediately Click on
Finish
Button
Geete table
CategorylD CategoryName
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
Available yes or No
Decimal
Field Name Field Type Description AutoValue Entry
ItemiD
places
No
Required Length
Integer 10 yes 10
Quantity 10 No
Integer 10
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
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
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
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
Database Tasls
Select this
option
Tables
Bopors
Categones
GOCerle
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
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
Available Quantity
Ihemi hemName Categony0 Cost
Vee 100
tata le
Surrier Coffee 108 Ve
" 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
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
Oes
Tables
Bepons None
Select CrnA
Deiee
Benae..
form Wzard.
Report id
Open.
Emteddeó Getsbas Click here
Dateose
226
click on the Field properties that you want to change and make the edits.
oU
Can
then
Poperties
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
CategoryD CategoryName
lh04 Breads
105 Dairy Products
106 Cold Drinks
107 Small Eats
108 Beverages
109 Condiments
110 Pulses
111 Cereals
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
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