Professional Documents
Culture Documents
Cryptography ?
Cryptography defined as "the science and study of secret writing," concerns the
ways in which communications and data can be encoded to prevent disclosure of
their contents through eavesdropping or message interception, using codes (2),
ciphers (3), and other methods, so that only certain people can see the real
message. Although the science of cryptography is very old, the desktop-computer
revolution has made it possible for cryptographic techniques to become widely
used and accessible to nonexperts. David Kahn traces the history of cryptography
from Ancient Egypt into the computer age (4). According to Kahn's research from
Julius Caesar to Mary, Queen of Scots (5) to Abraham Lincoln's Civil War ciphers,
cryptography has been a part of the history. Over the centuries complex computer-
based codes, algorithms and machines were created. During World War I, the
Germans developed the Enigma machine to have secure communications (6).
Enigma codes were decrypted under the secret Ultra project during World War II
by the British.
3
What is Encryption ?
"Encryption is basically an indication of users' distrust of the security of the
system, the owner or operator of the system, or law enforcement
authorities." (7)
"As the economy continues to move away from cash transactions towards
"digital cash", both customers and merchants will need the authentication
provided by unforgeable digital signatures in order to prevent forgery and
transact with confidence." (12)
This is an important issue related to the Internet users. There are many companies
and even shopping malls selling anything from flowers to bottles of wines over the
Internet and these transactions are made by the use of credit cards and secure
Internet browsers including encryption techniques. The customers over the Internet
would like to be secure about sending their credit card information and other
financial details related to them over a multi-national environment. It will only
work by the use of strong and unforgeable encryption methods.
Also business and commercial companies with trade secrets use or would like to
use encryption against high-tech eavesdropping and industrial espionage.
Professionals such as lawyers, doctors, dentists or accountants who have
4
Private key systems use a single key. The single key is used both to encrypt and
decrypt the information. Both sides of the transmission need a separate key and the
key must be kept secret from. The security of the transmission will depend on how
well the key is protected. The US Government developed the Data Encryption
Standard ("DES") which operates on this basis and it is the actual US standard.
DES keys are 56 bits (16) long. The length of the key was criticised and it was
suggested that the short key was designed to be long enough to frustrate corporate
eavesdroppers, but short enough to be broken by the National Security Agency
("NSA") (17). Export of DES is controlled by the State Department. DES system is
getting old and becoming insecure. US government offered to replace the DES
with a new algorithm called Skipjack which involves escrowed encryption.
In the public key system there are two keys: a public and a private key. Each user
has both keys and while the private key must be kept secret the public key is
publicly known. Both keys are mathematically related. If A encrypts a message
with his private key then B, the recipient of the message can decrypt it with A's
public key. Similarly anyone who knows A's public key can send him a message by
encrypting it with his public key. A will than decrypt it with his private key. Public
key cryptography was developed in 1977 by Rivest, Shamir and Adleman ("RSA")
in the US. This kind of cryptography is more eficient than the private key
cryptography because each user has only one key to encrypt and decrypt all the
messages that he or she sends or receives.
1. Binary semaphore
2. Counting semaphore
Binary semaphore can take the value 0 & 1 only. Counting semaphore
can take nonnegative integer values.
Two standard operations, wait and signal are defined on the semaphore.
Entry to the critical section is controlled by the wait operation and exit
from a critical region is taken care by signal operation. The wait, signal
operations are also called P and V operations. The manipulation of
semaphore (S) takes place as following:
1. The wait command P(S) decrements the semaphore value by 1. If the resulting value becomes
negative then P command is delayed until the condition is satisfied.
P(S) or wait(S):
If S > 0 then
Set S to S-1
Else
V(S) or signal(S):
If any processes are waiting on S
Set S to S+1
Deadlock prevention.
Deadlock avoidance.
Deadlock Prevention
The deadlock prevention approach does not allow any transaction to
acquire locks that will lead to deadlocks. The convention is that when
more than one transactions request for locking the same data item, only
one of them is granted the lock.
Deadlock Avoidance
The deadlock avoidance approach handles deadlocks before they occur. It
analyzes the transactions and the locks to determine whether or not
waiting leads to a deadlock.
There are two algorithms for this purpose, namely wait-die and wound-
wait. Let us assume that there are two transactions, T1 and T2, where
T1 tries to lock a data item which is already locked by T2. The algorithms
are as follows
Wait-Die If T1 is older than T2, T1 is allowed to wait. Otherwise, if T1 is younger than T2, T1 is
aborted and later restarted.
Wound-Wait If T1 is older than T2, T2 is aborted and later restarted. Otherwise, if T1 is younger
than T2, T1 is allowed to wait.
Since there are no precautions while granting lock requests, some of the
transactions may be deadlocked. To detect deadlocks, the lock manager
periodically checks if the wait-forgraph has cycles. If the system is
deadlocked, the lock manager chooses a victim transaction from each
cycle. The victim is aborted and rolled back; and then restarted later.
Some of the methods used for victim selection are
This approach is primarily suited for systems having transactions low and
where fast response to lock requests is needed.
Transaction Location
Transactions in a distributed database system are processed in multiple
sites and use data items in multiple sites. The amount of data processing
is not uniformly distributed among these sites. The time period of
processing also varies. Thus the same transaction may be active at some
sites and inactive at others. When two conflicting transactions are located
in a site, it may happen that one of them is in inactive state. This
condition does not arise in a centralized system. This concern is called
transaction location issue.
Transaction Control
Transaction control is concerned with designating and controlling the
sites required for processing a transaction in a distributed database
system. There are many options regarding the choice of where to process
the transaction and how to designate the center of control, like
Pre-acquisition of locks requires a long time for communication delays. This increases the time
required for transaction.
In case of site or link failure, a transaction has to wait for a long time so that the sites recover.
Meanwhile, in the running sites, the items are locked. This may prevent other transactions from
executing.
If the controlling site fails, it cannot communicate with the other sites. These sites continue to keep
the locked data items in their locked state, thus resulting in blocking.
Let us assume that there are two transactions, T1 and T2. T1 arrives at
Site P and tries to lock a data item which is already locked by T2 at that
site. Hence, there is a conflict at Site P. The algorithms are as follows
Distributed Wound-Die
o If T1 is older than T2, T1 is allowed to wait. T1 can resume execution after Site P receives a
message that T2 has either committed or aborted successfully at all sites.
10
o If T1 is younger than T2, T1 is aborted. The concurrency control at Site P sends a message
to all sites where T1 has visited to abort T1. The controlling site notifies the user when T1
has been successfully aborted in all the sites.
Distributed Wait-Wait
o If T1 is older than T2, T2 needs to be aborted. If T2 is active at Site P, Site P aborts and rolls
back T2 and then broadcasts this message to other relevant sites. If T2 has left Site P but is
active at Site Q, Site P broadcasts that T2 has been aborted; Site L then aborts and rolls
back T2 and sends this message to all sites.
o If T1 is younger than T1, T1 is allowed to wait. T1 can resume execution after Site P receives
a message that T2 has completed processing.
Centralized Deadlock Detector One site is designated as the central deadlock detector.
Distributed Deadlock Detector All the sites participate in detecting deadlocks and removing
them.
Functional Dependency
Functional dependency (FD) is a set of constraints between two
attributes in a relation. Functional dependency says that if two tuples
have same values for attributes A1, A2,..., An, then those two tuples
must have to have same values for attributes B1, B2, ..., Bn.
Normalization
If a database design is not perfect, it may contain anomalies, which are
like a bad dream for any database administrator. Managing a database
with anomalies is next to impossible.
Update anomalies If data items are scattered and are not linked to each other properly, then it
could lead to strange situations. For example, when we try to update one data item having its copies
scattered over several places, a few instances get updated properly while a few others are left with
old values. Such instances leave the database in an inconsistent state.
Deletion anomalies We tried to delete a record, but parts of it was left undeleted because of
unawareness, the data is also saved somewhere else.
Insert anomalies We tried to insert data in a record that does not exist at all.
Object Oriented Database (OODB) provides all the facilities associated with object oriented
paradigm. It enables us to create classes, organize objects, structure an inheritance hierarchy and
call methods of other classes. Besides these, it also provides the facilities associated with standard
database systems. However, object oriented database systems have not yet replaced the RDBMS
in commercial business applications.
Designed to store, retrieve and manage objects created by programs written in some object
oriented languages (OOL) such as C++ or java.
Although a relational database can be used to store and manage objects, it does not understand
objects as such. Therefore, a middle layer called object manager or object-oriented layer software
is required to translate objects into tuples of a relation .
The user will create classes, objects, inheritance and so on and the database system will store and
manage these objects and classes. This second approach, thus, turns non-OOPLs into OOPLs. A
translation layer is required to map the objects created by user into objects of the database
system.
OODBMSs can provide appropriate solutions for many types of advanced database applications.
However, there are also disadvantages.
The object-oriented data model allows the 'real world' to be modeled more closely. The object,
which encapsulates both state and behavior, is a more natural and realistic representation of real-
world objects. An object can store all the relationships it has with other objects, including many-
to-many relationships, and objects can be formed into complex objects that the traditional data
models cannot cope with easily.
Extensibility
OODBMSs allow new data types to be built from existing types. The ability to factor out common
properties of several classes and form them into a superclass that can be shared with subclasses
can greatly reduce redundancy within system is regarded as one of the main advantages of object
orientation. Further, the reusability of classes promotes faster development and easier
maintenance of the database and its applications.
Unlike traditional databases (such as hierarchical, network or relational), the object oriented
database are capable of storing different types of data, for example, pictures, voice video,
including text, numbers and so on.
A single language interface between the Data Manipulation Language (DML) and the
programming language overcomes the impedance mismatch. This eliminates many of the
efficiencies that occur in mapping a declarative language such as SQL to an imperative 'language
such as 'C'. Most OODBMSs provide a DML that is computationally complete compared with SQL,
the 'standard language of RDBMSs.
Navigational access from the object is the most common form of data access in an OODBMS. This
is in contrast to the associative access of SQL (that is, declarative statements with selection based
on one or more predicates). Navigational access is more suitable for handling parts explosion,
recursive queries, and so on.
The tight coupling between data and applications in an OODBMS makes schema evolution more
feasible.
There are many areas where traditional DBMSs have not been particularly successful, such as,
Computer-Aided Design (CAD), Computer-Aided Software Engineering (CASE), Office
Information System(OIS), and Multimedia Systems. The enriched modeling capabilities of
OODBMSs have made them suitable for these applications.
Improved performance
There have been a number of benchmarks that have suggested OODBMSs provide significant
performance improvements over relational DBMSs. The results showed an average 30-fold
performance improvement for the OODBMS over the RDBMS.
Disadvantages of OODBMSs
Lack of universal data model: There is no universally agreed data model for an OODBMS,
and most models lack a theoretical foundation. This .disadvantage is seen as a significant
drawback, and is comparable to pre-relational systems.
Lack of experience: In comparison to RDBMSs the use of OODBMS is still relatively limited.
This means that we do not yet have the level of experience that we have with traditional systems.
OODBMSs are still very much geared towards the programmer, rather than the nave end-user.
Also there is a resistance to the acceptance of the technology. While the OODBMS is limited to a
small niche market, this problem will continue to exist
Competition: Perhaps one of the most significant issues that face OODBMS vendors is the
competition posed by the RDBMS and the emerging ORDBMS products. These products have an
established user base with significant experience available. SQL is an approved standard and the
relational data model has a solid theoretical formation and relational products have many
supporting tools to help .both end-users and developers.
Locking at object level may impact performance Many OODBMSs use locking as the basis
for concurrency control protocol. However, if locking is applied at the object level, locking of an
inheritance hierarchy may be problematic, as well as impacting performance.
Complexity: The increased functionality provided by the OODBMS (such as the illusion of a
single-level storage model, pointer sizzling, long-duratipntransactions, version management, and
schema evolution--makes the system more complex than that of traditional DBMSs. In
complexity leads to products that are more expensive and more difficult to use.
Lack of support for views: Currently, most OODBMSs do not provide a view mechanism,
which, as we have seen previously, provides many advantages such as data independence,
security, reduced complexity, and customization.
Lack of support for security: Currently, OODBMSs do not provide adequate security
mechanisms. The user cannot grant access rights on individual objects or classes.
If OODBMSs are to expand fully into the business field, these deficiencies must be rectified.
An INNER JOIN is the most common type of join and is the default type
of join. You can use INNER keyword optionally.
SELECT ... FROM table1 JOIN table2 USING ( column1 ,... ) ...
sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY INNER JOIN DEPARTMENT
ON COMPANY.ID = DEPARTMENT.EMP_ID;
1 Paul IT Billing
2 Allen Engineerin
7 James Finance
table is calculated the same way. Once the primary JOIN is calculated, an
OUTER join will take any unjoined rows from one or both tables, pad
them out with NULLs, and append them to the resulting table.
SELECT ... FROM table1 LEFT OUTER JOIN table2 ON conditional_expression ...
SELECT ... FROM table1 LEFT OUTER JOIN table2 USING ( column1 ,... ) ...
sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN DEPARTMENT
ON COMPANY.ID = DEPARTMENT.EMP_ID;
1 Paul IT Billing
2 Allen Engineerin
Teddy
Mark
David
Kim
7 James Finance
Dim c As Double
Dim f As Double
Private Sub CmdClr_Click()
TxtInput.Text =
TxtInput.SetFocus
End Sub
End If
End Sub
End If
End Sub
N = Val(TxtNumber.Text)
Select Case N
Case Is < 2
Lbl_Answer.Caption = "It is not a prime number"
Case Is = 2
Lbl_Answer.Caption = "It is a prime number"
Case Is > 2
D=2
Do
If N / D = Int(N / D) Then
Lbl_Answer.Caption = "It is not a prime number"
tag = "Not Prime"
Exit Do
End If
D=D+1
For j = 0 To 2
a(i, j) = InputBox("ENER THE ELEMENNTS OF 1st MATRIX")
Next j
Next i
For i = 0 To 2
For j = 0 To 2
b(i, j) = InputBox("ENER THE ELEMENNTS OF 2nd MATRIX")
Next j
Next i
For i = 0 To 2
For j = 0 To 2
c(i, j) = 0
For k = 0 To 2
c(i, j) = c(i, j) + a(i, k) * b(k, j)
Next k
Next j
Next i
For i = 0 To 2
For j = 0 To 2
Print c(i, j)
Next j
Next i
End Sub
Q.2 Write a program in VB to find largest and smallest element in
an array.
Module MaxMin
Sub Main()
Dim n, i, min, max As Integer
Console.Write("Enter the number of Elements: ")
n = CInt(Console.ReadLine())
Dim arr(n) As Integer
For i = 0 To n - 1
Console.Write("Enter the " & (i + 1).ToString & "th element: ")
arr(i) = CInt(Console.ReadLine())
Next
Console.WriteLine("Array Contains...")
For i = 0 To n - 1
Console.Write(arr(i) & " ")
Next
min = arr(0)
max = arr(0)
For i = 0 To n - 1
If arr(i) < min Then
min = arr(i)
End If
Next
For i = 0 To n - 1
If arr(i) > max Then
max = arr(i)
End If
Next
Console.WriteLine()
Console.WriteLine("Minimum=" & min)
Console.WriteLine("Maximum=" & max)
Console.ReadLine()
19
End Sub
End Module