Database Micheal
Database Micheal
as a container of information.
1. Flat File: Data is stored in a single table. This is usually suitable for less
amount of data.
2. Relational: Data is stored in multiples tables which are linked by a
common field. This is suitable for medium to large amount of data.
Database Servers: These are dedicated computer systems that hold the
databases and run only the DBMS and related software. Databases are
available on database servers and are usually accessed through a command
line or Graphic User Interface tools [called Frontend].
Advantages of Database:
2) Sharing of Data: The users of the database can share the data among
themselves.
3) Data Integrity: Data integrity means that the data in the database is
accurate and consistent.
Features of Database:
3) Foreign key: The foreign key identifies a column or set of columns in one
(referencing) table that refers to a column or set of columns in another
(referenced) table.
Database Objects:
Data Types: These are used to identify which type of data we are going to
store in the database. Data types in the OpenOffice base are broadly
classified into five categories.
1. Numeric Types
2. Alphanumeric Types
3. Binary Types
4. Date time
5. Other Variable types
Numeric Types: Used for storing information such as mobile number, roll
number, door number, etc.
Binary Types: Used for storing data in binary formats. This can be used for
storing photos, music files, etc.
DATE TIME: Used for storing information such as date of birth, date of
admission, date of product sale, etc.
In the OpenOffice Base, we store data in tables that can be inserted, modified,
and removed using suitable options.
3) Select the data > right click on selected data > select the Delete option
Field Properties :
1. Select the table > Right-click > Select the option Edit > the table will
open in Design View.
There are various properties of fields according to the data type set for each
field in the design view.
1) AutoValue – if set to yes then the field will get the auto numeric values.
2) AutoValue – if set to no then the field will not get the auto numeric values.
3) Length – By default length of the field is 10 but the size of the field can be
set to maximum length.
4) Default Value – A default value can be set for a field if the user doesn’t
provide any value while entering the values in the table.
5) Format – This property helps to set the format of the data entered in the
field such as 91-222-333.
1) Entry Required – if set to yes then it will be a must to insert the value in the
field.
2) Length – By default length of the field is 10 but the size of the field can be
set to maximum length.
3) Default Value – A default value can be set for a field if the user doesn’t
provide any value while entering the values in the table.
4) Format – This property helps to set the format of the data entered in the
field such as 91-222-333.
Sorting Data :
Referential Integrity :
3) Deleting records from a primary key table if there are any matching related
records available in the associated table(s).
1. Save time as there is no need to enter the same data in separate tables.
2. Reduce data-entry errors.
3. Summarize data from related tables.
You can create a relationship between any two tables by selecting the
Relationships option from the Tools menu.
1) ONE to ONE Relationship: In this relationship, both the tables must have
primary key columns.
The relationships applied on the tables can be removed also with the help of
the Delete option. Right, Click on the relationship thread and select the Delete
option.
Queries are commands that are used to define the data structure and also to
manipulate the data in the database. A query helps us join information from
different tables and filter that information
For example, if you want to display all the data from table emp (short form of
employee), the command is
The above query will show the result of a particular employee named “Neha”.
The above query will show all the records of table emp according to
ascending order of column Salary.
Performing calculations :
1) To display the salary of all the employees after incrementing by 1000 then
the following SQL command will be executed in Base. (Fields of table
Employee are EmployeeID, FirstName, Salary)
2) To display the salary of all the employees after decreasing by 10000 then
the SQL command will be:
3) To display the salary of all the employees after incrementing it as twice the
amount of present salary, then the SQL command will be.
Update Statement :
FORM: A form provides the user with a systematic way of storing information
in the database. It is an interface in a user-specified layout that lets users
view, enter, and change data directly in database objects such as tables.
Creating Form Using Wizard: Steps To Create Form Using Wizard are :
1) Click Use Wizard to Create Form option under Tasks group. The Form
Wizard dialog box appears.
2) Select selective fields to be sent onto the form by selecting the field name
and clicking the > button and clicking Next.
3) Select the option Add Subform if you need to insert the contents in the table
in a separate form and click Next.
Creating Reports using the wizard: Steps To Create Report Using Wizard
are :
1) Click on Use Wizard to Create Report… option available under Tasks.
3) Redefine the label of the fields in the reports or else you can set the default
name and click Next.
4) Define grouping for the fields of the table if required and click Next
5) Sort the field in the report by selecting the appropriate field name and
sorting method(if required) and click Next.
What is Database?
An organised group of data that is kept and accessible electronically is
referred to as a database. It is a digital repository that enables the effective
management, storage, and retrieval of both organised and unorganised data.
Information like client records, financial data, inventory listings, and much more
can be stored in databases. Example of database are – Microsoft Access,
OpenOffice Base, Oracle, MySQL and PostgreSQL etc.
Flat File: Data is stored in a single table. Usually suitable for less amount
of data. basically for small-scale organization where data does not need to
be strucutred in a complex way. Example of database software are
Microsoft Excel or Google Sheets.
Relational: Data is stored in multiple tables and the tables are linked using
a common field. Relational is suitable for medium to large amount of
data. Example of database software are MySQL, Microsoft SQL
Server, and Oracle Database..
What is Database Server?
Database servers are dedicated computers that are designed to store data
and provide database services to other computers. We use a database to
store, organize, manage and retrieve data efficiently and effectively. The
database servers run only database and database related software.
Advantages of Database
Data redundancy means when same data is stored more than one places,
which increased complexity and wasted of storage space, so, database helps to
reduce data redundacy.
Sharing of Data
A database allows its users to exchange data among themselves. The data
can only be shared with users who have received the appropriate degrees of
authorization because there are different levels of access to the data.
Data Integrity
Privacy
The privacy rule in a database ensures that only authorized users can access
the database and view data according to the specific privacy constraints.
To maintain data security, access levels are set in the database so that a user
can only view data that they are not allowed to modify if the permission is not
given.
For example, in social networking sites, different accounts have different access
constraints, and users are only allowed to view the other account data that is
permitted for their specific account.
Data Consistency
For example, if a customer’s name and address are stored in multiple tables
within a database, the data must be consistent across all table.
Features of Database
There are some key features of a database:
In the RDBMS data can be integrated using keys. These are Primary Key,
Composite Primary Key, and Foreign Key, Key are used to make the relationship
between the tables.
1. Primary Key – This unique field is called the Primary Key (PK). primary
key is a field or a set of fields that uniquely identify each record in a table.
A primary key must be unique and cannot contain null values.
2. Composite Primary Key – A composite primary key is a primary key that
consists of two or more fields that together uniquely identify each record in
a table.
3. Foreign Key – A composite primary key is a primary key that consists of
two or more fields that together uniquely identify each record in a table.
What is RDBMS?
A database management system that is based on the relational model is called
an RDBMS (Relation Database Management System). Tables are used to
organise data in relational databases. A relational database management system
(RDBMS) is used to store, manage, query, and retrieve data.
Database Objects
a. Tables: Data is arranged into rows and columns in a table, which is a type
of data structure. It can be applied to both the storage and presentation of
structured data.
Data is stored in various formats such as flat Data is stored in tables that are related to each other
Data structure
files or hierarchical structures. a relational model.
DBMS systems may or may not enforce strict RDBMS systems enforce strict data integrity rules tha
Data integrity
data integrity rules. ensure data consistency and accuracy.
Data DBMS systems may or may not follow RDBMS systems follow normalization rules to minimi
normalization normalization rules. data redundancy and improve data integrity.
DBMS systems may not be scalable to handle RDBMS systems are highly scalable to handle large
Scalability
large amounts of data. amounts of data.
DBMS systems are generally less expensive RDBMS systems are generally more expensive than D
Cost
than RDBMS systems. systems.
Data Types
The type of data (value) that will be stored in the database is defined by its
datatype. Important to know the different types of data helps to ensure that each
property’s value is as expected and that data is collected in the correct format.
Data types in OpenOffice base are broadly classified into five categories listed
below.
Numeric Types
Alphanumeric Types
Binary Types
Date time
Other Variable types
Numeric Types
Numerical data types are data types that store numeric values in a database.
Numeric data types can be further divided into several subtypes, including:
Alphanumeric Types
Data that has both letters and numbers is referred to as alphanumeric type.
Binary Types
For storing data in binary formats, binary data types are utilised. In a database,
binary data types can be used to store things like music and image files. The
binary data type can generally be used to store files in any format.
Date Time
When specifying date and time values for a column used in a database table,
date time data types are used. Information like dates of birth, admissions,
product sales, and other dates can be stored in databases using date and time
data types.
Other Data Types
Select the table > Right click > Select the option Edit > the table Design
View window will open
Following are some properties of data of the numeric type:
1. AutoValue – if set to yes then field will get the auto numeric values.
2. Length – By default length of the field is 10 but the size of the field can be
set to maximum length.
3. Default Value – A default value can be set for a field if user don’t provide
any value while entering the values in the table.
4. Format example – This property helps to set the format of the data
entered in the field such as 91-222-333.
Following are some properties of data of the character type:
1. Entry Required – if set to yes then it will be must to insert the value in the
field which means that field cannot be left blank.
2. Length – By default length of the field is 10 but the size of the field can be
set to maximum length.
3. Default Value – A default value can be set for a field if user don’t provide
any value while entering the values in the table.
4. Format example – This property helps to set the format of the data
entered in the field such as 91-222-333.
Sorting Data
Sorting means to arrange the data in either ascending order of descending order.
Sorting is the process of putting data into a meaningful order so you can evaluate
it more efficiently.
Referential Integrity
The relationship between tables is referred to as referential integrity. Referential
integrity is used to maintain accuracy and consistency of data in a relationship. In
Base, data can be linked between two or more tables with the help of primary key
and foreign key constraints.
1. Save time as there is no need to enter the same data in separate tables.
2. Reduce data-entry errors.
3. Summarize data from related tables.
Type of Relationships in Database
1. ONE to ONE
2. ONE to MANY OR MANY to ONE
3. MANY to MANY
ONE to ONE
In this relationship, both the tables must have primary key columns.
In this relationship, one of the table must have primary key column. It signifies
that one column of primary key table is associated with all the columns of
associated table.
MANY to MANY
In this relationship, no table has the primary key column. It signifies that all the
columns of primary key table are associated with all the columns of associated
table.
Note Removing the Relationships – With the use of the Delete option, the
relationships that have been applied to the tables can also be deleted. When you
right-click a relationship thread, the Delete option will appear.
Session 4 : Retrieve Data using Query
In order to describe the data structure and to modify the data in the database,
queries are used as instructions. A query enables the joining and filtering of data
from various tables.
SELECT: The statement “SELECT” is used to get data from the database.
INSERT: The statement “INSERT” is used to add a new record to the
database.
DELETE: The database can be cleaned out by using the statement
DELETE.
UPDATE: This statement is used to modify the database’s information.
Database Query
Query is a computer languages. In order to describe the data structure and to
modify the data in the database, queries are used as instructions. Query can
extract particular data from a database. We can filter and join data from various
tables with the help of a query. By using the criteria you supply query will filter the
data.
Select Statement
WHERE specifies which rows to retrieve.
ORDER BY specifies an order in which to return the rows.
Syntax of Select Statement is –
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
31 Powder 80 30
45 Shampoo 250 25
Output –
Product_Name
Soap
Powder
Shampoo
Soap Box
Output –
Product_Name Price
Soap 40
Powder 80
Shampoo 300
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
52 Soap Box 120 100
Output – 235
Question – Display the total amount of each item. The amount must be
calculated as the price multiplied by quantity for each item.
Output –
25 Soap 3200
31 Powder 2400
45 Shampoo 6250
Output – 58.75
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Question – Write a Query to display the product whose price is less than
90
Output –
25 Soap 40 80
31 Powder 80 30
Output – 6250
Or
Output –
45 Shampoo 6250
Output –
25 Soap 40 80
Select * from product where Price >= 40 and Price <= 120;
Output –
25 Soap 40 80
31 Powder 80 30
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Or
Output –
31 Powder 80 30
45 Shampoo 250 25
25 Soap 40 80
Or
Output –
Product_No Product_Nam Price Quantity
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
45 Shampoo 250 25
31 Powder 80 30
25 Soap 40 80
UPDATE statement
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
25 Soap 40 80
31 Powder 80 30
45 Shampoo 300 25
Output –
25 Soap 40 80
31 Powder 80 50
45 Shampoo 250 25
Create Table
To create a new table in the database you can use Create Table Command.
Field DataType
Product_No Integer
Product_Name Varchar(20)
Price Integer
Quantity Integer
Output –
Insert Table
Insert statement is primarily used to add a single or more rows to the target table.
Or
INSERT INTO table_name VALUES (value1, value2, value3, ...);
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Question – Write a Query to add a new row with the following details
Or
Output –
25 Soap 40 80
31 Powder 80 30
45 Shampoo 300 25
Forms
The Form allows you greater control over your outcomes. The form allows you to
customize various parts of the form’s design and then generates a form based on
your instructions.