From Twitter

QUERY PROCESSING AND EVALUATION

The Query Language – SQL is one of the main reasons of success of RDBMS. A user just needs to specify the query in SQL that is close to the English language and does not need to say how such query is to be evaluated. However, a query needs to be evaluated efficiently by the DBMS. But how is a query-evaluated efficiently? This unit attempts to answer this question. The unit covers the basic principles of query evaluation, the cost of query evaluation, the evaluation of join queries, etc. in detail. It also provides information about query evaluation plans and the role of storage in query evaluation and optimisation. This unit thus, introduces you to the complexity of query evaluation in DBMS.

let us begin by defining query processing. Let us take a look at the Figure





In the first step Scanning, Parsing, and Validating is done to translate the query into its internal form. This is then further translated into relational algebra (an intermediate query form). Parser checks syntax and verifies relations. The query then is optimised with a query plan, which then is compiled into a code that can be executed by the database runtime processor.
We can define query evaluation as the query-execution engine taking a query-evaluation plan, executing that plan, and returning the answers to the query. The query processing involves the study of the following concepts:
 • how to measure query costs?
• algorithms for evaluating relational algebraic operations.
• how to evaluate a complete expression using algorithms on individual operations?


STATISTICAL DATABASE SECURITY MCA

we have discussed the basic security measures in both DBMS and SQL commands that provide necessary permissions to the users. However, in practice there are many database systems where information can be determined without having the access rights to do so. This is a breach of data confidentiality. In the subsequent subsection we discuss this problem and the way to resolve it

Types of Disclosures
Data of an organisation is a very sensitive resource. Even the characteristics of data are quite sensitive. For example, existence of a piece of data such as “use of health related drugs” is sensitive information and is a form of disclosure. The various type of disclosure may be:
  • Exact Data: It may be defined as the determination of the value of an item by using a sequence of complex queries.
  • Bounds: It is defined as finding the value of data item between two values. The bounds in such cases may be lowered using binary search. This may lead to a very narrow range.
  • Negative Result: Sometimes it may be possible to determine a negative result.This is also a form of disclosure.
  •  Existence: The existence of data value in itself is a sensitive piece of information, regardless of the actual value. For example, existence of a record regarding defence expenses may be a disclosure.
Please note that such disclosure of data can be obtained without making a direct query to the database but rather a set of queries. We will explain it with the help of an example in the next sub-section. Please remember “A good security scheme needs to protect data using access control while avoiding such indirect disclosures”.

Security vs. Decisions
Disclosure of data as indicated in the previous section is a major problem as disclosure may result in breach of security in some form or the other, and thus, is not acceptable. Thus, the first step in this direction would be to reject any query that directly asks for sensitive information that is hidden. But, how about a sequence of queries that are raised for the purpose of statistics (management information)? For example, we may be able to determine the average marks obtained in a class of 50 student, but if only 2 students have opted for a subject then the first student who knows his/her marks can find the marks of the other student by issuing the average marks query. Thus, statistical queries should be permitted only when some minimum number of records satisfies a condition. Thus, the overall objectives are to make sure that security is not compromised.

Let us discuss some of the queries that may result in the disclosure of sensitive data.
Consider the relation in the following Table:

Assume that a student can not only view his/her details in the Table, but also the names of his/her colleagues, and that s/

ACCESS CONTROL In Relational Database

All relational database management systems provide some sort of intrinsic security mechanisms that are designed to minimise security threats as stated in the previous section. These mechanism range from the simple password protection offered in Microsoft Access to the complex user/role structure supported by advanced relational databases like Oracle and Microsoft SQL Server. But can we define access control for all these DBMS using a single mechanism?

SQL provides that interface for access control. Let us discuss the security mechanisms common to all databases using the Structured Query Language (SQL).

An excellent practice is to create individual user accounts for each database user. Although, sharing of user accounts among various users is possible or even one user account can be created for each type of user, however, such a practice should be discouraged.

 Why? It could be because of the following reasons:

It will eliminate individual accountability: If any one of the users make a change in the database, we will not be able to trace it back to a specific individual even after going through audit logs. Imagine what would happen when a specific user leaves the organisation and his or her access from the database is to be removed? It will require change in the password and this will cause inconvenience to other users.
Thus, it is important that we provide separate user accounts for separate users.

Does this mechanism have any drawbacks? If the expected number of database users are small then it is all right to give them individual user name and passwords and all the database access privileges that they need to have on the database items.

However, consider a situation when there are a large number of users. Specification of access rights to all these users individually will take a long time. That is still manageable as it may be a one time effort, however, the problem will be compounded if we need to change the access right for a particular type of users. Such an activity would require a huge maintenance cost. This cost can be minimised if we use a specific concept called “Roles”. A database may have hundreds of users but their access rights may be categorised in specific roles for example, teachers, student in a university database. Such roles would require specification of access rights only once for the role. The users then can be assigned username, password and specific role. Thus, the maintenance of user accounts becomes easier as now we have limited roles to be maintained.

Granting Permissions
You would need to create the users or roles before you grant them permissions. Then permissions can be granted to a user or a role. This can done with the use of the SQL GRANT statement.
The syntax of this statement is:

GRANT <permissions>
[ON <table>]
TO <user/role>
[WITH GRANT OPTION]


Now, let us define this statement line-by-line. The first line, GRANT <permissions>, allows you to specify the specific permissions on a table. These can be either relation-level data manipulation permissions (such as SELECT, INSERT, UPDATE and DELETE) or data definition permissions (such as CREATE TABLE, ALTER DATABASE and GRANT). More than one permission can be granted in a single GRANT statement, but data manipulation permissions and data definition permissions may not be combined in a single statement.

The second line, ON <table>, is used to specify the table on which permissions are being given. This line is not needed if we are granting data definition permissions.
The third line specifies the user or role that are being granted permissions.
Finally, the fourth line, WITH GRANT OPTION, is optional. If this line is included in the statement, the user is also permitted to grant the same permissions that s/he has received to other users. Please note that the WITH GRANT OPTION cannot be specified when permissions are assigned to a role.

Example 1: Assume that you have recently hired a group of 25 data entry operators who will be adding and maintaining student records in a university database system. They need to be able to access information in the STUDENT table, modify this information and add new records to the table. However, they should not be able to entirely delete a record from the database Solution: First, you should create user accounts for each operator and then add them all to a new role-Dataentry. Next, we would need to use the following SQL statement to grant them the appropriate permissions:

GRANT SELECT, INSERT, UPDATE
ON STUDENT
TO Dataentry


And that is all that you need to do. Let us now examine a case where we are assigning data definition permissions.Example 2: We want to allow members of the DBA role to add new tables to our database. Furthermore, we want them to be able to grant other users permission to do the same.
Solution: The SQL statement to do so is:
 
GRANT CREATE TABLE
TO DBA
WITH GRANT OPTION


Notice that we have included the WITH GRANT OPTION line to ensure that our DBAs can assign this permission to other users. At this point, we have discussed how to assign permissions to users and roles as necessary. We will now look at the methods for removing permissions from users.
Removing Permissions Once we have granted permissions, it may be necessary to revoke them at a later date. SQL provides us with the REVOKE command to remove granted permissions. The following is the syntax of this command:
 
REVOKE [GRANT OPTION FOR] <permissions>
ON <table>
FROM <user/role>

 
Please notice that the syntax of this command is almost similar to that of the GRANT command. Please also note that the WITH GRANT OPTION is specified on the REVOKE command line and not at the end of the command as was the case in GRANT. As an example, let us imagine we want to revoke a previously granted permission to the user Usha, such that she is not able to remove records from the STUDENT database. The following commands will solve the problem:

REVOKE DELETE
ON STUDENT
FROM Usha


There is one additional mechanism supported by some commercial DBMS that is worth discussing − the DENY command. This command can be used to explicitly deny permission to a user that s/he might otherwise have received because of his/her membership of a role. Here is the syntax:
 
DENY <permission>
ON <table>
TO <user/role>


Consider the last problem again, let us imagine that Usha was also a member of the Teachers role that also had access to the STUDENT table. The previous REVOKE statement would not be sufficient to deny her access to the table. It will remove the permission granted to her through a GRANT statement, but would not affect the permissions gained through her membership in the Teachers role. However, if we use a DENY statement it will block permission for any role. Here is the command:
 
DENY DELETE
ON STUDENT
TO Usha

 
Thus DENY command creates a “NOT PERMITTED” statement in the database access controls. If we later want to give Usha permission to remove student records again from the STUDENT table, we cannot simply use the GRANT command. This is because of the fact that the GRANT command permission to DELETE record would be overridden by the existing DENY. Thus, first we use the REVOKE command to remove the DENY Not permission as:

REVOKE DELETE
ON STUDENT
FROM Usha

 
Please notice that this command is exactly the same as the REVOKE used to remove a granted permission. Thus, the DENY and GRANT commands both work in a similar fashion -- they both create permissions in the database access control mechanism. The REVOKE command removes all such permissions for the specified user. Once this command has been issued, Usha will be able to delete student records from the table if she is a member of a role that possesses that permission. You can also issues a GRANT command to provide the DELETE permission to Usha’s account.

The access control mechanisms supported by the Standard Query Language is a good starting point, but you must look into the DBMS documentation to locate the enhanced security measures supported by your system. You will find that many DBMS support more advanced access control mechanisms, such as granting permissions on specific attributes.

LEVELS OF DATABASE SECURITY

As is true for any other technology, the security of database management systems depends on many other systems. These primarily include the operating system, the applications that use the DBMS, services that interact with the DBMS, the web server that makes the application available to end users, etc. However, please note that most importantly, DBMS security depends on us, the-users.

Common Database Security Failures :Database security is of paramount importance for an organisation, but many organisations do not take this fact into consideration, till an eventual problem occurs. The common pitfalls that threaten database security are 
  • Weak User Account Settings: Many of the database user accounts do not contain the user settings that may be found in operating system environments. For example, the user accounts name and passwords, which are commonly known, are not disabled or modified to prevent access.          The user account settings allow limited capabilities for security, without password controls on dictionary checks or account controls supporting expiration of user account. 
  • Insufficient Segregation of Duties:No established security administrator role is defined in the database management of the organisation. This results in database administrators (DBAs) performing both the functions of the administrator (for users accounts), as well as the performance and operations expert. This may result in management inefficiencies 
  • Inadequate Audit Trails:The auditing capabilities of databases since it require keeping track of additional requirements, are often ignored for enhanced performance or disk space. Inadequate auditing results in reduced accountability. It also reduces the effectiveness of data history analysis. The audit trails records information about the actions taken on certain critical of data. They log events directly associated with the data, thus, they are essential for monitoring the access and the activities on a database system. 
  • Unused DBMS Security Features: The security of an individual application is usually independent of the security of the DBMS. Please note that security measures that are built into an application apply to users of the client software only. The DBMS itself and many other tools or utilities that can connect to the database directly through ODBC or any other protocol, may bypass this application level security completely. Thus, you must try to use security restrictions that are reliable, for instance, try using security mechanism that are defined within the database.

Basically database security can be broken down into the following levels:
• Server Security
• Database Connections
• Table Access Control
• Restricting Database Access.
  1.  Server Security   Server security is the process of controlling access to the database server. This is the most important aspect of security and should be carefully planned. The basic idea here is “You cannot access what you do not see”.  For security purposes, you should never let your database server be visible to the world. If a database server is supplying information to a web server then it should be configured in such a manner that it is allowed connections from that web server only. Such a connection would require a trusted IP address. 
  2. Trusted IP Addresses To connect to a server through a client machine, you would need to configure the server to allow access to only trusted IP addresses. You should know exactly who should be allowed to access your database server. For example, if it is the back end of a web server, then only that web server address should be allowed access to the database server. If the database server is the back end of a local application that is running on the internal network, then it should only talk to addresses from within the internal network. 
  3. Database Connections With the ever-increasing number of Dynamic Applications, an application may allow immediate unauthenticated updates to some database. If you are going to allow users make updates to some database via a web page, please ensure that you validate all such updates. This will ensure that all updates are desirable and safe. For example, you may remove any possible SQL code from a user-supplied input. If a normal 
  4. Table Access Control  Table access control is probably one of the most overlooked but one of the very strong forms of database security because of the difficulty in applying it. Using a table access control properly would require the collaboration of both the system administrator as well as the database developer. In practise, however such “collaboration” is relatively difficult to find. 
  5. Restricting Database Access  By now we have defined some of the basic issues of database security, let us now look into the specifics of server security, from the point of view of network access of the system. Internet based databases have been the most recent targets of security attacks. All web-enabled applications listen to a number of ports. Cyber criminals often perform a simple “port scan” to look for ports that are open from the popular default ports used by database systems. How can we address this problem? We can address this problem “by default”, that is, we can change the default ports a database service would listen into. Thus, this is a very simple way to protect the DBMS from such criminals.
There are many ways of preventing open access from the Internet. Each DBMS and OS has its own set of unique features for the same. Let us discuss some general methods of preventing open access from the Internet.

Trusted IP addresses : UNIX servers are configured to answer ping requests only from a list of trusted hosts. In UNIX, this can be accomplished by configuring the rhosts file. Thus, it restricts server access to a list of specific users only.

Server Account Disabling : It may be a good idea to suspend the server ID after three failed password attempts. This may thwart attackers. If such a scheme is not implemented, then an attacker can run a brute force program that generates millions of passwords. Such a program ultimately would break the combination of the user ID and password.

Special Tools : Some customised tools, for example, Real Secure, send an alert when an external server is attempting to breach your system security. There are many such similar products available for the protecting of the DBMS from unauthorised Internet access.

MCS-042 Solved Assignment Ques 1 of 1 Construct the Hamming code for the bit sequence 10011101

Solution
First we find redundant bits (r) such that 2r >= r+m+1
so here r = 4

so there are 4 redundant bits;
r1,r2,r4,r8       

so bits after insertion redundant bits.....
1  0  0  1  r8  1  1  0 r4  1 r2  r1
^                 .....................           ^
12th bit                                    1st bit   (r1)
r1 is calculated from even parity of bits number ( 1,3,5,7,9,11)
r2 is calculated from even parity of bits  (2,3,6,7,10,11)
r4 is calculated from even parity of bits (4,5,6,7,12)
r8 is calculated from even parity of bits (8,9,10,11,12)

calculation of r1
as bit no. 3 = 1
    bit no. 5 = 0
    bit no. 7 = 1
    bit no. 9 = 1
    bit no. 11=0to make no. of 1's even we have r1 = 1


count no of 1's for which r2 take cares of bit (2,3,6,7,10,11)
no of 1's are found to be = 3 (on bit 3,6,7)

its clearly odd (for even parity we have to make no of 1's = even , if already no of one is even then simply r = 0)

so what we do we will make r2 = 1 to make no of 1's = even

similarly ,
r2 =1

r4=1

r8=0

Hence Following are the redundancy bits.

r1 = 1
r2 = 1
r4 = 1
r8 = 0

So the Hamming code is 100101101111

MCA 4th Semester MCS-041 Question 2 The Sleeping-Barber Problem:

MCA 4th Semester MCS-041 Question 2 The Sleeping-Barber Problem:

QUESTION 1: A barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy, but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber.
Write an interactive program in C / C++ to synchronize/coordinate the barber and the customers.

Solution : 

MCA 4th semester Solved Assignment MCS-041 Operating Systems Question 1 Consider the following set of processes, with the length of the CPU-burst time given in milliseconds

QUESTION 1  : MCA 4th semester Solved Assignment  MCS-041 Operating Systems Question 1

Consider the following set of processes, with the length of the CPU-burst time given in milliseconds:

ProcessBurst TimePriority
P1103
P231
P343
P454
P56
The processes are assumed to have arrived in the order P1, P2, P3, P4, and P5, all at the same time.
  • a. Draw Gantt charts illustrating the execution of these processes using FCFS, SJF, a non-preemptive priority (a smaller priority number implies a higher priority), and Round Robin(quantum = 1) scheduling.?
  • b. What is the turn around time of each process for each of the scheduling algorithms in part a?
  • c. What is the waiting time of each process for each of the scheduling algorithms in part a?
  • d. Explain the evaluation of each algorithm.?

SOLUTION: ....

Labels

(MCS-031 (6) 2011 (5) 4nf (1) 5nf (1) ACCESS CONTROL In Relational Database (1) ALGORITHMICS (5) assignment 2014 2015 (1) AVAILABLE TOOLS & ALGORITHMS (5) BCA (1) BINARY SEARCH (1) Block Nested Loop Join (1) Build and Fix Model (1) BUILDING BLOCKS OF ALGORITHMS (1) CHARACTERISTICS OF AN ALGORITHM (2) Core Java (1) Data Communication Network Security (1) DATABASE SECURITY (1) EER tool (1) ELEMEMTARY ALGORITHMICS (2) ENHANCED ER TOOLS (1) EVOLUTION (1) EXAMPLE OF AN ALGORITHM (2) Indexed Nested-Loop Join (1) install servelet engine (1) INTRODUCTION (1) Iterative Enhancement Model (1) Java Server Pages (1) JDBC (1) JSP (2) LEVELS OF DATABASE SECURITY (1) MCA (9) MCA 051 (1) MCA 3rd Semester (8) MCA 4th Semester (1) MCA 5 sem (1) MCS-031 (7) MCS-031 : DESIGN AND ANALYSIS OF ALGORITHM (14) MCS-032 (1) MCS-033 (1) MCS-034 (2) MCS-035 (1) mcs-041 (2) MCS-042 (1) mcs-043 (2) mcs-052 solved assignment (1) MCSL-036 (2) Nested loop join (1) OBJECTIVES (1) Operating System (2) OUTLINE OF ALGORITHMICS (1) Principles of Management and Information Systems (1) PROBLEMS (1) QUERY PROCESSING AND EVALUATION (1) Query processing Optimisation (1) Question Papers (8) Related Topic (9) relational Database (1) SELECT OPERATION Query Processing (1) Servlet (1) Servlet Programme (1) Servlet Programming (1) SOFTWARE DEVELOPMENT MODELS (4) SOFTWARE ENGINEERING (4) Solution (7) Solved Assignment 2013 2014 (6) SOME PRE-REQUISITES AND Asymptotic Bounds ASYMPTOTIC BOUNDS INTRODUCTION (1) STATISTICAL DATABASE SECURITY (1) structure (1) SUMMARY (1) Waterfall Model (1) Write a C program to print the following triangle (1)