Components of ERD


Entities : An entity is something about which the business needs to store data. An entity is a class of persons, places, objects, events or concepts about which we need to capture and store data. An entity instance is a single occurrence of an entity.

Attribute: An attribute is a descriptive property or characteristic of an entity. Synonyms include element, property and field. A compound attribute is one that actually consists of other attributes. It is also known as a composite attribute. An attribute “Address” is the example of compound attribute as shown in the following illustration

Relationships: A relationship is a natural business association that exists between one or more entities. The relationship may represent an event that links the entities.

Cardinality: defines the minimum and maximum number of occurrences of one entity that may be related to a single occurrence of the other entity. Because all relationships are bidirectional, cardinality must be defined in both directions for every relationship.

A DFD can be categorized in the following forms:ny system can be represented at any level of detail by these four symbols.

External Entities

External Entity

External entities determine the system boundary. They are external to the system being studied. They are often beyond the area of influence of the developer.These can represent another system or subsystem. These go on margins/edges of data flow diagram. External entities are named with appropriate name.

Processes

DFD Process

Processes are work or actions performed on incoming data flows to produce outgoing data flows. These show data transformation or change. Data coming into a process must be “worked on” or transformed in some way. Thus, all processes must have inputs and outputs. In some (rare) cases, data inputs or outputs will only be shown at more detailed levels of the diagrams. Each process in always “running” and ready to accept data.Major functions of processes are computations and making decisions. Each process may have dramatically different timing: yearly, weekly, daily.

Naming Processes

Processes are named with one carefully chosen verb and an object of the verb. There is no subject. Name is not to include the word “process”. Each process should represent one function or action. If there is an “and” in the name, you likely have more than one function (and process). For example, get invoice ,update customer and create Order Processes are numbered within the diagram as convenient. Levels of detail are shown by decimal notation. For example, top level process would be Process 14, next level of detail Processes 14.1-14.4, and next level with Processes 14.3.1-14.3.6. Processes should generally move from top to bottom and left to right.

Data Flow

DFD Data Flow

Data flow represents the input (or output) of data to (or from) a process (“data in motion”). Data flows only data, not control. Represent the minimum essential data the process needs. Using only the minimum essential data reduces the dependence between processes. Data flows must begin and/or end at a process.Data flows are always named. Name is not to include the word “data”. Should be given unique names. Names should be some identifying noun. For example, order, payment, complaint.

Data Stores

Data Store

or

Data Store

Data Stores are repository for data that are temporarily or permanently recorded within the system. It is an “inventory” of data. These are common link between data and process models. Only processes may connect with data stores.There can be two or more systems that share a data store. This can occur in the case of one system updating the data store, while the other system only accesses the data.

Context diagrams 
An overview of an organizational system that shows the system boundaries, external entities that interact with the system and the major information flows between the entities and the system. In this diagram, a single process represents the whole system.

First level DFD: A data flow diagram that represents a system’s major processes, data flows, and data stores at a high level of detail.

CSS handles the look and feel part of a web page. Using CSS the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used, layout designs, variations in display for different devices and screen sizes as well as a variety of other effects. CSS provides powerful control over the presentation of an HTML document. Most commonly, CSS is combined with the markup languages HTML or XHTML.

  1. You can define a style for each HTML element and apply it to as many Web pages as you want.
  2. You do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag.
  3. CSS simply change the style, and all elements in all the web pages will be updated automatically.
  4. CSS using the same HTML document, different versions of a website can be presented for handheld devices such as PDAs and cell phones or for printing.
  5. Its a good idea to start using CSS in all the HTML pages to make them compatible to future browsers.

 Java is an object-oriented programming language, we have to follow the encapsulation wherein we hide the unwanted details.

Java provides entities called “Access Modifiers or access specifiers” that help us to restrict the scope or visibility of a package, class, constructor, methods, variables, or other data members. These access modifiers are also called “Visibility Specifiers”.

Access Modifiers In Java
To ensure encapsulation and reusability, these access specifiers/modifiers are an integral part of object-oriented programming.


Modifiers in Java are of two types:

#1) Access Modifiers

Access modifiers in Java allow us to set the scope or accessibility or visibility of a data member be it a field, constructor, class, or method.

#2) Non-access Modifiers

Java also provides non-access specifiers that are used with classes, variables, methods, constructors, etc. The non-access specifiers/modifiers define the behavior of the entities to the JVM.

Some of the non-access specifiers/modifiers in Java are:

  • static
  • final
  • abstract
  • transient
  • volatile
  • synchronized
  • native
    

Types Of Access Modifiers In Java

Java provides four types of access specifiers that we can use with classes and other entities.

These are:

#1) Default: Whenever a specific access level is not specified, then it is assumed to be ‘default’. The scope of the default level is within the package.

#2) Public: This is the most common access level and whenever the public access specifier is used with an entity, that particular entity is accessible throughout from within or outside the class, within or outside the package, etc.

#3) Protected: The protected access level has a scope that is within the package. A protected entity is also accessible outside the package through inherited class or child class.

#4) Private: When an entity is private, then this entity cannot be accessed outside the class. A private entity can only be accessible from within the class






 

 

 


 A time series is simply a series of data points ordered in time. In a time series, time is often the independent variable and the goal is usually to make a forecast for the future.

We wish to predict the trend in financial markets or electricity consumption, time is an important factor that must now be considered in our models

 In a computer's central processing unit (CPU), the accumulator is a Register in which intermediate arithmetic and logic results are stored.

Without a Register like an accumulator, it would be necessary to write the result of each calculation (addition, multiplication, Shift, etc.) to main memory, perhaps only to be read right back again for use in the next operation.

Access to main memory is slower than access to a register like an accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register. Early electronic computer systems were often split into two groups, those with accumulators and those without.

Modern computer systems often have multiple general-purpose registers that can operate as accumulators, and the term is no longer as common as it once was. However, to simplify their design, a number of special-purpose processors still use a single accumulator.

Basic Concept:

Mathematical operations often take place in a stepwise fashion, using the results from one operation as the input to the next. For instance, a manual calculation of a worker's weekly payroll might look something like:

  1. look up the number of hours worked from the employee's time card
  2. look up the pay rate for that employee from a table
  3. multiply the hours by the pay rate to get their basic weekly pay
  4. multiply their basic pay by a fixed percentage to account for income tax
  5. subtract that number from their basic pay to get their weekly pay after tax
  6. multiply that result by another fixed percentage to account for retirement plans
  7. subtract that number from their basic pay to get their weekly pay after all deductions

 Servlet: A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model.

Servlet life cycle: A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths followed by a servlet.

  • The servlet is initialized by calling the init() method.
  • The servlet calls service() method to process a client's request.
  • The servlet is terminated by calling the destroy() method.
  • Finally, servlet is garbage collected by the garbage collector of the JVM.

Now let us discuss the life cycle methods in detail.

The init() Method

The init method is called only once. It is called only when the servlet is created, and not called for any user requests afterwards. So, it is used for one-time initializations, just as with the init method of applets.

The servlet is normally created when a user first invokes a URL corresponding to the servlet, but you can also specify that the servlet be loaded when the server is first started.

When a user invokes a servlet, a single instance of each servlet gets created, with each user request resulting in a new thread that is handed off to doGet or doPost as appropriate. The init() method simply creates or loads some data that will be used throughout the life of the servlet.

The init method definition looks like this −

public void init() throws ServletException {
// Initialization code...
}

The service() Method

The service() method is the main method to perform the actual task. The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the formatted response back to the client.

Each time the server receives a request for a servlet, the server spawns a new thread and calls service. The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.

Here is the signature of this method −

public void service(ServletRequest request, ServletResponse response) 
throws ServletException, IOException {
}

The service () method is called by the container and service method invokes doGet, doPost, doPut, doDelete, etc. methods as appropriate. So you have nothing to do with service() method but you override either doGet() or doPost() depending on what type of request you receive from the client.

The doGet() and doPost() are most frequently used methods with in each service request. Here is the signature of these two methods.

The doGet() Method

A GET request results from a normal request for a URL or from an HTML form that has no METHOD specified and it should be handled by doGet() method.

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Servlet code
}

The doPost() Method

A POST request results from an HTML form that specifically lists POST as the METHOD and it should be handled by doPost() method.

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Servlet code
}

The destroy() Method

The destroy() method is called only once at the end of the life cycle of a servlet. This method gives your servlet a chance to close database connections, halt background threads, write cookie lists or hit counts to disk, and perform other such cleanup activities.

After the destroy() method is called, the servlet object is marked for garbage collection. The destroy method definition looks like this −

public void destroy() {
// Finalization code...
}

The communication between the nodes in a packet data network must be precisely defined to ensure correct interpretation of the packets by the receiving intermediate and the end systems. The packets exchanged between nodes are defined by a protocol – or communications language.

There are many functions which may be need to be performed by a protocol. These range from the specification of connectors, addresses of the communications nodes, identification of interfaces, options, flow control, reliability, error reporting, synchronization, etc. In practice there are so many different functions, that a set (also known as suite or stack) of protocols are usually defined. Each protocol in the suite handles one specific aspect of the communication.

The protocols are usually structured together to form a layered design (also known as a “protocol stack”). All major telecommunication network architectures currently used or being developed use layered protocol architectures. The precise functions in each layer vary. In each case, however, there is a distinction between the functions of the lower (network) layers, which are primarily designed to provide a connection or path between users to hide details of underlying communications facilities, and the upper (or higher) layers, which ensure data exchanged are in correct and understandable form. The upper layers are sometimes known as “middleware” because they provide software in the computer which convert data between what the applications programs expect, and what the network can transport. The transport layer provides the connection between the upper (applications-oriented) layers and the lower (or network-oriented) layers.

The basic idea of a layered architecture is to divide the design into small pieces. Each layer adds to the services provided by the lower layers in such a manner that the highest layer is provided a full set of services to manage communications and run distributed applications. A basic principle is to ensure independence of layer by defining services provided by each layer to the next higher layer without defining how the services are to be performed. This permits changes in a layer without affecting other layers. Prior to the use of layered protocol architectures, simple changes such as adding one terminal type to the list of those supported by an architecture often required changes to essentially all communications software at a site. 

Microwave: Electromagnetic Spectrum consists of entire range of electromagnetic radiation. Radiation is the energy that travels and spreads out as it propagates. The types of electromagnetic radiation that makes the electromagnetic spectrum is depicted in the following screenshot.

Properties of Microwaves

Following are the main properties of Microwaves.

  • Microwaves are the waves that radiate electromagnetic energy with shorter wavelength.
  • Microwaves are not reflected by Ionosphere.
  • Microwaves travel in a straight line and are reflected by the conducting surfaces.
  • Microwaves are easily attenuated within shorter distances.
  • Microwave currents can flow through a thin layer of a cable.
  • Supports larger bandwidth and hence more information is transmitted. For this reason, microwaves are used for point-to-point communications.
  • More antenna gain is possible.
  • Higher data rates are transmitted as the bandwidth is more.
  • Antenna size gets reduced, as the frequencies are higher.
  • Low power consumption as the signals are of higher frequencies.
  • Effect of fading gets reduced by using line of sight propagation.
  • Provides effective reflection area in the radar systems.
  • Satellite and terrestrial communications with high capacities are possible.
  • Low-cost miniature microwave components can be developed.
  • Effective spectrum usage with wide variety of applications in all available frequency ranges of operation.

 

StringStringBuffer
String is slow and consumes more memory when you concat too many strings because every time it creates new instance.StringBuffer is fast and consumes less memory when you concat strings.
String class overrides the equals() method of Object class. So you can compare the contents of two strings by equals() method.StringBuffer class doesn't override the equals() method of Object class.


Q8. a) What is proxy server? Explain URL class and its methods in java.

Answer : - A proxy server is basically another computer which serves as a hub through which internet requests are processed. By connecting through one of these servers, your computer sends your requests to the server which then processes your request and returns what you were wanting. In this way it serves as an intermediary between your home machine and the rest of the computers on the internet.

Proxies are used for a number of reasons such as :

  • Control internet usage in corporate networks
  • Bandwidth savings for large networks
  • Monitoring and Filtering
  • Privacy (hide your IP address, location, and other information)
  • Security

Constructors of Java URL class

URL(String spec)
Creates an instance of a URL from the String representation.

URL(String protocol, String host, int port, String file)
Creates an instance of a URL from the given protocol, host, port number, and file.

URL(String protocol, String host, int port, String file, URLStreamHandler handler)
Creates an instance of a URL from the given protocol, host, port number, file, and handler.

URL(String protocol, String host, String file)
Creates an instance of a URL from the given protocol name, host name, and file name.

URL(URL context, String spec)
Creates an instance of a URL by parsing the given spec within a specified context.

URL(URL context, String spec, URLStreamHandler handler)
Creates an instance of a URL by parsing the given spec with the specified handler within a given context.

Commonly used methods of Java URL class

The java.net.URL class provides many methods. The important methods of URL class are given below.

MethodDescription
public String getProtocol( )it returns the protocol of the URL.
public String getHost( )it returns the host name of the URL.
public String getPort( )it returns the Port Number of the URL.
public String getFile( )it returns the file name of the URL.
public String getAuthority( )it returns the authority of the URL.
public String toString( )it returns the string representation of the URL.
public String getQuery( )it returns the query string of the URL.
public String getDefaultPort( )it returns the default port of the URL.
public URLConnection openConnection( )it returns the instance of URLConnection i.e. associated with this URL.
public Object getContent( )it returns the content of the URL.


 Servlet can be described in many ways, depending on the context.

  • Servlet is a technology which is used to create a web application.
  • Servlet is an API that provides many interfaces and classes including documentation.
  • Servlet is an interface that must be implemented for creating any Servlet.
  • Servlet is a class that extends the capabilities of the servers and responds to the incoming requests. It can respond to any requests.
  • Servlet is a web component that is deployed on the server to create a dynamic web page.

GET Method

The GET method is the default method to pass information from browser to web server and it produces a long string that appears in your browser’s Location box. Never use the GET method if you have password or other sensitive information to pass to the server. The GET method has size limitation : only 1024 characters can be used in a request string.

This information is passed using QUERY_STRING header and will be accessible through QUERY_STRING environment variable and Servlet handles this type of requests using doGet( ) method.

POST Method

A generally more reliable method of passing information to a backend program is the POST method. This packages the information in exactly the same way as GET method, but instead of sending it as a text string after a ? (question mark) in the URL it sends it as a separate message. This message comes to the backend program in the form of the standard input which you can parse and use for your processing. Servlet handles this type of requests using doPost( ) method.

Servlets handles form data parsing automatically using the following methods depending on the situation −

  • getParameter( ) − You call request.getParameter( ) method to get the value of a form parameter.
  • getParameterValues( ) − Call this method if the parameter appears more than once and returns multiple values, for example checkbox.
  • getParameterNames( ) − Call this method if you want a complete list of all parameters in the current request.

 A socket programming interface provides the routines required for interprocess communication between applications, either on the local system or spread in a distributed, TCP/IP based network environment. Once a peer-to-peer connection is established, a socket descriptor is used to uniquely identify the connection. The socket descriptor itself is a task specific numerical value.

Normally, a server runs on a specific computer and has a socket that is bound to a specific port number. The server just waits, listening to the socket for a client to make a connection request.

On the client-side: The client knows the hostname of the machine on which the server is running and the port number on which the server is listening. To make a connection request, the client tries to rendezvous with the server on the server's machine and port. The client also needs to identify itself to the server so it binds to a local port number that it will use during this connection. This is usually assigned by the system.

If everything goes well, the server accepts the connection. Upon acceptance, the server gets a new socket bound to the same local port and also has its remote endpoint set to the address and port of the client. It needs a new socket so that it can continue to listen to the original socket for connection requests while tending to the needs of the connected client.

On the client side, if the connection is accepted, a socket is successfully created and the client can use the socket to communicate with the server.

The client and server can now communicate by writing to or reading from their sockets.

 Steps:

·      Register the driver class

The forName() method of Class class is used to register the driver class. This method is used to dynamically load the driver class.

    Class.forName(“oracle.jdbc.driver.OracleDriver”);  

·       Create the connection object

The getConnection() method of DriverManager class is used to establish connection with the database.

Connection con=DriverManager.getConnection( “jdbc:oracle:thin:@localhost:1521:xe”,”system”,”password”);  

·      Create the Statement object

The createStatement() method of Connection interface is used to create statement. The object of statement is responsible to execute queries with the database.

Statement stmt=con.createStatement();  

·      Execute the query

The executeQuery() method of Statement interface is used to execute queries to the database. This method returns the object of ResultSet that can be used to get all the records of a table.

ResultSet rs=stmt.executeQuery(“select * from emp”);  

while(rs.next())

{  

System.out.println(rs.getInt(1)+” “+rs.getString(2));  

}  

5) Close the connection object

By closing connection object statement and ResultSet will be closed automatically. The close() method of Connection interface is used to close the connection.

con.close();