0% found this document useful (0 votes)
26 views

Notes - Unit 3 - DBMS

Uploaded by

nazishkodiyil662
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Notes - Unit 3 - DBMS

Uploaded by

nazishkodiyil662
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Unit 3: Database Management System

Session-1: Appreciate the concept of Database Management System


Data & Information: Data is a collection of raw or unorganized facts that requires to be processed to make it
meaningful. It mainly consists of characters, words, numbers or symbols that do not mean much on their own.
However, when the data is processed, organized and structured in a specific manner to make it meaningful, it is
called Information.
A computer makes use of various applications and formulas to convert data into information.
Example of data and information- Data - 0, 32. Information - The freezing and boiling point of water in Degree
Celsius is 0 and 32 respectively.
Database: A Database is an organized collection of data. It allows you to store large amount of related data in
the form of tables. Data in each table is stored in rows and columns. Telephone directory, a dictionary and a list
of employees and customers in banks, etc. are the examples of database. Given below is an example of a student
database that shows how data is stored in tabular form in a database.

Roll No Name Class Address Mobile No.


101 Sushant 10 Delhi 56784674
102 Adil 10 Agra 32456788
103 Kishore 10 Delhi 12563567

Features of Database:
 It stores and create data in the form of tables.
 It is very easy to use and understand.
 It can easily handle a large number of records stored in the tables.
 Data stored in a database will remain stored permanently until and unless it is deleted from the
system manually.
 It allows multiple users to use the database simultaneously. or
Applications of Database:
Some of the areas where database applications are widely used to store, manage and retrieve data.
 Schools: It can be used to store the student records with their personal information and parent's details.
It can also be used to keep a record of the fee and result details.
 Airlines: It is used to maintain a record of details, flight schedule, reservation or cancellation status.
 Hospitals: It helps to maintain a record of patient's medical history and the treatment provided for the
same.
 Banks: It helps to store and retrieve customer's account information such as withdrawals, deposits,
payments and loans.
Advantages of Database Management System (DBMS):
 Reduce Data Redundancy: Data redundancy refers to the occurrence of same data in two or more
places within a database. DBMS allows to prevent the input of duplicate items in the database. For e.g. -
If there are details of the same employees in two different rows, then one of the duplicate data will be
deleted.
 Data Security: As the number of users increases, the data transfer also increases thus increasing the risk
of data security. A Database Management System (DBMS) provides a platform for data privacy and
security policies to improve Data Security. Only authorized users are allowed to access the database
using a username and password.
 Data integrity: Data integrity refers to the overall accuracy, completeness, and reliability of data.
Database Management System arranges information in well-managed and synchronized form to make
data handling very easy thus provide data integrity.
 Data Consistency: Data consistency ensures that there is no data mismatch and conflict. All data
appears the same for all the users viewing the database. Moreover, any changes made to the database are
immediately reflected to all the users and there is no data inconsistency.
 Data Sharing: The data stored in the database can be shared among multiple users or application
programs.
 Backup and Recovery: The DBMS provides backup and recovery sub-system that is responsible to
recover data from hardware and software failures.

Database Users:
It is the person, who needs information from the database to carry out its primary business responsibilities. The
various types of users which can access the database system are as follows:
 Application Programmer/Developers: A people, who writes application programs in programming
languages to interact and manipulate the database are called application programmer/developer.
 Database Administrator (DBA): A person, who is responsible for managing or establishing policies for
the maintenance and handling the overall database management system is called DBA.
 End-user: A person, who interacts with the database system to perform different operations on the
database like inserting, deleting etc., through menus or forms is called end-user.

RDBMS (Relational Database Management System)


 RDBS is a type of DBMS software that uses Relational Database Model (RDB) for its database
 RDBMS enables users to store the data in multiple tables simultaneously and produce answers to questions
that can’t be handled by individual tables alone.
 Relational database stores data in the form of rows and columns.
 RDBMS makes it easy to search and retrieve the data within the database and ensures that the data integrity
is maintained. Eg: ORACLE, LibreOffice Base, MS Access, Sybase, MySQL
RDBMS Concepts:
Table: Table is a collection of logically related records. It is organized as a set of columns and can have any
number of rows.
Attributes/ Fields / Columns: Fields are individual record characteristics and are presented as columns within a
table. Data values are stored in a database as fields. A field holds the data values of one type of data for several
persons.
Record/ Tuple / Row: The data values for all the fields related to a person or object is called a record. A record
holds the data values of all the fields for a single person or object in a table.

Types of Key Fields:


The following are the types of key fields available in the DBMS system:
Primary Key: A field or a set of fields that uniquely identify each record in a table is known as a primary key.
Each relation has at least one column for which each row that must have a unique value. Only one column attribute
can be defined as a primary key for each table.
A primary key must possess the following properties:
 It does not allow null values.
 It has a unique index.
 It allows numbers and text both.
e.g. In the student's table, student ID works as a primary key because it contains Ids which are unique for each
student. Note Data cannot be primary key.
Candidate Key: The set of all attributes which can uniquely identify each tuple of a relation are known as
candidate keys. Each table may have one or more candidate keys and one of them will become the primary key.
The candidate key of a relation is always a minimal key. e.g. Column student ID and the combination of first
name and last name work as the candidate keys for the student table.
A candidate key must possess the following properties:
 For each row, the value of the key must uniquely identify that row.
 No attribute in the key can be discarded without destroying the property of unique identification.
Alternate Key: From the set of candidate keys after selecting one of the keys as a primary key, all other remaining
keys are known as alternate keys.
e.g. From the candidate keys (student ID, combination of first name and last name), if student ID is chosen as a
primary key, then the combination of first name and last name columns work as alternate keys.
Foreign Key: A field of a table (relation) that references the primary key of another table is referred to as foreign
key. The relationship between two tables is established with the help of foreign key.
A table may have multiple foreign keys and each foreign key can have a different referenced table. Foreign keys
play an essential role in database design, when tables are broken apart, then foreign keys make it possible for
them to be reconstructed.
e.g. Courseld column of student table (reference table) works as a foreign key as well as a primary key for course
table.
Composite Key: There may be a table that might not have a single column/attribute can uniquely identify all the
records of a table. In order to uniquely identify rows of a table, combination of two or more columns/attributes
can be used. It is known as composite key.
For example, StudentId and Firstname together known as Composite Key,
Session-2: Create and Edit Tables Using Wizard and SQL Commands
Creating Database Using OpenOffice:
Select the option database to open the base application. You can also directly open the OpenOffice Base
Application by doing the following:
• Click Start>Programs>OpenOffice>OpenOffice Base.
You should be guided through the Database Wizard for creating a database. Database wizard dialogue box will
appear.

You can create a new database by selecting the option Create a new database.
You can also open an existing database file that you have already created by selecting option Open an existing
database file. Click Next.
Database wizard with step 2 dialog box will appear.

Click Finish. The Save As dialog box will appear


Specify a name for the database in the File name: field and click Save. A window similar to the one displayed
below.
Steps to Create a Table Using Table Wizard:
Tables are the basic building blocks of a database. You After creating the database, you see a window as shown
below.
There are different ways to create a table
1. Create table using Design View
2. Use Wizard to Create Table

A table can be created using the pre-defined steps and table structure(s) in Base.
The following are the steps to create a table:
Click on Tables → Use Wizard to Create Table, the window will open.
Click the Select Fields → Choose Category → Select the table.

Select the fields as per the requirements and select on buttons to add the pre-defined columns or select
to remove the fields from the Selected Fields Box. After selecting the fields click on Next Button.
Once the fields will be selected the window to set the data types will open. By default, all the fields will have
Text[VARCHAR] data type, but all of them can be selected as per the requirement.
Click the next button.
After setting the properties of the fields such as field name, type etc.
The window to set the primary will primary will open. Base automatically adds the column to be set as Primary
Key which will help the user to enter the unique values and helps in creating the relationship with the other table
to extract the data from multiple tables.
After setting the Primary Key click on Next button.

When the Primary Key will be set, then window to create the table will open. A user can either go ahead with the
same table name or can change it.
In the same window options to work with the table will be given as:
The option to insert the data immediately will be selected by default. Click on Finish to insert the data in the table.
Creating Table using Design view:
Click on Create Table in Design View……..option available under Tasks and a Table Design window will appear.

Specify the field name and data type of the field to be created by selecting the appropriate type available under
Field type dropdown list. Specify the field name and the data type for each field name.
Specify the table name. Click OK.

A dialogue box will appear.

Options to set Primary Key


You are asked to set a primary key for the table you just created. You can select the appropriate option to set the
primary key or leave the table without a primary key. If you click Yes, the application will set the primary key
for the first field created automatically. If you click No, you should see a window.
Data Types:
Data types are used to identify which type of data (value), we are going to store in the database.
Fields themselves can be of different types depending on the data they contain. Data types in OpenOffice base
are broadly classified into five categories listed below
 Numeric types
 Alphanumeric types
 Date time
 Other variable types
Numeric Types: Numeric data types are used for describing numeric values for the field used in the table of a
database. Numeric data types in a database can be used for storing information such as mobile number, roll
number, statistical values, etc.
The different types of numeric data types available are listed here.

Alphanumeric Types: There are different alphanumeric types in OpenOffice Base


Binary Types:
Binary data types are used for storing data in binary formats. Binary data types in a database can be used for
storing photos, music files, etc. In general, files of any format can be stored using the binary data type. The
different type of binary data types available are listed here.

Date Time:
Date time data types are used for describing date and time values for the field used in the table of a database. Date
time data types in a database can be used for storing information such as date of birth, date of admission, date of
product sale etc.
The different types of date time data types available are listed here.
Session-3: Perform Operations on Tables
A Tables are used to present the data in an organize manner where data is stored in the form of rows &
columns. In Base, data is stored in the form of tables and you can perform various types of operations on these
tables such as inserting data, editing data, deleting data, sorting data, etc. You can also create relationships
between two tables.
Inserting data in the table:
Follow the given below steps to insert data in a table:
 Open your database in which your table exists.
 Open the table.
 Now type your data. Using the tab key move to the next column.
 You can add as many rows as you want.
Editing records in the table:
After inserting data in a table, you may need to edit the data in case some information has been changed. Follow
the given below steps to edit the data in a table.
1. Open your database.
2. Now open your table.
3. Click on the Edit menu and choose the Edit Data option.
4. The table will be displayed in the edit mode
5. Now edit your data. And click on the Save button to save the changes
Deleting records from the table:
There are many ways to delete the records in a table.
1. Open your table.
2. Select the record that has to be deleted. And press the Delete key
OR
Click on the Edit menu and choose the Delete option.
OR
Right Click on the record and choose the Delete Rows option.
Sorting data in the table:
Sorting refers to the arrangement of data. You can arrange the data in ascending or descending order. In base,
you can sort the data using single field and multiple fields.
Sorting data using single field
Follow the given below steps to sort the single field in a table
1. Open your table.
2. Select the column whose data needs to be sorted.
3. On the Table Data toolbar, select either Sort in Ascending Order or Sort in Descending Order as per
your requirement.
Data will be sorted as per your choice.
Sorting data using multiple field
Follow the given below steps to sort multiple fields in a table
1. Open your table.
2. Click on the Sort button on the Table Data toolbar. The Sort Order dialog box opens.
3. Select the field names and their order either ascending or descending.
4. Click on OK.
The data will be sorted according to your choice.

Referential integrity
Referential integrity is used to maintain accuracy and consistency of data in a relationship (two related tables).
In Base, data can be linked between two or more tables with the help of primary key and foreign key
constraints. Referential integrity refers to the rule that a foreign key must have a matching primary key. It
prevents to insert the duplicate records.
Referential integrity helps in the following:
 Adding records to a related table if there is no associated record available in the primary key table.
 Changing values in a primary key field if any dependent records are present in an associated table.
 Deleting records from a primary key table if there are any matching related records available in
associated table(s).
Relationship:
A relationship in Base refers to an association between two or more tables. Relationships between tables helps
in saving time as there is no need to enter the same data in another tables. If there is a large amount of data that
you need to display in a table, in that case, you can store data in more than one table. To display the data from
more than one table as a single table, you must create relationships between the tables. Relationship can be
established by matching the fields with the same name in different tables. For example, you can create a
relationship between two tables, if one field serves as a primary key in one table and the same field serves as a
foreign key in the second table.
Types of Relationship
There are mainly three types of relationships that you can establish between two tables.
1. One to One
2. Onto 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 type of relationship a
record in a table can have only one matching record in another table. One- to-One relationship can be
established when two tables are related by a single row.
Example: In the given tables Customers and NewTable, ID in Customers table and ID1 in NewTable, table are
the primary keys.

One to Many: n this relationship, one of the table must have primary key column. In this relationship, one
record in one table is associated with many records in the second table. This type of relationship can be
established where one record in a table matches with many records in another table. For example, a same
employee can do multiple tasks in an organisation or a students is doing many activities in a school.
Example: In the given tables Customers and NewTable, ID in Customers table is the primary key.

Many to Many: In this relationship, no table has the primary key column It signifies that all the columns of
primary key table an associated with all the columns of associated table. In this type of relationship, many
records of a table matches with many records of another table. This type of relationship can be established when
many records in a table are associated with many records in another table.
Example: In the given tables Vacations and Fuel, there no primary key.
Creating a Relationship:
Follow the given below steps to create a relationship between two tables.
1. Open your database.
2. Select two tables.
3. Click on the Tools menu and choose the Relationship option. The Add Tables dialogue box appears.
4. Now, select a table from the dialog box and click on the Add button. The selected table is added in a
relationship.
5. Similarly, select the another table and click on the Add button.
6. Click on the close button to close the Add Tables dialog box.
7. Drag the primary key of a table and drop to the same field in the another table. The relationship is
created.
8. Click on the Save button in the File menu to save the relationship.
Field properties
In design view there are different properties of fields according to the data type set for each field.
Numeric Data Type Properties
 Auto Value: if it sets to yes then field will get the auto numeric values.
Length: By default, length of the field is 10 but the size of the field can be set to maximum length in
this property.

 Default Value: A default value can be set for a field if user does not provide any value while entering the
values in the table.
 Format example: This property is used to set the format of the data entered in the field such as 91-222-
333.
Character Data Type Properties
 Entry Required: if it sets to yes then it you must enter the value in the field which means that field
cannot be left blank
 Length: By default, length of the field is 10 but the size of the field can be set to maximum length in this
property.
 Default Value: A default value can be set for a field if user does not provide any value while entering the
values in the table.
 Format example: This property is used to set the format of the data entered in the field such as 91-222-
333.

You might also like