Unit 3_DBMS
Unit 3_DBMS
Hierarchical Data Model -In this model the data is organized into a tree like
structure. The data is stored in the form of records. All these records are linked to
each other at various levels, thereby forming a hierarchy.
Network Data Model- In this model, multiple records are linked to same master
file. It is also considered as an inverted tree where master is present in the bottom
of the tree and the branches contain information linked to the master.
Relational Data Model - This data model is based on the principle of setting
relationships between two or more tables of the same database. It is the most
commonly used database model
Relational Database Terminology
Entity – It is a real world object about which information is to be stored in a
database.
Attribute-These details associated with the entity are called attributes. Each entity
is a collection of these attributes associated with it.
Table – A table is a collection of logically related records.
Field or Columns or attributes – A field is the smallest entity in the database.
Fields are individual record characteristics and are presented as columns within a
table.
Data Values – Data values are the raw data represented in numeric, character or
alphanumeric form.
Record or Row – The data values for all the fields related to a person or object is
called a record. It is presented as rows within a table.
Primary Key – A primary key or simply a key is a field that uniquely identifies a row
in a table.
A primary key cannot have a NULL value.
Foreign Key – If a field or a combination of fields of one table can be used to
uniquely identify records of another table, then that particular field is known as the
foreign key. This foreign key helps to build a relation between two tables.
Candidate Key – All the field values that are eligible to be the primary key are the
candidate keys for that table.
Alternate Key – Out of the candidate keys, one or two are made as primary keys.
The others are the alternate keys.
Data Types -The nature of data to be entered for various fields are of different
types. A data type refers to the type of data that will be stored in the particular
field.
1. Text Data Type – The text data is a combination of letters, numbers or
special characters. No arithmetic calculations can be performed on text data.
2. Numeric Data Type – Numeric data types consists of numbers. The
numbers can be integer or real numbers on which any type of arithmetic
calculations can be performed.
3. Currency Data Type – The currency data type indicates the monetary
values and can be stored using currencies of various countries. For example
$100, £ 500 or Rs. 25.50.
4. Date Data Type – This data type is used to indicate dates and time. For
example 12/25/2019, 08:45 AM. The data and time can be stored in various
formats.
5. Boolean – In boolean data type there can be only two values- True or False.
This also can be given in multiple formats like Yes/No, True/False, On/Off.
6. Binary – The Binary data type used to store digitized images and sounds that
comes as long string of zeros and ones. It is possible to store photos of the
products or employees, or sound snippets or voice messages in Base
database.
Creating a Table
A table in LibreOffice Base can be created using a wizard or using the Design
view.
Navigating through the Table- The black pointing arrow just before the field
name is the record pointer.
The various components of Navigation Box are as follows:
• Record Selector Box – T his is the text box where the currently active
record number is displayed. We may enter the record number that we want to
see in this text box.
• Navigation Buttons – These are used to scroll vertically in the table.
Types of Relationships
The type of relationship between any two tables in a database is based on the
number of records that are present in the transaction table corresponding to the
master table.
Primarily three types of relationships can be set up between two tables in a
relational database These are:
(i) One-to-One
(ii) One-to-many
(iii) Many-to-Many
One-to-One relationship- In this type of relationship, one specific record of a
master table has one and only one corresponding record in the transaction
table.
Referential Integrity
The principle of referential integrity is that; no unmatched foreign key values
should exist in the database.
to maintain referential integrity libreoffice base provides 4 options
No action – This is the default option. This option states that a user
should not be allowed to update or delete any record in the master table
if any related record exists in the transaction table.
Update cascade – This option allows the user to delete or update the
referenced field but along with it all the related records in any of the
transaction tables will also be deleted or updated.
Set NULL – This option assigns NULL value to all the related fields if the
master record is deleted or updated.
Set default – This option assigns any fixed default value to all the
related fields if the master record is deleted or updated.
Creating a Query
A query can be created in three ways. In this chapter you will learn the
first two methods to create a query.
(i) Using a Wizard
(ii) In Design View
(iii) In SQL view
Query wizard contains the Steps Pane on the left and the Query
Details Area on the right. After selecting the fields, field name will
appear in the Fields in the Query list box.
Name of the Query – By default, the name of the query is Query_Events
by default. If desired, type the new name in the text box
Once the query is designed, click Run Query button on the toolbar or
press F5 key. The query result will be displayed in the Tables Pane area
Four layouts are given in this step of the wizard to choose from:
• Columnar display with Labels on the left of the field value
• Columnar display with Labels on top of the field value
• Display as datasheet
• Block display with labels on top
Reports
using a report we can present the retrieved data in an attractive and
customized manner. We can create a report based on a table or a query
or both.
By default the type of report is Dynamic. That means as the field values
in the base table or query change, the report will also change
automatically. If you don’t want automatic updation of the report, choose
the Static option.