Database basics 1
Database basics 1
1. Bits (characters)
2. Fields
3. Records
4. Files
5. Databases
1)Bit (Character) - a bit is the smallest unit of data representation
(value of a bit may be a 0 or 1).
Element/Field
🠶 Data bucket – Data buckets are the memory locations where the
records are stored. These buckets are also considered as Unit Of
Storage.
🠶 Hash Function – Hash function is a mapping function that maps all
the set of search keys to actual record address. Generally, hash
function uses primary key to generate the hash index – address of
the data block. Hash function can be simple mathematical function
to any complex mathematical function.
Advantages of Hash File Organization
🠶 Records need not be sorted after any of the transaction. Hence the
effort of sorting is reduced in this method.
🠶 Since block address is known by hash function, accessing any
record is very faster. Similarly updating or deleting a record is also
very quick.
🠶 This method can handle multiple transactions as each record is
independent of other. i.e. since there is no dependency on storage
location for each record, multiple records can be accessed at the
same time.
🠶 It is suitable for online transaction systems like online banking,
ticket booking system etc.
Disadvantages of Hash File Organization
🠶 Disadvantages:
🠶 The hash function can be any complex mathematical function.
🠶 This method may accidentally delete the data. For example, In Student table, when
hash field is on the STD_NAME column and there are two same names – ‘Antony’,
then same address is generated. In such case, older record will be overwritten . So
there will be data loss.
🠶 Since all the records are randomly stored, they are scattered in the memory. Hence
memory is not efficiently used.
🠶 If we are searching for range of data, then this method is not suitable. Because, each
record will be stored at random address. Hence range search will not give the correct
address range and searching will be inefficient. For example, searching the
employees with salary from 20K to 30K will be efficient.
🠶 Searching for records with exact name or value will be efficient. If the Student
name starting with ‘B’ will not be efficient as it does not give the exact name of the
student.
🠶 If these hash columns are frequently updated, then the data block address is also
changed accordingly. Each update will generate new address. This is also not
acceptable.
Traditional file-based approach
🠶 The term 'file-based approach' refers to the situation where data
is stored in one or more separate computer files defined and
managed by different application programs.
🠶 Typically, for example, the details of customers may be stored in
one file, orders in another, etc. Computer programs access the
stored files to perform the various tasks required by the
business. Each program, or sometimes a related set of programs,
is called a computer application.
🠶 For example, all of the programs associated with processing
customers' orders are referred to as the order processing
application. The file-based approach might have application
programs that deal with purchase orders, invoices, sales and
marketing, suppliers, customers, employees, and so on.
🠶 Limitations
• Data duplication: Each program stores its own separate files. If the same
data is to be accessed by different programs, then each program must store
its own copy of the same data.
• Data inconsistency: If the data is kept in different files, there could be
problems when an item of data needs updating, as it will need to be
updated in all the relevant files; if this is not done, the data will be
inconsistent, and this could lead to errors.
• Difficult to implement data security: Data is stored in different files by
different application programs. This makes it difficult and expensive to
implement organization-wide security procedures on the data.
The following diagram shows how different applications will each have their
own copy of the files they need in order to carry out the activities for which
they are responsible:
File processing Vs. DBMS
File System DBMS System
1 File system is a software that manages ad organizes the DBMS is a software for
files in a storage medium within a computer. managing the database.
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
+----+----------+-----+-----------+----------+
A record is a horizontal entity in a table.
🠶 What is a column?
🠶 A column is a vertical entity in a table that contains all information
associated with a specific field in a table.
🠶 For example, a column in the CUSTOMERS table is ADDRESS, which
represents location description and would be as shown below −
+-----------+
| ADDRESS |
+-----------+
| Ahmedabad |
| Delhi |
| Kota |
| Mumbai |
| Bhopal |
| MP |
🠶 Features of RDBMS Systems:
• All data stored in the tables are provided by an RDBMS
• Ensures that all data stored are in the form of rows and columns
• Facilitates primary key, which helps in unique identification of the rows
• Index creation for retrieving data at a higher speed
• Facilitates a common column to be shared amid two or more tables
• Multi-user accessibility is facilitated to be controlled by individual users
• A virtual table creation is enabled to store sensitive data and simplify
queries