google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Tuesday, July 8, 2014

File Organization

FILE ORGANIZATION:

It refers to the way of arranging the records in a file which can be accessed in a faster way.
The criteria considered in choosing a file organization are:
1) Fast access to single record or collection of related records.
2) Easy record adding/ update/ removal without disrupting.
3) Storage efficiency
4) Redundancy as a warranty against data corruption.

The files are generally viewed as
• Logical File organization: The groups of fields which are combined to form logical
record, which can perform different operations on the file.
• Physical file organization: The data which is stored in the form of records can be
placed in any storage devices, main memory, secondary memory etc.


Types of File Organization:
I) Sequential Access File Organization
II) Direct Access File Organization
III) Index Sequential Access File Organization


I) Sequential Access File Organization:

1) All records are stored in a sequential order.
2) That is, the records are arranged in the ascending or descending order of a key field.
3) Eg: a) In a student information system, the file would contain roll number, name, division, marks
obtained in the examination.
b) In a payroll application, the records are stored with employee number as a
key field.
4) To locate a particular record in such file organization, we have to start searching
from the beginning of the file until it is found in the file.
5) It is time consuming process.
6) Normally created and maintained on magnetic tapes. Eg: Audio Cassettes.
7) There is no need for any storage space identification

Advantages:
1) Simple to understand
2) Easier to organize, maintain
3) Economical
4) Error in files remain localized

Disadvantages:
1) Entire file has to be processed
2) Transactions must be sorted in a particular sequence before processing
3) Time consuming searching
4) High data redundancy
5) Random enquiries are not possible to handle


II) Direct Access File Organization (Random Access or relative file organization).:

1) Also known as Random Access or relative file organization.
2) Records are stored in Direct Access Storage Device(DASD). Such as magnetic disk(Hard disks).
3) For direct access, the file is viewed as numbered sequence of blocks or records.
4) These blocks or records are taken as key for accessing the desired information randomly.
5) It allows arbitrary (random) blocks to be read or written.
6) It is useful for immediate access to large amount of information. They are often used in accessing
large databases.
7) This technique is called as hashing

Advantages:
1) Immediate Access of the desired records.
2) No sorting of the records is required.
3) Faster updating of several files.
4) Helps in online transaction processing system like online reservation systems.

Disadvantages:
1) Data may be accidentally erased or over-written unless special precautions are taken
2) Backup facility is needed
3) Expensive- hard disks are needed to store the records, it is expensive
4) Less efficient as compared to sequential file organization in the use of storage space
5) Only one key is used
6) Cannot be accessed sequentially


III) Index Sequential access file organization(ISAM)

1) This file organization is a synthesis of the above two file organizations.
2) It combines the positive features of both the sequential and direct access file organizations.
3) Here records are stored randomly on a direct access device such as magnetic disk by a primary key.
Hence, we can access data either sequentially or randomly using the index. The index is stored in a
file and read into memory when the file is opened.
4) It may have multiple keys. These keys can be alphanumeric
5) The key upon which the data records are ordered is called the primary key.
6) Other keys are called alternate keys

Advantages:
1) Multilpe keys – are also alphanumeric in nature
2) Both sequential and random access is possible
3) Accessing of records is fast, if the index table is properly organized

Disadvantages:

1) More storage space is needed because of the presence of Index
2) Less efficient in the use of storage space as compared to other file organizations
3) It requires special software, i.e expensive.

Call by value and Call by refrence

Explain call by value and call by reference with example.

Call by value-
When a function call is given, a relationship is established between actual and formal parameters.
A temporary storage is created for formal parameters to store the data(actual parameters) received
as input from calling function. This process of data transfer from actual parameter to formal
parameters is known as call by value.

Ex: void main()
{ int a=20,b=30,x;
int f1(int,int);
-----
x=f1(a,b);
-----
getch( );
}
int f1(int p, int q)
{
p=p+p;
q=q+q;
return(p+q);
}

Call by reference-
When a function is called, the address of variables are passed on to the
called function. The parameters receiving the address should be pointer variables. This
concept of sending the address of data from calling function to pointer variables in the
called function is known as call by reference.

Ex: viod main()
{
int a=10,b=15,c=20;
------
X=f1(&a,&b,&c);
------
getch();
}
int f1(int *p1, int  *p2, int  *p3)
{
*p1=*p1+10;
*p2=*p2+5;
}

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...