answersLogoWhite

0

📱

Database Programming

Databases are collections of tables that maintain and display information, often collaboratively; this information can be used for interaction with an application or gaining general knowledge. Questions about database engines and modifying or using them belong in this category.

8,803 Questions

What is relational algebra in DBMS explain with suitable example?

Relational algebra

In order to implement a DBMS, there must exist a set of rules which state how the database system will behave. For instance, somewhere in the DBMS must be a set of statements which indicate than when someone inserts data into a row of a relation, it has the effect which the user expects. One way to specify this is to use words to write an `essay' as to how the DBMS will operate, but words tend to be imprecise and open to interpretation. Instead, relational databases are more usually defined using Relational Algebra.

Relational Algebra is :

  • the formal description of how a relational database operates
  • an interface to the data stored in the database itself
  • the mathematics which underpin SQL operations

Operators in relational algebra are not necessarily the same as SQL operators, even if they have the same name. For example, the SELECT statement exists in SQL, and also exists in relational algebra. These two uses of SELECT are not the same. The DBMS must take whatever SQL statements the user types in and translate them into relational algebra operations before applying them to the database.

Terminology
  • Relation - a set of tuples.
  • Tuple - a collection of attributes which describe some real world entity.
  • Attribute - a real world role played by a named domain.
  • Domain - a set of atomic values.
  • Set - a mathematical definition for a collection of objects which contains no duplicates.
Operators - Write
  • INSERT - provides a list of attribute values for a new tuple in a relation. This operator is the same as SQL.
  • DELETE - provides a condition on the attributes of a relation to determine which tuple(s) to remove from the relation. This operator is the same as SQL.
  • MODIFY - changes the values of one or more attributes in one or more tuples of a relation, as identified by a condition operating on the attributes of the relation. This is equivalent to SQL UPDATE.
Operators - RetrievalThere are two groups of operations:
  • Mathematical set theory based relations:

    UNION, INTERSECTION, DIFFERENCE, and CARTESIAN PRODUCT.

  • Special database operations:

    SELECT (not the same as SQL SELECT), PROJECT, and JOIN.

Relational SELECTSELECT is used to obtain a subset of the tuples of a relation that satisfy a select condition.

For example, find all employees born after 1st Jan 1950: SELECTdob '01/JAN/1950'(employee)

Relational PROJECTThe PROJECT operation is used to select a subset of the attributes of a relation by specifying the names of the required attributes.

For example, to get a list of all employees surnames and employee numbers: PROJECTsurname,empno(employee)

SELECT and PROJECTSELECT and PROJECT can be combined together. For example, to get a list of employee numbers for employees in department number 1:Figure : Mapping select and project Set Operations - semanticsConsider two relations R and S.
  • UNION of R and S

    the union of two relations is a relation that includes all the tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated.

  • INTERSECTION of R and S

    the intersection of R and S is a relation that includes all tuples that are both in R and S.

  • DIFFERENCE of R and S

    the difference of R and S is the relation that contains all the tuples that are in R but that are not in S.

SET Operations - requirementsFor set operations to function correctly the relations R and S must be union compatible. Two relations are union compatible if
  • they have the same number of attributes
  • the domain of each attribute in column order is the same in both R and S.
UNION ExampleFigure : UNION INTERSECTION ExampleFigure : Intersection DIFFERENCE ExampleFigure : DIFFERENCE CARTESIAN PRODUCTThe Cartesian Product is also an operator which works on two sets. It is sometimes called the CROSS PRODUCT or CROSS JOIN.

It combines the tuples of one relation with all the tuples of the other relation.

CARTESIAN PRODUCT exampleFigure : CARTESIAN PRODUCT JOIN OperatorJOIN is used to combine related tuples from two relations:
  • In its simplest form the JOIN operator is just the cross product of the two relations.
  • As the join becomes more complex, tuples are removed within the cross product to make the result of the join more meaningful.
  • JOIN allows you to evaluate a join condition between the attributes of the relations on which the join is undertaken.

The notation used is R JOINjoin condition S

JOIN ExampleFigure : JOIN Natural JoinInvariably the JOIN involves an equality test, and thus is often described as an equi-join. Such joins result in two attributes in the resulting relation having exactly the same value. A `natural join' will remove the duplicate attribute(s).
  • In most systems a natural join will require that the attributes have the same name to identify the attribute(s) to be used in the join. This may require a renaming mechanism.
  • If you do use natural joins make sure that the relations do not have two attributes with the same name by accident.
OUTER JOINsNotice that much of the data is lost when applying a join to two relations. In some cases this lost data might hold useful information. An outer join retains the information that would have been lost from the tables, replacing missing data with nulls.

There are three forms of the outer join, depending on which data is to be kept.

  • LEFT OUTER JOIN - keep data from the left-hand table
  • RIGHT OUTER JOIN - keep data from the right-hand table
  • FULL OUTER JOIN - keep data from both tables
OUTER JOIN example 1Figure : OUTER JOIN (left/right) OUTER JOIN example 2Figure : OUTER JOIN (full)

What are international databases?

A collection of data or records is what we call a database. A database can be either internal or it can be external. An Internal database is one like in an organization which is only accessible by the organization's people.

What is data anomaly?

Data Anomaly are the logical or structural in database.For example, if we have a multiple instances of same information in a table, it may happen that the data is not consistent after operations like update. This may result in the loss od data integrity.

Describe the differences in meaning between the terms relation and relation schema?

Relational Schema refers to meta-data elements which are used to describe structures and constraints of data representing a particular domain. Whereas a relation is a property or predicate that ranges over more than one argument Here's some translation from "Relational Algebra" to SQL terminology: * "Relation" = Table. * "Relation Schema" = Table definition. So for example, the "schema" for the Person "relation" is: Person(FirstName, LastName, Age, Gender, Address) Also in relational Algebra, a "tuple" is a table row, and an "attribute" is a table column.
Mathematician define a relation to be subset of cartesian product list of domains.

In daabase relation is a set of entities with similar attributes.

In other way we can consider a relation as a table and it's rows as entities, and table's columns as attributes.Concept of relation corresponds to programming language notion of variable.

relational Schema corresponds to the programming language notion of type definition.

It is the logical design of database.

e.g. for a relation account having attributes account_number, branch_name and balance, relational schema is specified as -

Account_schema= (account_number, branch_name, balance)

What are the attributes of a firefighter?

There can be various attributes of an element. Firefighter could be a custom tag with various attributes.

What are the examples of data anomalies?

I try to answer as simple as people can understand. Island Of Information means the same data (such scattered data locations) separated at the different places. Data Anomaly caused by Island Of Information. We can say that Data Anomaly is something wrong with the data or information. Some examples are Modification Anomalies(data cannot be deleted), Insertion Anomalies(data cannot be inserted) and Deletion Anomalies(data cannot be deleted).

What are the advantages and disadvantages of Associative model?

With the Associative model there is not record. When assembling all of the current information on a complex order the data storage needs to be re-visited multiple times. This could pose as a disadvantage. Some calculations seem to suggest that Associative database would need as many as four times the data reads as the relational database.

What are the examples for data redundancy?

i think it mite be something like well i dont know i have forgoten now what the answer was hold on a second wait i have remembered i think it is poo i now i am wrong so i dont think that it is that (poo) anyway sorry i couldnt help u why dont u just ask ur parents? or people around u?

What step is data either written to the file or read from the file?

Insertion is the process of writing data to a file. Extraction is the process of reading data from a file. More generally we use the terms output and inputrespectively. However, the output of one process can often be used as the input for another. Therefore the terms must be applied within the context of the objects being read from or written to.

What are flat files?

In database management, a flat file is one that holds all the information in a single table.

By contrast, a relational database has two or more tables having a defined relationship to each other.

A flat file is not related to any other table.

Examples

Flat file

You could keep details of a DVD collection in a flat file. Some of the fields might be:

title

date purchased

length

year issued

Relational database

A retail business might have a database with three tables:

products [one record for each type of item for sale]

customers

products&customers [each sale constitutes a record in this table. The table is related (linked) to each of the other two tables]

Tables and files

"Table" is a database term, "file" a computer term. Some database management programs make each table into a separate file. Others store all the tables in a single file.

Sketch all binary tree with six pendent vertices?

The weights are tabulated in table given below.

V1V2V3V4V5V6V1-1016111017V210-9.5InfInf19.5V3169.5-7Inf12V411Inf7-87V510InfInf8-9V61719.51279-

What is a registered entity?

one that has been registered at the local county level. Meaning an individual has paid for the use of the name registered - good for 5 years in most counties.

What is meant by crosswalk when working with databases?

Also referred to as a schema crosswalk, when someone talks about a crosswalk, what they are generally talking about is a table that allows for references to be built that allow the way data is stored in one database to be matched up with data in another database.

For instance, let's say a school district's student database software keeps track of the gender of each student with a single character field that codes females with an "F" and males with an "M".

The school district is required to upload data about their students to the state in which it operates for analysis, but the state wants to see males coded as "XY" and females coded as "XX".

A crosswalk would need to be created that would convert the gender data in the export process. The crosswalk may look something like this:

F -- XX

M -- XY

The methods of collecting information for job analysis in an organization?

Methods of Collecting Job Analysis Data A variety of methods are used to collect information about jobs. None of them, however, is perfect. In actual practice, therefore, a combination of several methods is used for obtaining job analysis data. These are discussed below. Job performance In this method the job analyst actually performs the job in question. The analyst, thus, receives first hand experience of contextual factors on the job including physical hazards, social demands, emotional pressures and mental requirements. This method is useful for jobs that can be easily learned. It is not suitable for jobs that are hazardous (e.g., fire fighters) or for jobs that require extensive training (e.g., doctors, pharmacists). Personal observation The analyst observes the worker(s) doing the job. The tasks performed, the pace at which activities are done, the working conditions, etc., are observed during a complete work cycle. During observation, certain precautions should be taken The analyst must observe average workers during average conditions. The analyst should observe without getting directly involved in the job. The analyst must make note of the specific job needs and not the behaviors specific to particular workers. The analyst must make sure that he obtains a proper sample for generalization. This method allows for a deep understanding of job duties. It is appropriate for manual, short period job activities. On the negative side, the methods fail to take note of the mental aspects of jobs. Critical incidents The critical incident technique (CIT) is a qualitative approach to job analysis used to obtain specific, behaviorally focused descriptions of work or other activities. Here the job holders are asked to describe several incidents based on their past experience. The incidents so collected are analyzed and classified according to the job areas they describe. The job requirements will become clear once the analyst draws the line between effective and ineffective behaviors of workers on the job. For example, if a shoe salesman comments on the size of a customer’s feet and the customer leaves the store in a huff, the behavior of the salesman may be judged as ineffective in terms of the result it produced. The critical incidents are recorded after the events have already taken place – both routine and non-routine. The process of collecting a fairly good number of incidents is a lengthy one. Since, incidents of behavior can be quite dissimilar, the process of classifying data into usable job descriptions can be difficult. The analysts overseeing the work must have analytical skills and ability to translate the content of descriptions into meaningful statements. Interview The interview method consists of asking questions to both incumbents and supervisors in either an individual or a group setting. The reason behind the use of this method is that job holders are most familiar with the job and can supplement the information obtained through observation. Workers know the specific duties of the job and supervisors are aware of the job’s relationship to the rest of the organization. Due diligence must be exercised while using the interview method. The interviewer must be trained in proper interviewing techniques. It is advisable to use a standard format so as to focus the interview to the purpose of analyst. Although the interview method provides opportunities to elicit information sometimes not available through other methods, it has limitations. First, it is time consuming and hence costly. Second, the value of data is primarily dependent on the interviewer’s skills and may be faulty if they put ambiguous questions to workers. Last, interviewees may be suspicious about the motives and may distort the information they provide. If seen as an opportunity to improve their positions such as to increase their wages, workers may exaggerate their job duties to add greater weightage to their positions. Questionnaire method The questionnaire is a widely used method of analyzing jobs and work. Here the job holders are given a properly designed questionnaire aimed at eliciting relevant job-related information. After completion, the questionnaires are handed over to supervisors. The supervisors can seek further clarifications on various items by talking to the job holders directly. After everything is finalized, the data is given to the job analyst. The success of the method depends on various factors. The structured questionnaire must cover all job related tasks and behaviors. Each task or behavior should be described in terms of features such as importance, difficulty, frequency, and relationship to overall performance. The job holders should be asked to properly rate the various job factors and communicate the same on paper. The ratings thus collected are then put to close examination with a view to find out the actual job requirements. Questionnaire method is highly economical as it covers a large number of job holders at a time. The collected data can be quantified and processed through a computer. The participants can complete the items leisurely. Designing questionnaires, however, is not an easy task. Proper care must be taken to see that the respondents do not misinterpret the questions. Further, it is difficult to motivate the participants to complete the questionnaires truthfully and to return them.

Write a function using reference variables as arguments to swap the values of a pair of integers?

#include<iostream>

using namespace std;

void swap(int &i, int &j)

{

int temp = i;

i = j;

j = temp;

}

int main()

{

int i,j;

cin>>i>>j;

cout << i << j << endl;

swap(i,j);

cout << i << j;

return 0;

}

What is the difference between pipe-lining and materialization?

in adbms,,these are the two approaches to query processing..

in materialization approach,we start from the lowest level operations in the expressions.the inputs to the lowest level operations are the relations in the database.we execute the lowest level operations on the input relations and store the result in temporary relations.

in pipelining approach,several relational operations are combined into a pipeline of operations,in which the results of one operation are passed along to the next operation in the pipeline.

pipelining is advantageous since it eliminates the cost of reading and writing temporary relations

Why a bridge using filtering table and router using routing table?

A bridge can filter, forward based on its MAC address forwarding table. The bridge will note any MAC address that is the source address on a frame and the port that the frame was received. Then it will forward or filter depending upon the forwarding table. If a MAC address is found on more than one port (because of loops in the network) then the frame is forwarded on both ports. If a frame is received on a port and the destination MAC address is only found on that port then the frame is filtered and discarded. If the destination MAC address is not found in the forwarding table, then the bridge will flood the frame out all ports except the receiving port.

A router will build a routing table based on the routing protocol that is being used in the router. The routing protocol (RIP, RIPv2, AS-AS, OSPF etc) will have a method of identifying the best route to send the IP packet to the destination. When an IP frame is received then it will be routed on the best route to the destination

Different between manual and electronic typerwriter?

A manual typewriter cannot have multiple fonts being used at the same time. The cylindrical type heads of a manual typewriter were also replaced with a spherical type ball in the electronic version.

What is external schema?

The role of the external schema is to support user views of data and thus to provide programmers with easier data access

What are the importance of computerization?

The importance of computerization is that it improves efficiency. Information can be shared centrally in a database. Tasks are processed at a very high rate.

What is the relationship between JSP and JDBC?

There is no other relation apart from having Java in their names.

JSP is a technology that is used to create powerful User Interface components

whereas

JDBC is a technology that is used to connect to Relational Databases like Oracle or Sybase