13
MARCH 2012 QUESTION PAPER ANSWER PART A 1) DBMS_JAVA Provides a PL/SQL interface for accessing database functionality from Java DBMS_JOB Schedules and manages jobs in the job queue 2) Tuple is the collection of information about the attributes of table for single instance. In simple this also can be called as a 'row' in a Table. In DBMS: Rows are referred to as tuples Columns are refrred to as Attributes Collection of related data items are called Records 3) An entity set that does not have a primary key is referred to as a weak entity set. The existance of a weak entity set depends on the existence of a strong entity set; it must relate to the strong set via a on-to-many relationship set. A distriminator of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set. The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence depend, plus the weak entity set’s discriminator. 4) Basically foreign key used to make a relation ship between the tables, used to reduce the redundancy of data and data integrity. foreign key is primary key of other table. For example: 'STUDENT' is one table which stores information about students and 'SID' is primary key in that table and 'MARKS' is another table which stores information of student marks and that 'SID' attribute can be use in 'MARKS' table by making it foreign key of same table. 5) SQL ORDER BY Syntax SELECT column_name,column_name FROM table_name ORDER BY column_name,column_name ASC|DESC;

2012

  • Upload
    midhun

  • View
    4

  • Download
    1

Embed Size (px)

DESCRIPTION

java question

Citation preview

  • MARCH 2012 QUESTION PAPER ANSWER

    PART A1)

    DBMS_JAVAProvides a PL/SQL interface for accessing database functionality from Java

    DBMS_JOBSchedules and manages jobs in the job queue

    2)

    Tuple is the collection of information about the attributes of table for single instance. In simple this also can be called as a 'row' in a Table. In DBMS:Rows are referred to as tuplesColumns are refrred to as AttributesCollection of related data items are called Records

    3)

    An entity set that does not have a primary key is referred to as a weak entity set.

    The existance of a weak entity set depends on the existence of a strong entity set; it must relate to the strong set via a on-to-many relationship set.

    A distriminator of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.

    The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence depend, plus the weak entity sets discriminator.

    4)

    Basically foreign key used to make a relation ship between the tables, used to reduce the redundancy of data and data integrity.

    foreign key is primary key of other table.

    For example:

    'STUDENT' is one table which stores information about students and 'SID' is primary key in that table and 'MARKS' is another table which stores information of student marks and that 'SID' attribute can be use in 'MARKS' table by making it foreign key of same table.

    5)SQL ORDER BY SyntaxSELECT column_name,column_nameFROM table_nameORDER BY column_name,column_name ASC|DESC;

  • ORDER BY Example

    Example

    SELECT * FROM CustomersORDER BY Country;

    PART B1)

    If the database is a file of information, then the DBMS is the file folders, the file labels and the file cabinet.

    database management system (DBMS) is system software for creating and managing databases. The DBMS provides users and programmers with a systematic way to create, retrieve, update and manage data.

    A DBMS makes it possible for end users to create, read, update and delete data in a database. The DBMS essentially serves as an interface between the database and end users or application programs, ensuring that data is consistently organized and remains easily accessible.The DBMS manages three important things: the data, the database engine that allows data to be accessed, locked and modified -- and the database schema, which defines the databases logical structure. These three foundational elements help provide concurrency, security, data integrity and uniform administration procedures. Typical database administration tasks supported by the DBMS include change management, performance monitoring/tuning and backup and recovery. Many database management systems are also responsible for automated rollbacks, restarts and recovery as well as the logging and auditing of activity.The DBMS is perhaps most useful for providing a centralized view of data that can be accessed by multiple users, from multiple locations, in a controlled manner. A DBMS can limit what data the end user sees, as well as how that end user can view the data, providing many views of a single database schema. End users and software programs are free from having to understand where the data is physically located or on what type of storage media it resides because the DBMS handles all requests.The DBMS can offer both logical and physical data independence. That means it can protect users and applications from needing to know where data is stored or having to be concerned about changes to the physical structure of data (storage and hardware). As long as programs use the application programming interface (API) for the database that is provided by the DBMS, developers won't have to modify programs just because changes have been made to the database.With relational DBMSs (RDBMSs), this API is SQL, a standard programming language for defining, protecting and accessing data in a RDBMS.

  • Advantages of a DBMS

    Advantages of DBMS (Database Management Systems) are followings: A true DBMS offers several advantages over file processing. The principal advantages of a DBMS are the followings: Flexibility: Because programs and data are independent, programs do not have to be modified when types of unrelated data are added to or deleted from the database, or when physical storage changes.

    Fast response to information requests: Because data are integrated into a single database, complex requests can be handled much more rapidly then if the data were located in separate, non-integrated files. In many businesses, faster response means better customer service.

    Multiple access: Database software allows data to be accessed in a variety of ways (such as through various key fields) and often, by using several programming languages (both 3GL and nonprocedural 4GL programs). Lower user training costs: Users often find it easier to learn such systems and training costs may be reduced. Also, the total time taken to process requests may be shorter, which would increase user productivity. Less storage: Theoretically, all occurrences of data items need be stored only once, thereby eliminating the storage of redundant data. System developers and database designers often use data normalization to minimize data redundancy.

    Central storage and management of data within the DBMS provides:

    Data abstraction and independence Data security A locking mechanism for concurrent access An efficient handler to balance the needs of multiple applications using the same data The ability to swiftly recover from crashes and errors, including restartability and

    recoverability Robust data integrity capabilities Logging and auditing of activity Simple access using a standard application programming interface (API) Uniform administration procedures for data

    2)1. Application programmers or Ordinary users

    2. End users 3. Database Administrator (DBA)

  • 4. System Analyst

    1. Application programmers or Ordinary users: These users write application programs to interact with the database. Application programs can be written in some programming language such a COBOL, PL/I, C++, JAVA or some higher level fourth generation language. Such programs access the database by issuing the appropriate request, typically a SQL statement to DBMS.2. End Users: End users are the users, who use the applications developed. End users need not know about the working, database design, the access mechanism etc. They just use the system to get their task done. End users are of two types:a) Direct users b) Indirect usersa) Direct users: Direct users are the users who se the computer, database system directly, by following instructions provided in the user interface. They interact using the application programs already developed, for getting the desired result. E.g. People at railway reservation counters, who directly interact with database.b) Indirect users: Indirect users are those users, who desire benefit form the work of DBMS indirectly. They use the outputs generated by the programs, for decision making or any other purpose. They are just concerned with the output and are not bothered about the programming part.3. Database Administrator (DBA): Database Administrator (DBA) is the person which makes the strategic and policy decisions regarding the data of the enterprise, and who provide the necessary technical support for implementing these decisions. Therefore, DBA is responsible for overall control of the system at a technical level. In database environment, the primary resource is the database itself and the secondary resource is the DBMS and related software administering these resources is the responsibility of the Database Administrator (DBA).4. System Analyst: System Analyst determines the requirement of end users, especially nave and parametric end users and develops specifications for transactions that meet these requirements. System Analyst plays a major role in database design, its properties; the structure prepares the system requirement statement, which involves the feasibility aspect, economic aspect, technical aspect etc. of the system.

    3)

    What are Entity Relationship Diagrams?

    Entity Relationship Diagrams (ERDs) illustrate the logical structure of databases.

    An ER Diagram

  • Entity Relationship Diagram Notations

    Peter Chen developed ERDs in 1976. Since then Charles Bachman and James Martin have added some sligh refinements to the basic ERD principles.

    Entity

    An entity is an object or concept about which you want to store information.Learn how to edit text on an entity.

    Weak Entity

    A weak entity is an entity that must defined by a foreign key relationship with another entity as it cannot be uniquely identified by its own attributes alone.Learn how to edit text on this object.

    Key attribute

    A key attribute is the unique, distinguishing characteristic of the entity. For example, an employee's social security number might be the employee's key attribute.

    Multivalued attribute

    A multivalued attribute can have more than one value. For example, an employee entity can have multiple skill values.

    Derived attribute

    A derived attribute is based on another attribute. For example, an employee's monthly salary is based on the employee's annual salary.

    Relationships

    Relationships illustrate how two entities share information in the database structure.

    Learn how to draw relationships:

  • First, connect the two entities, then drop the relationship notation on the line.

    Cardinality

    Cardinality specifies how many instances of an entity relate to one instance of another entity.

    Ordinality is also closely linked to cardinality. While cardinality specifies the occurences of a relationship, ordinality describes the relationship as either mandatory or optional. In other words, cardinality specifies the maximum number of relationships and ordinality specifies the absolute minimum number of relationships.

    entity-relationship model (diagram)

    (n.) Also called an entity-relationship (ER) diagram, a graphical representation of entities and their relationships to each other, typically used in computing in regard to the organization of data within databases or information systems. An entity is a piece of data-an object or concept about which data is stored.

    A relationship is how the data is shared between entities. There are three types of relationships between entities:

    1. One-to-One

    One instance of an entity (A) is associated with one other instance of another entity (B). For example, in a database of employees, each employee name (A) is associated with only one social security number (B).

    2. One-to-Many

    One instance of an entity (A) is associated with zero, one or many instances of another entity (B), but for one instance of entity B there is only one instance of entity A. For example, for a company with all employees working in one building, the building name (A) is associated with many different employees (B), but those employees all share the same singular association with entity A.

  • 3. Many-to-Many

    One instance of an entity (A) is associated with one, zero or many instances of another entity (B), and one instance of entity B is associated with one, zero or many instances of entity A. For example, for a company in which all of its employees work on multiple projects, each instance of an employee (A) is associated with many instances of a project (B), and at the same time, each instance of a project (B) has multiple employees (A) associated with it.

    4)

    In computer programming, a transaction usually means a sequence of information exchange and related work (such as database updating) that is treated as a unit for the purposes of satisfying a request and for ensuring database integrity. For a transaction to be completed and database changes to made permanent, a transaction has to be completed in its entirety. A typical transaction is a catalog merchandise order phoned in by a customer and entered into a computer by a customer representative. The order transaction involves checking an inventory database, confirming that the item is available, placing the order, and confirming that the order has been placed and the expected time of shipment. If we view this as a single transaction, then all of the steps must be completed before the transaction is successful and the database is actually changed to reflect the new order. If something happens before the transaction is successfully completed, any changes to the database must be kept track of so that they can be undone.

    A program that manages or oversees the sequence of events that are part of a transaction is sometimes called a transaction monitor. Transactions are supported by Structured Query Language, the standard database user and programming interface. When a transaction completes successfully, database changes are said to be committed; when a transaction does not complete, changes are

  • rolled back. In IBM's Customer Information Control System product, a transaction is a unit of application data processing that results from a particular type of transaction request. In CICS, an instance of a particular transaction request by a computer operator or user is called a task.

    Less frequently and in other computer contexts, a transaction may have a different meaning. For example, in IBM mainframe operating system batch processing, a transaction is a job or a job step

    5)

    The CREATE INDEX statement is used to create indexes in tables.

    Indexes allow the database application to find data fast; without reading the whole table.

    Indexes

    An index can be created in a table to find data more quickly and efficiently.

    The users cannot see the indexes, they are just used to speed up searches/queries.

    Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So you should only create indexes on columns (and tables) that will be frequently searched against.

    SQL CREATE INDEX Syntax

    Creates an index on a table. Duplicate values are allowed:

    CREATE INDEX index_nameON table_name (column_name)

    SQL CREATE UNIQUE INDEX Syntax

    Creates a unique index on a table. Duplicate values are not allowed:

    CREATE UNIQUE INDEX index_nameON table_name (column_name)

    Note: The syntax for creating indexes varies amongst different databases. Therefore: Check the syntax for creating indexes in your database.

    CREATE INDEX Example

    The SQL statement below creates an index named "PIndex" on the "LastName" column in the "Persons" table:

    CREATE INDEX PIndexON Persons (LastName)

    If you want to create an index on a combination of columns, you can list the column names within the parentheses, separated by commas:

    CREATE INDEX PIndexON Persons (LastName, FirstName)

  • The CREATE INDEX statement is used to create indexes in tables.Indexes allow the database application to find data fast; without reading the whole table.

    Indexes

    An index can be created in a table to find data more quickly and efficiently.

    The users cannot see the indexes, they are just used to speed up searches/queries.

    Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So you should only create indexes on columns (and tables) that will be frequently searched against.

    SQL CREATE INDEX Syntax

    Creates an index on a table. Duplicate values are allowed:

    CREATE INDEX index_nameON table_name (column_name)

    SQL CREATE UNIQUE INDEX Syntax

    Creates a unique index on a table. Duplicate values are not allowed:

    CREATE UNIQUE INDEX index_nameON table_name (column_name)

    Note: The syntax for creating indexes varies amongst different databases. Therefore: Check the syntax for creating indexes in your database.

    CREATE INDEX Example

    The SQL statement below creates an index named "PIndex" on the "LastName" column in the "Persons" table:

    CREATE INDEX PIndexON Persons (LastName)

    If you want to create an index on a combination of columns, you can list the column names within the parentheses, separated by commas:

    CREATE INDEX PIndexON Persons (LastName, FirstName)

    6)

    explains Embedded SQL

    Embedded SQL is not supported by all relational database management systems (RDBMS). Oracle DB and PostgreSQL provide embedded SQL support. MySQL, Sybase and SQL Server 2008 do not, although support was provided by earlier versions of SQL Server (2000 and 2005).

    The C programming language is commonly used for embedded SQL implementation. For example, a commercial bank's information system (IS) has a front-end user interface created in the C

  • language, and the IS interfaces with a back-end Oracle DB database. One of the front-end interface modules allows quick viewing and commission calculation for sales agents during specified periods. An inefficient approach to handling this process would be to store each commission value in a database table. However, a more effective solution is to calculate and return commission values based on unique user requests on specified dates. The application accomplishes this by embedding a SQL query within the C code, as follows:

    SELECT 0.2*SALE_AMOUNT FROM TOTAL_SALES WHERE SALE_DATE='MM/DD'YYYY' AND AGENT_NO=xx

    In this example, the SQL statement calculates and returns 20 percent of the sale amount from a TOTAL_SALES table, while the user is expected to input the SALE_DATE and AGENT_NO values. This SQL query is then inserted inline into the C code of the front-end module. The C code and SQL query work together to deliver seamless user results.

    6)

    A domain of possible values should be associated with every attribute. These domain constraints are the most basic form of integrity constraint.

    They are easy to test for when data is entered.

    1. Domain types

    1.Attributes may have the same domain, e.g. cname and employee-name.2.It is not as clear whether bname and cname domains ought to be distinct.3. At the implementation level, they are both character strings.4. At the conceptual level, we do not expect customers to have the same names as

    branches, in general.5. Strong typing of domains allows us to test for values inserted, and whether queries

    make sense. Newer systems, particularly object-oriented database systems, offer a rich set of domain types that can be extended easily.

    2. The check clause in SQL-92 permits domains to be restricted in powerful ways that most programming language type systems do not permit.

    1. The check clause permits schema designer to specify a predicate that must be satisfied by any value assigned to a variable whose type is the domain.

    2. Examples:

    create domain hourly-wage numeric(5,2)

    constraint wage-value-test check(value >= 4.00)

    Note that ``constraint wage-value-test'' is optional (to give a name to the test to signal which constraint is violated).

    create domain account-number char(10)

    constraint account-number-null-test check(value not null)

  • create domain account-type char(10)

    constraint account-type-test check(value in (``Checking'', ``Saving''))

    PART C

    discuss about the two-tier and three-tier architecture.Two-Tier Architecture:The two-tier architecture is like client server application. The direct communication takes place between client and server. There is no intermediate between client and server.

    The above figure shows the architecture of two-tier. Here the communication is one to one. Let us see the concept of two tier with real time application. For example now we have a need to save the employee details in database. The two tiers of two-tier architecture is

    1. Database (Data tier) 2. Client Application (Client tier)

    So, in client application the client writes the program for saving the record in SQL Server and thereby saving the data in the database.Advantages:

    1. Understanding and maintenances is easier.

    Disadvantages:

    1. Performance will be reduced when there are more users.

    Three-Tier Architecture:Three tier architecture having three layers. They are

    1. Client layer 2. Business layer 3. Data layer

    Client layer: Here we design the form using textbox, label etc.Business layer: It is the intermediate layer which has the functions for client layer and it is used to make communication faster between client and data layer. It provides the business processes logic and the data access.Data layer: it has the database.

  • Advantages

    1. Easy to modify with out affecting other modules 2. Fast communication 3. Performance will be good in three tier architecture

    2)

    Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:

    CREATE - to create objects in the database ALTER - alters the structure of the database DROP - delete objects from the database TRUNCATE - remove all records from a table, including all spaces allocated for the records

    are removed COMMENT - add comments to the data dictionary RENAME - rename an object

    DML

    Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:

    SELECT - retrieve data from the a database INSERT - insert data into a table UPDATE - updates existing data within a table DELETE - deletes all records from a table, the space for the records remain MERGE - UPSERT operation (insert or update) CALL - call a PL/SQL or Java subprogram EXPLAIN PLAN - explain access path to data LOCK TABLE - control concurrency

  • DCL

    Data Control Language (DCL) statements. Some examples:

    GRANT - gives user's access privileges to database REVOKE - withdraw access privileges given with the GRANT command

    ExampleIf the database is a file of information, then the DBMS is the file folders, the file labels and the file cabinet.Advantages of a DBMS

    What are Entity Relationship Diagrams?Entity Relationship Diagram NotationsEntityWeak EntityKey attributeMultivalued attributeDerived attributeRelationshipsCardinality

    entity-relationship model (diagram)1. One-to-One2. One-to-Many3. Many-to-ManyIndexesSQL CREATE INDEX SyntaxSQL CREATE UNIQUE INDEX Syntax

    CREATE INDEX ExampleIndexesSQL CREATE INDEX SyntaxSQL CREATE UNIQUE INDEX Syntax

    CREATE INDEX ExampleDMLDCL