dbms preparatory material

Upload: shubham-rohan-asthana

Post on 03-Jun-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 DBMS Preparatory Material

    1/14

    What are Views in Databases ?

    A view is a virtual or logical table composed of the result set of a query. Unlike ordinary

    tables (base tables) in a relational database, a view is not part of the physical schema: it isa dynamic, virtual table computed or collated from data in the database. Changing the data

    in a table alters the data shown in the view.

    Views can provide advantages over tables;

    * They can subset the data contained in a table

    * They can join and simplify multiple tables into a single virtual view

    * Views can act as aggregated tables, where aggregated data (sum, average etc.) are

    calculated and presented as part of the data

    * Views can hide the complexity of data, for example a view could appear as Sales2000 or

    Sales2001, transparently partitioning the actual underlying table

    * Views do not incur any extra storage overhead* Depending on the SQL engine used, views can provide extra security.

    Just like functions (in programming) provide abstraction, views can be used to create

    abstraction. Also, just like functions, views can be nested, thus one view can aggregate data

    from other views.

    What are the different Data Models in DBMS ?

    Hierarchical Model

    The hierarchical data model organizes data in a tree structure. There is a hierarchy of

    parent and child data segments. This structure implies that a record can have repeatinginformation, generally in the child data segments. Hierarchical DBMSs were popular from

    the late 1960s, with the introduction of IBM's Information Management System (IMS)

    DBMS, through the 1970s.

    Network Model

    The popularity of the network data model coincided with the popularity of the hierarchical

    data model. Some data were more naturally modeled with more than one parent per child.

    Relational Model

    (RDBMS - relational database management system) A database based on the relational

    model developed by E.F. Codd. A relational database allows the definition ofdata structures,

    storage and retrieval operations and integrity constraints. In such a database the data and

    relations between them are organised in tables. A table is a collection of records and each

    record in a table contains the same fields.

    Properties of Relational Tables:

    # Values Are Atomic

    # Each Row is Unique

    # Column Values Are of the Same Kind

    # The Sequence of Columns is Insignificant

    http://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbms
  • 8/11/2019 DBMS Preparatory Material

    2/14

    # The Sequence of Rows is Insignificant

    # Each Column Has a Unique Name

    The RELATIONAL database model is based on the Relational Algebra.

    Object/Relational Model

    Object/relational database management systems (ORDBMSs) add new object storage

    capabilities to the relational systems at the core of modern information systems. nd othercomplex objects.

    Object-Oriented Model

    Object DBMSs add database functionality to object programming languages. They bring

    much more than persistent storage of programming language objects. Object DBMSs extend

    the semantics of the C++, Smalltalk and Java object programming languages to provide

    full-featured database programming capability, while retaining native language

    compatibility. A major benefit of this approach is the unification of the application and

    database development into a seamless data model and language environment.

    Semistructured Model

    In semistructured data model, the information that is normally associated with a schema is

    contained within the data, which is sometimes called ``self-describing''. In such database

    there is no clear separation between the data and the schema, and the degree to which it is

    structured depends on the application.

    There are couple more models but you don't have to know them unless you are into

    Database background.

    What are Schemas and Instances ?

    Database schema is a description of the structure of a database or a directory (file

    systems).There are 3 kind of schemas in Databases -

    * conceptual schema which is a map of concepts and their relationships

    * logical schema which is a map of entities and their attributes and relations

    * physical schema which is a particular implementation of a logical schema

    What are Entities and Attributes ?

    An entity is something that has a distinct, separate existence, though it need not be a

    material existence. A DBMS entity is either a thing in the modelled world or a drawing

    element in an ERD.

    Attributes are the Properties of that Entity.

    http://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbmshttp://www.coders2020.com/what-are-the-different-data-models-in-dbms
  • 8/11/2019 DBMS Preparatory Material

    3/14

    Explain ER Diagrams ?

    Seriously, If you don't know what are ER diagrams than probably you need to start DBMS

    from start. They are one of the most basic feature ofDatabase design and though No will

    ask you to design them (unless you are sitting for a DB company) during interview but still

    you should be very comfortable with them. Atleast know all ER symbols.

    I will try to write a good detailed article on them later here :-)

    What are the Different types of Keys in RDBMS ?

    * Alternate key - An alternate key is any candidate key which is not selected to be the

    primary key

    * Candidate key - A candidate key is a field or combination of fields that can act as a

    primary key field for that table to uniquely identify each record in that table.

    * Compound key - compound key (also called a composite key or concatenated key) is a

    key that consists of 2 or more attributes.

    * Primary key - a primary key is a value that can be used to identify a unique row in a

    table. Attributes are associated with it. Examples of primary keys are Social Security

    numbers (associated to a specific person) or ISBNs (associated to a specific book).

    In the relational model of data, a primary key is a candidate key chosen as the main

    method of uniquely identifying a tuple in a relation.

    * Superkey - A superkey is defined in the relational model as a set of attributes of a relation

    variable (relvar) for which it holds that in all relations assigned to that variable there are no

    two distinct tuples (rows) that have the same values for the attributes in this set.

    Equivalently a superkey can also be defined as a set of attributes of a relvar upon which all

    attributes of the relvar are functionally dependent.

    * Foreign key - a foreign key (FK) is a field or group of fields in a database record that

    points to a key field or group of fields forming a key of another database record in some

    (usually different) table. Usually a foreign key in one table refers to the primary key (PK) of

    another table. This way references can be made to link information together and it is an

    essential part of database normalization

    http://www.coders2020.com/explain-er-diagramshttp://www.coders2020.com/explain-er-diagramshttp://www.coders2020.com/explain-er-diagramshttp://www.coders2020.com/explain-er-diagrams
  • 8/11/2019 DBMS Preparatory Material

    4/14

    What are the guidelines of Database design ?

    What is Lossless Join Decomposition ?

    We claim the above decomposition is lossless. How can we decide whether a decomposition

    is lossless?

    * Let R be a relation schema.

    * Let F be a set of functional dependencies on R.

    * Let R1 and R2 form a decomposition of R.

    * The decomposition is a lossless-join decomposition of R if at least one of the following

    functional dependencies are in F+ :

    1.

    2.Why is this true? Simply put, it ensures that the attributes involved in the natural join (

    tex2html_wrap_inline1634 ) are a candidate key for at least one of the two relations.

    This ensures that we can never get the situation where spurious tuples are generated, as for

    any value on the join attributes there will be a unique tuple in one of the relations.

    What is Normalization ? What are the types of Normalization ? What is BCNF ?

    The formal classifications describing the level of database normalization in a data model arecalled Normal Forms (NF) and the process of doing this is Normalization.

    First normal form

    First normal form (1NF) lays the groundwork for an organised database design:

    Ensure that each table has a primary key: minimal set of attributes which can

    uniquely identify a record.

    Eliminate repeating groups (categories of data which would seem to be required a

    different number of times on different records) by defining keyed and non-keyed

    attributes appropriately.

    Atomicity: Each attribute must contain a single value, not a set of values.

    'First normal form' depends on functional dependency formula f(x)=y. For every

    value of x there is value for y.

  • 8/11/2019 DBMS Preparatory Material

    5/14

    Second normal form

    Second normal form (2NF) If a table has a composite key, all attributes must be

    related to the whole key:

    The database must meet all the requirements of the first normal form.

    The relational schema should not have any partial functional dependency i.e. Noproper subset of the primary key should derive a functional dependency belonging

    to the same schema. For example, consider functional dependencies FD:{AB->C, A-

    >D, C->D} here AB is the primary key, as A->D this relational schema is not in

    2NF.

    Third normal form

    Third normal form (3NF) requires that data stored in a table be dependent only on

    the primary key, and not on any other field in the table.

    The database must meet all the requirements of the first and second normal form.

    All fields must be directly dependent on the primary key field. Any field which is

    dependent on a non-key field which is in turn dependent on the Primary Key (ie a

    transitive dependency) is moved out to a separate database table.

    Boyce-Codd normal form

    Boyce-Codd normal form (or BCNF) requires that there be no non-trivial

    functional dependencies of attributes on something other than a superset of a

    candidate key (called a superkey).

    I don't think so that You will be need to know any other advance Normalization forms.

    Tell us what these SQL commands and Statements do ?

    What are Constraints ? What are the types of Constraints ?

    What are Various kind of join Operations?

    join combines records from two or more tables in a relational database. In the Structured

    Query Language (SQL), there are three types of joins: inner, outer, and cross. Outer joinsare subdivided further into left outer joins, right outer joins, and full outer joins.

    Join Forms

    Inner join

  • 8/11/2019 DBMS Preparatory Material

    6/14

    An inner join essentially finds the intersection between the two tables. This is the most

    common type of join used, and is considered the default join type. The join example below

    takes all the records from table A (in this case, employee) and finds the matching record(s)

    from table B (department). If no match is found, the record from A is not included in the

    results. If multiple results are found in B that match the predicate then one row will be

    returned for each (the values from A will be repeated).

    Special care must be taken when joining tables on columns that can be NULL since NULL

    values will never match each other. See Left Outer Join or Right Outer Join for a solution.

    Left outer join

    A left outer join is very different from an inner join. Instead of limiting results to those in

    both tables, it limits results to those in the "left" table (A). This means that if the ON clause

    matches 0 records in B, a row in the result will still be returnedbut with NULL values for

    each column from B.

    It returns all the values from left table + ( (matched values from right table) OR (null when

    the values from the right don't match) ).

    For example, this allows us to find the employee's departments, but still show the employeeeven when their department is NULL or does not exist. The example above would have

    ignored employees in non-existent departments.

    Right outer join

    A right outer join is much like a left outer join, except that the tables are reversed. Every

    record from the right side, B or department, will be returned, and NULL values will be

    returned for those that have no matching record in A.

    It returns all the values from right table + matched values from left table (OR null)

    Full outer join

    A full outer join combines the results of both left and right outer joins. These joins will show

    records from both tables, and fill in NULLs for missing matches on either side.Some database systems do not support this functionality, but it can be emulated through

    the use of left and right outer joins and unions (see below).

    Cross join

    While not used very commonly, a cross join is the foundation upon which inner joins are

    built. A cross join returns the cartesian product of the sets of rows from the joined tables.

    The SQL code for a cross join lists the tables to be joined (FROM), but does not include any

    filtering predicate (WHERE).

    What is Relational Algebra in Databases ?

    What is DDL and DML ?

    This is an important questions from Interview's point of view as this tests the basics of your

    databases. Once you can answer them what is DDL and what is DML, than they will ask you

  • 8/11/2019 DBMS Preparatory Material

    7/14

    to give examples and than will move to SQL statements. Normally interviewer tends to build

    on questions... So here we go

    Data Definition Language (DDL) statements are used to define the database structure or

    schema. Some examples:

    1. CREATE - to create objects in the database

    2. ALTER - alters the structure of the database

    3. DROP - delete objects from the database

    4. TRUNCATE - remove all records from a table, including all spaces allocated for the

    records are removed

    5. COMMENT - add comments to the data dictionary

    6. RENAME - rename an object

    Try to Remember DDL as CAD (AutoCAD, designing software) for Create, Alter and Drop.

    Data Manipulation Language (DML) statements are used for managing data within

    schema objects. Some examples:

    1. SELECT - retrieve data from the a database2. INSERT - insert data into a table

    3. UPDATE - updates existing data within a table

    4. DELETE - deletes all records from a table, the space for the records remain

    5. MERGE - UPSERT operation (insert or update)

    6. CALL - call a PL/SQL or Java subprogram

    7. EXPLAIN PLAN - explain access path to data

    8. LOCK TABLE - control concurrency

    Try to remember DML as SIU or SUI (switzerland ->Roger Federer ) for Select, Update

    and Inse

    What is a Trigger in Database ? What is Stored Proedure ?

    This Database Trigger question and Stored Procedure question is one of the most Frequently

    asked questions in Databases so make sure that you are good with it. No one will ask you in

    detail on this and answering well this problem will surely fetch you some advantage. Also be

    clear with there Difference too.

    A trigger is a code that is Automatically and immediately executed when a certain event

    took place on a table in the database. They are pre built code and used to for logging

    purpose or to erstrict people from accessing some data.

    A stored procedure is a group ofSQL statements that form a logical unit and perform a

    particular task, and they are used to encapsulate a set of operations or queries to execute

    on a database server. One of the biggest advantages of using stored procedures over

    not using stored procedures is the ability to significantly reduce network traffic.

    And the more network traffic that can be reduced, the better the overall performance of

    your SQL Server-based applications.

    http://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedure
  • 8/11/2019 DBMS Preparatory Material

    8/14

    How does Stored Procedure reduce the Network load ? Simple, everytime we don't have to

    go through network for every call to get ingormation or to perform certain operation on

    database. Do it all on one go.

    29. What is DML (Data Manipulation Language)?This language that enable user to access or manipulate data as organised by appropriate

    data model.

    Procedural DML or Low level: DML requires a user to specify what data are needed and

    how to get those data.

    Non-Procedural DML or High level: DML requires a user to specify what data are needed

    without specifying how to get those data.

    31. What is DML Compiler?

    It translates DML statements in a query language into low-level instruction that the query

    evaluation engine can understand.

    32. What is Query evaluation engine?

    It executes low-level instruction generated by compiler.

    33. What is DDL Interpreter?

    It interprets DDL statements and record them in tables containing metadata.

    36. What is Relational Algebra?

    It is procedural query language. It consists of a set of operations that take one or two

    relations as input and produce a new relation.

    53. What is indexing and what are the different kinds of indexing?

    Indexing is a technique for determining how quickly specific data can be found.

    Types:

    Binary search style indexing

    B-Tree indexing

    Inverted list indexing

    Memory resident table

    Table indexing

    54. What is system catalog or catalog relation? How is better known as?

    A RDBMS maintains a description of all the data that it contains, information about every

    relation and index that it contains. This information is stored in a collection of relations

    maintained by the system called metadata. It is also called data dictionary.

    Artificial Key:

    If no obvious key, either stand alone or compound is available, then the last way is to

    http://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedurehttp://www.coders2020.com/what-is-a-trigger-in-database-what-is-stored-proedure
  • 8/11/2019 DBMS Preparatory Material

    9/14

    simply create a key, by assigning a unique number to each record or occurrence. Then this

    is known as developing an artificial key.

    55. What is meant by query optimization?

    The phase that identifies an efficient execution plan for evaluating a query that has the least

    estimated cost is referred to as query optimization.

    Inclusion Dependency:

    An Inclusion Dependency is a statement of the form that some columns of a relation are

    contained in other columns. A foreign key constraint is an example of inclusion dependency.

    59. What is a Phantom Deadlock?

    In distributed deadlock detection, the delay in propagating local information might cause the

    deadlock detection algorithms to identify deadlocks that do not really exist. Such situations

    are called phantom deadlocks and they lead to unnecessary aborts.

    Atomicity:

    Either all actions are carried out or none are. Users should not have to worry about the

    effect of incomplete transactions. DBMS ensures this by undoing the actions of incomplete

    transactions.

    61. What are the different phases of transaction?

    Different phases are

    Analysis phase

    Redo Phase

    Undo phase

    62. What do you mean by flat file database?

    It is a database in which there are no programs or user access languages. It has no cross-

    file capabilities but is user-friendly and provides user-interface management.

    70. Are the resulting relations of PRODUCT and JOIN operation the same?

    No.

    PRODUCT: Concatenation of every row in one relation with every row in another.

    JOIN: Concatenation of rows from one relation and related rows from another.

    74. What is the job of the information stored in data-dictionary?

    The information in the data dictionary validates the existence of the objects, provides access

    to them, and maps the actual physical storage location.

    78. Name the three major set of files on disk that compose a database in Oracle

    There are three major sets of files on disk that compose a database. All the files are binary.

    These are

  • 8/11/2019 DBMS Preparatory Material

    10/14

    Database files

    Control files

    Redo logs

    79. What is an Oracle Instance?

    The Oracle system processes, also known as Oracle background processes, provide

    functions for the user processesfunctions that would otherwise be done by the user

    processes themselves

    Oracle database-wide system memory is known as the SGA, the system global area or

    shared global area. The data and control structures in the SGA are shareable, and all the

    Oracle background processes and user processes can use them.

    The combination of the SGA and the Oracle background processes is known as an Oracle

    instance.

    80. What are the four Oracle system processes that must always be up and running for the

    database to be useable

    The four Oracle system processes that must always be up and running for the database to

    be useable include DBWR (Database Writer), LGWR (Log Writer), SMON (System Monitor),

    and PMON (Process Monitor).

    81. What are database files, control files and log files. How many of these files should a

    database have at least? Why?

    Database Files

    The database files hold the actual data and are typically the largest in size. Depending on

    their sizes, the tables (and other objects) for all the user accounts can go in one database

    filebut that's not an ideal situation because it does not make the database structure very

    flexible for controlling access to storage for different users, putting the database on different

    disk drives, or backing up and restoring just part of the database.

    You must have at least one database file but usually, more than one files are used. In terms

    of accessing and using the data in the tables and other objects, the number (or location) of

    the files is immaterial.

    The database files are fixed in size and never grow bigger than the size at which they were

    created

    Control FilesThe control files and redo logs support the rest of the architecture. Any database must have

    at least one control file, although you typically have more than one to guard against loss.

    The control file records the name of the database, the date and time it was created, the

    location of the database and redo logs, and the synchronization information to ensure that

    all three sets of files are always in step. Every time you add a new database or redo log file

    to the database, the information is recorded in the control files.

    Redo Logs

  • 8/11/2019 DBMS Preparatory Material

    11/14

    Any database must have at least two redo logs. These are the journals for the database; the

    redo logs record all changes to the user objects or system objects. If any type of failure

    occurs, the changes recorded in the redo logs can be used to bring the database to a

    consistent state without losing any committed transactions. In the case of non-data loss

    failure, Oracle can apply the information in the redo logs automatically without intervention

    from the DBA.The redo log files are fixed in size and never grow dynamically from the size at which they

    were created.

    82. What is ROWID?

    The ROWID is a unique database-wide physical address for every row on every table. Once

    assigned (when the row is first inserted into the database), it never changes until the row is

    deleted or the table is dropped.

    The ROWID consists of the following three components, the combination of which uniquely

    identifies the physical storage location of the row.

    Oracle database file number, which contains the block with the rows

    Oracle block address, which contains the row

    The row within the block (because each block can hold many rows)

    The ROWID is used internally in indexes as a quick means of retrieving rows with a

    particular key value. Application developers also use it in SQL statements as a quick way to

    access a row once they know the ROWID

    85. Name two utilities that Oracle provides, which are use for backup and recovery.

    These utilities are Export and Import.

    The Export utility dumps the definitions and data for the specified part of the database to an

    operating system binary file. The Import utility reads the file produced by an export,

    recreates the definitions of objects, and inserts the data

    86. What are stored-procedures? And what are the advantages of using them.

    Stored procedures are database objects that perform a user defined operation. A stored

    procedure can have a set of compound SQL statements. A stored procedure executes the

    SQL commands and returns the result to the client.

    Stored procedures are used to reduce network traffic.

    84. What is database Trigger?

    A database trigger is a PL/SQL block that can defined to automatically execute for insert,

    update, and delete statements against a table. The trigger can be defined to execute once

    for the entire statement or once for every row that is inserted, updated, or deleted. For any

  • 8/11/2019 DBMS Preparatory Material

    12/14

    one table, there are twelve events for which you can define database triggers. A database

    trigger can call database procedures that are also written in PL/SQL.

    91. A B C is a set of attributes. The functional dependency is as follows

    AB -> B

    AC -> C

    C -> B

    a) is in 1NF

    b) is in 2NF

    c) is in 3NF

    d) is in BCNF

    (a) is in 1NF since (AC)+ = { A, B, C} hence AC is the primary key. Since C B is a FD given,

    where neither C is a Key nor B is a prime attribute, this it is not in 3NF. Further B is not

    functionally dependent on key AC thus it is not in 2NF. Thus the given FDs is in 1NF.

    97. What is Transaction Manager?

    It is a program module, which ensures that database, remains in a consistent state despite

    system failures and concurrent transaction execution proceeds without conflicting.

    100. What are stand-alone procedures?

    Procedures that are not part of a package are known as stand-alone because they

    independently defined. A good example of a stand-alone procedure is one written in a

    SQL*Forms application. These types of procedures are not available for reference from

    other Oracle tools. Another limitation of stand-alone procedures is that they are compiled at

    run time, which slows execution.

    104. How can you find the minimal key of relational schema?

    Minimal key is one which can identify each tuple of the given relation schema uniquely. For

    finding the minimal key it is required to find the closure that is the set of all attributes that

    are dependent on any given set of attributes under the given set of functional dependency.

    Algo. I Determining X+, closure for X, given set of FDs F

    1. Set X+ = X

    2. Set Old X+ = X+

    3. For each FD Y Z in F and if Y belongs to X+ then add Z to X+

    4. Repeat steps 2 and 3 until Old X+ = X+

    5. What is the parameter substitution symbol used with INSERT INTO command?

    &

    6. Which command displays the SQL command in the SQL buffer, and then executes it?

    RUN

  • 8/11/2019 DBMS Preparatory Material

    13/14

    7. What are the wildcards used for pattern matching?

    _ for single character substitution and % for multi-character substitution

    11. What command is used to get back the privileges offered by the GRANT command?

    REVOKE

    15. What is the difference between TRUNCATE and DELETE commands?

    TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE

    operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause

    can be used with DELETE and not with TRUNCATE.

    23. What is the use of the DROP option in the ALTER TABLE command?

    It is used to drop constraints specified on the table.

    SQL QUERIES

    I. SCHEMAS

    Table 1 : STUDIES

    PNAME (VARCHAR), SPLACE (VARCHAR), COURSE (VARCHAR), CCOST (NUMBER)

    Table 2 : SOFTWARE

    PNAME (VARCHAR), TITLE (VARCHAR), DEVIN (VARCHAR), SCOST (NUMBER), DCOST

    (NUMBER), SOLD (NUMBER)

    Table 3 : PROGRAMMER

  • 8/11/2019 DBMS Preparatory Material

    14/14

    PNAME (VARCHAR), DOB (DATE), DOJ (DATE), SEX (CHAR), PROF1 (VARCHAR), PROF2

    (VARCHAR), SAL (NUMBER)

    LEGEND :

    PNAME Programmer Name, SPLACE Study Place, CCOST Course Cost, DEVIN

    Developed in, SCOST Software Cost, DCOST Development Cost, PROF1 Proficiency 1

    KEYS:

    1. SELECT AVG(SCOST) FROM SOFTWARE WHERE DEVIN = 'ORACLE';

    2. SELECT PNAME,TRUNC(MONTHS_BETWEEN(SYSDATE,DOB)/12) "AGE",

    TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) "EXPERIENCE" FROM PROGRAMMER;

    3. SELECT PNAME FROM STUDIES WHERE COURSE = 'PGDCA';

    4. SELECT MAX(SOLD) FROM SOFTWARE;

    5. SELECT PNAME, DOB FROM PROGRAMMER WHERE DOB LIKE '%APR%';

    6. SELECT MIN(CCOST) FROM STUDIES;

    7. SELECT COUNT(*) FROM STUDIES WHERE COURSE = 'DCA';

    8. SELECT SUM(SCOST*SOLD-DCOST) FROM SOFTWARE GROUP BY DEVIN HAVING DEVIN

    = 'C';

    9. SELECT * FROM SOFTWARE WHERE PNAME = 'RAKESH';

    10. SELECT * FROM STUDIES WHERE SPLACE = 'PENTAFOUR';

    11. SELECT * FROM SOFTWARE WHERE SCOST*SOLD-DCOST > 5000;

    12. SELECT CEIL(DCOST/SCOST) FROM SOFTWARE;

    13. SELECT * FROM SOFTWARE WHERE SCOST*SOLD >= DCOST;

    14. SELECT MAX(SCOST) FROM SOFTWARE GROUP BY DEVIN HAVING DEVIN = 'VB';15. SELECT COUNT(*) FROM SOFTWARE WHERE DEVIN = 'ORACLE';

    16. SELECT COUNT(*) FROM STUDIES WHERE SPLACE = 'PRAGATHI';

    17. SELECT COUNT(*) FROM STUDIES WHERE CCOST BETWEEN 10000 AND 15000;

    18. SELECT AVG(CCOST) FROM STUDIES;

    19. SELECT * FROM PROGRAMMER WHERE PROF1 = 'C' OR PROF2 = 'C';

    20. SELECT * FROM PROGRAMMER WHERE PROF1 IN ('C','PASCAL') OR PROF2 IN

    ('C','PASCAL');

    21. SELECT * FROM PROGRAMMER WHERE PROF1 NOT IN ('C','C++') AND PROF2 NOT IN

    ('C','C++');