102 kavya

advertisement
UNIT-I
Concept of DBMS
Short Questions [ 2 marks ]
1. What is database?
1A. A database is a collection of logically related information that is organized in a systematic manner
so that it can easily be accessed, managed, and updated.
2. What is Data Processing?
2A. Data processing is the collection and manipulation of items of data to produce meaningful
Information.
3. What is a DBMS?
3A. A database management system (DBMS) can be defined as a collection of software packages for
processing the database.
4. What are the components of DBMS?
4A. A database system is composed of four components;
•
•
•
•
Data
Hardware
Software
Users
5. Define Instance?
5A. The collection of information stored in the database at a particular moment is called an ‘Instance’ of
the database.
6. Define Schema and Sub-Schema?
6A. The schema is the physical arrangement of the data as it appears in the DBMS. The subschema is the
logical view of the data as it appears to the application program
7. What is data independence?
7A. The ability to modify a schema definition in one level of database schema without affecting a
schema definition in the next higher level is called data Independence.
8. What is difference between physical and logical data Independence?
8A.
1. Physical Data Independence: - The ability to modify the physical schema without causing
application programs to be rewritten. The modifications at this level are occasionally necessary to
improve performance.
2.
Logical Data Independence; - The ability to modify the logical schema without causing
application programs to be rewritten. The modifications at this level are necessary whenever the
logical structure of the database is altered.
9. Who will be called as DBA?
9A. Database administrator (DBA) is a person or a group , who is responsible for the supervision and
control of the databases, within the organization.
10. What is Meta data or Data Dictionary?
10A. Data Dictionary is a file that contains metadata i.e data about data.
11. What the three levels of data abstraction?
11A.
1.Physical level
2.Logical level
3.View level
12. Write different types of database users?
12A.
1. Application programmers
2. Sophisticated users
3. Unsophisticated users
4. Specialized users
13. Expand the terms DDL, DML, DCL?
13A.
DDL: Data Definition Language
DML: Data Manipulation Language
DCL: Data Control Language
14. Write the commands of DDL, DML, DCL
14A. DDL:
create, alter, drop
DML:
insert, delete, update, select,
DCL:
grant, revoke, commit, rollback, save point.
Long Questions And Answers [ 6 marks]
1. What are the advantages of DBMS over File Processing system
A.
advantages of DBMS over File Processing system are
1. Provides for mass storage of relevant data.
2. Make easy access of the data to user.
3. Allows for the modification of data in a consistent manner.
4. Allows multiple users to be active at a time
5. Eliminate or reduce the redundant data.
6. Provide prompt response to the users request for data.
7. Supports Backup and recovery of data.
8. Protect data from physical hardware failure and unauthorized access.
9. Constraints can be set to database to maintain data integrity.
2. Explain about different data models
A. Different data models are
1. Object based data models
2. Record – based data models
3. Physical data models
1. Object base data models: Object-based logical models are used in describing data at
logical and view levels. They are characterized by the fact they provide flexible structuring
capabilities and allow data constraints to be specified explicitly. There are many different data
models, some of them are
i.
The Entity-relationship model
ii.
The Object-oriented model
iii. The semantic data model
iv. The Functional data model
2. Record based data models: In Record based data models; the database is structured in
fixed formats records of several types. Each record defines fixed number of fields (attributes) and
each field is fixed length. These models are used to specify the overall logical structure of the
database and are used in describing the database at conceptual level.
The three widely accepted record – based data models are:
a) Relational model
b) Network model
c) Hierarchical model
3. Physical data models: Physical data model are used to describe data at the lowest level.
In contrast to logical data models, there are few number of physical data models which are in use.
very few physical data models have been proposed so far. Two of these well known models are
the unifying model and the frame memory model.
3. What is data abstraction? Explain in detail.
A. A major purpose of a database system is to provide users with an abstract view of the data. That is,
the system hides certain details of how the data are stored and maintained.
The three levels of data abstraction are:
1. Physical level : how the data is stored physically and where it is stored in database.
2. Logical level : what information or data is stored in the database (like what is the data type
or what is format of data).
3.View level : end users work on view level.
View Level
View 1
View 2
View 3
Logical Level
Physical Level
The three level of data abstraction
4. What are the responsibilities of Database Manager? Explain.
A.
Responsibilities of Database Manager:
1. Interaction with File Manager: The raw data is stored on the disk using the file system which is
usually provided by conventional operating system.
2. Integrity Enforcement: The data values stored in the database must satisfy certain types of
consistency constraints.
3. Security Enforcement: Not every user of the database needs to have access to the entire content of
the database.
4. Backup and Recovery: It is the responsibility of database manager to detect such failures and
restore the database to a state that existed prior the occurrence of the failure this is usually
accomplished through the backup and recovery processor.
5. Concurrency Control: It is necessary for the system to control the interaction among the
concurrent users, and achieving such control is one of the responsibilities of database manager
6. Authorization Control:- This module checks that the user has necessary authorization to carry
out the required function.
5. What are the functions of DBA?
A.
1. Schema definition
2. Storage structure and Access method definition
3. Schema physical organization and modification
4. Granting of authorization for data access
5. Routine maintenance
1. Schema Definition: The DBA creates the original database schema by executing a set of definition
statements in the DDL.
2. Storage structure and Access method definition: DBA will decide the actual storage structure and
different access methodologies for the database.
3. Schema physical organization and modification: The DBA carries out the changes to the schema
and physical organization to reflect the changing needs of the organization or to alter the physical
organization to improve the performance.
4. Granting of authorization for data access: By granting different types of authorization, the database
administrator can regulate which of the database various can access.
5. Routine maintenance: DBA is the final authority to regulate daily activities.
6.Discuss briefly about different types database users
A.
Depending on the way that the users expect to interact with the database system, the users are
classified in to
1. Application Programmers: - Application Programmers are computer professionals
interacting with the system through DML calls, embedded in a program written in a
language like high level languages like COBOL, C, etc.
2. Sophisticated users; - These users interact with system without writing programs. They
form their request by writing queries in a database query language. Those are submitted
to a query processor that breaks a DML statement down in to instructions for the database
manager’s module.
3. Unsophisticated users: - Who interact with the system by using permanent applications.
Example ATM.
4. Specialized users: - These users write specialized database applications that do not fir in
to the traditional data processing frame work. These applications include Computer –
aided design (CAD) systems, Knowledge base expert systems etc.
7. Write about Record Based Data models in details?
Record based data models: In Record based data models; the database is structured in fixed formats
records of several types. Each record defines fixed number of fields (attributes) and each field is fixed
length. These models are used to specify the overall logical structure of the database and are used in
describing the database at conceptual level.
The three widely accepted record – based data models are:
a) Relational model
b) Network model
c) Hierarchical model
7A) Relational Data Model: The relational data model uses a collection of tables represent both data and
the relationships among those data. Each table has multiple columns and each column has unique key.
Consider the following two tables, (a) CUSTOMERS table is as follows:
ID NAME
ADDRESS
SALARY
1
BHEEMESH
HYD
60000
2
RATNAM
CHENNAI
30000
3
KAVYA
B’LORE
40000
4
SATISH
B’LORE
80000
(b) Another table is ORDERS as follows:
ORDER-ID
DATE
CUSTOMER_ID AMOUNT
102
11-10-2013
3
5000
103
10-10-2013
2
6000
104
12-10-2013
4
4000
2. Network Data Model: Network data model can have many-to-many relationships can be represent when
designing this, the model one has to been establish relation between records at the time of creation of
database This model helps in rapid and easy access to data as we have multiple access paths to records.
3. Hierarchical Data Model: This model permits two basic types of relationships namely, One – to – One
and One – to – Many relationships. The relation is irreflexive, Anti symmetric and Transitive. This relates
records by the Parent – Child or Supervisor – Subordinate relationship.
UNIT-II
ENTITY AND RELATIONSHIP
Short Questions
1. What is an Entity and Entity set?
1A. Entity: An Entity is an “object” that exists and is distinguishable from other objects.
For example, Student of a college having some specific properties. Admission number of a Student
is an entity, it is uniquely identifies a person in a class.
Entity Set: The Entity Set is a set of entities of the same type, that share the same properties or
Attributes.
The set of all students in a class., can be defined as the entity-set.
2. What is Relationship and Relationship set?
2A. Relationship: A Relationship is an association among several entities. For example, we can define a
relationship between a student entity and a teacher entity.
Relationship Set : A Relationship set is a set of relationships of the same type. Formally, it is a
mathematical relation on n ≥ 2 (possibly non distinct) entity sets. If E1 ,E2, ……., En are entity
sets,
then a relationship set R is a subset of { (e1, e2, …………,en ) |e1 є E1, e2 є E2, ……….. en є E n } Where (e1,
e2, .……,en) is a relationship.
3. What is Weak Entity and strong Entity?
3A. Weak Entity: An entity set that does not have sufficient attributes to form a primary key is termed a
weak entity set.
Strong Entity: An entity set that has a primary key and does not depending on other entity set to
form a primary key is termed a strong entity set.
4. What is an attribute? What are the different types in it?
4A. Attributes: Each entity has certain characteristics are known as attributes. For instance the student
entity has the attributes are Student name, Roll Number , etc
The attributes can be classified in to
1.
Simple attributes
2.
Complex/ composite attributes
3.
Single – valued attributes
4.
Multi - valued attributes
5.
Derived attribute
6. Null Attribute
5. What is a Domain?
5A. Domain: Domain is a pool of values of a specific attribute. Separate domains for separate
attributes.
6. What is a tuple ?
6A. Tuple is a row(record) of a table .
7. What is a Degree & Cardinality of a table?
7A. Degree: It is a number of columns(attributes) in a table.
Cardinality: it is a number of rows(tuples) in a table.
8. What are the symbols used in E-R diagram?
8A. Lines, Double Lines, Rectangles , Double Rectangles , Ellipses, Double ellipses ,Dashed ellipses ,
Diamonds.
9. What are mapping cardinalities?
9A. Mapping Cardinalities express the number of entities to which another entity can be associated
via a relationship set. They are one to one, one to many , many to one, many to many.
Long Answer Questions
1. Explain the mapping constraints with neat diagram?
1A.
There are 4 types of mapping constraints.
1. ONE – to – ONE relationship
2. MANY – to – ONE relationship
3. ONE – to – MANY relationship
4. MANY – to – MANY relationship
1. ONE – to – ONE relationship: An entity in A is associated with at most one entity in B , An entity
in B is also associated with at most one entity in A.
Example : Relationship between the entities principal and college. i.e., Principals can lead a single college
and a principal can have only one college
2. Many – to – One relationship: An entity set in A is associated with at most one entity in B, An entity in
B however can be associated with any number of entities in A.
Example: Relationship between the entities Districts and state .i.e. many districts belong to a single state but
many states cannot belong to single district.
3. ONE – to - MANY relationship: An entity set A is associated with any number of entities in B. An
entity in B, however can be associated with at most one entity in A.
Example: Relationship between the entities class and student i.e., a class can have many students but a
student cannot be in more than one class at a time.
4. MANY – to – MANY relationship: An entity set A is associated with any number of entities in B and
an entity set in B is associated with any number of entities in A.
Example: Relationship between the Entities College and course .i.e. a college can have many courses and
course can be offered by many colleges.
2. Draw an ER diagram by showing the relationship between a student and Bank
2A.
3. Write the procedure to reducing of an E-R diagram into table?
3A. Procedure for conversion of ER Diagram into a database table:
1. The E – R diagram of any database can be represented by a collection of tables.
2. For each entity set and for each relationship set there is unique table to which is assigned the name
of the corresponding entity set or relationship.
3. Each table has a number of columns which again have unique names i.e. attributes.
4. The values of all attributes are called records.
5. The column value which uniquely identifies the record in the table will be defined as primary key.
6. Other keys will be defined according to the relationship with other tables / entities.
UNIT-III
RELATIONAL MODEL
Short Answer Type Questions
1. What is a Relational Database?
A.
A Relational database is a database that has a collection of tables of data items, all of which
is formally described and organized according to the relations.
2. What is Domain in a Table?
A. Domain is a pool of values of a specific attribute. Separate domains for separate attributes.
3. What is Degree of Table in Relational Model
A. Number of attributes ( columns) in a table is called degree of a Table.
4. What is a Tuple?
A. Tuple is a record (row) is a table.
5. What is Primary Key?
A. Primary key: The Primary key of a relational data base table is a column name which uniquely
identifies each record in the table.
6. What are Formal Query Languages?
A. Formal Query Languages are formal in the sense that they are lack of ‘syntactic behavior ‘of
commercial query languages.
Some of the formal Query Languages are listed below:
- The Relational Algebra
- Tuple Relational Calculus
- Domain Relational Calculus
7. What are Commercial Query Languages?
A.
Commercial Query Languages are needed for the commercial database systems. These
languages are more user-friendly. Some of the commercial Query languages are SQL , QBE ,Quel
etc.,
8. What are fundamental operations in Relational Algebra?
A. The fundamental operations in the relational algebra are SELECT, PROJECT, UNION, SET
DIFFERENCE, CARTESIAN PRODUCT AND RENAME, etc.
9. What are Unary operations?
A. The SELECT, PROJECT and RENAME operations are called UNARY Operations, because they
operate on ONE REALTION.
10. What are Binary operations?
A. The UNION, SET DIFFERENCE , CARTESIAN PRODUCT , etc., are called
BINARY OPERATIONS because they operate on two or more relations.
Long Answer Type Questions
1. Explain about Relational Data Model.
A. Relational Data Model : One of the major advantages of using a relational database is its
structural flexibility. It allows the users to retrieve the data in any combination
A relation is a two-dimensional array, consisting of horizontal rows and vertical columns. Each
row, column ie a cell contains a unique value and no two rows are identical with respect to one another.
Relations are commonly referred as tables.. Every column in a database table acts as attribute since
the meaning of the column is same for every row of the database .A row consists of a set of fields and hence
commonly referred as a record.
Properties of Relational Database:
The important properties of a relational database are listed
below:
1. A relational database is a collection of relations.
2. The database tables have a row column format.
3. Operators are available either to join or separate columns of the database table.
4. Relations are formed with respect to data only.
5. The tables can be accessed by using simple non-procedural
statements.
6. The data is fully independent, that is it will be the same irrespective of
the access path used.
Structure of Relational Database:
Relational database systems are the most common DBMS today. These relational DBMSs organize
data into separate structures called tables, which can be linked via common information to make data
storage more efficient. A relational DBMS has the following basic components:
· fields - a separate piece of information which describe the data item.
· records – collection of fields.
· tables – collection of records.
· database - the collection of tables i.e the complete information.
A relational database consists of a collection of tables, each of which is assigned a unique name. A
row in a table represents a relationship among a set of values.
Consider the EMPLOYEE table as under.
EMPNO
EMPNAME
DESIGN
SALARY
101
CHANUKYA
ENGINEER
50000
102
KAVYA
DOCTOR
40000
103
RATNAM
LECTURER
35000
2. What is an attribute? Write about types in it.
A. Attributes - Types of attributes
Each entity has certain characteristics are called attributes. For instance the student entity might
include the following attributes, student no , Student name etc. For each attribute, there is a set of permitted
values, called the domain of that attribute.
The attributes can be classified in to
1. Simple attributes
2. Complex/ composite attributes
3. Single – valued attributes
4. Multi - valued attributes
5. Derived attribute
6. Null Attribute
1. Simple attributes: The attributes have been simple; that is, they cannot be subdivided into
parts.
Example : Age, Sex etc.
2. Composite attributes. The attributes, which can be sub divided in to sub parts.
Example : Student Name, Which can be divided in parts like First name, Middle
name and Last name etc.,
3. Single – valued attributes: The attribute which contain/ accept only one value/character.
Example : Sex: Male or Female
Marital status : Married or Unmarried
4. Multivalued attributes. The attributes which has set of values for a specific entity.
Example 1: Number of dependents in a family may 0,1,2,3,4…..
Example 2: A student may have several phone numbers, and different students may
have
different numbers of phones.
5. Derived attributes : The value of this type of attribute can be derived from the values
of other
related attributes or entities. The value of a derived attribute is not stored
but is computed
when required.
6. Null Attributes : An attribute takes a null value when an entity does not have a
value for it. The null value may indicate “not applicable” – that is, that the value does
not exist for the
entity.
3. What is a Key? Write about types of Keys.
A. Keys:
We must have a way to specify how entities within a given entity set are distinguished. Conceptually,
individual entities are distinct; from a database perspective, however, the difference among them must be
expressed in terms of their attributes.
The values of the attribute, values of an entity must be such that they can uniquely identify the
entity. In other words, no two entities in an entity set are allowed to have exactly the same value for all
attributes.
A key allows us to identify a set of attributes in an entity . Keys also help uniquely identify
relationships, and thus distinguish relationships from each other.
The keys can be categorized in to
1. Super Key: A Super key is a set of one or more attributes that, taken collectively; allow us to
identify uniquely an entity in the entity set. For example, the ‘student_id’ attribute of the entity set student
is sufficient to distinguish one student entity from another. Thus, ‘student_id’ is a super key
2. Candidate Key: A super key with minimal values is called a candidate key. A super key that
does not contain a subset of attributes, that is itself super key.
3. Primary key: The Primary key of a relational data base table is a column name which uniquely
identifies each record in the table. It cannot contain NULL entries.
4. Secondary key :- An attribute ( or ) Combination of attributes used strictly for data retrieval
purposes.
5. Foreign key :- An attribute or Combination of attributes in one table whose values must either
match the primary key in another table or be NULL.
4. Write the Differences between Formal and Commercial Languages
A. Differences between formal and commercial languages
Formal Query Language
Commercial Query Language
These languages lack of syntactic behaviour of These languages posses syntactic behavior like
other languages.
high level languages.
These are not used by commercial database
systems.
These are the languages used
The user can query the tables, insert new commercial database systems.
tuples ( rows in table ) delte tuples and
These languages are used to
update/modify tuples, using these languages.
database, defining the structure
modifying data
for specifying
constraints.
Examples: Relational Algebra
Tuple
Relational Calculus
Relational Calculus
by the
query a
of data
security
Domain
Examples : SQL, QBE, Quel
4. What are the Codd rules in Relational Model?
A.
CODD rules
Edgar F. Codd, proposed thirteen rules (numbered zero to twelve) and said that if a Database
Management System meets these rules, it can be called as a Relational Database Management System.
These rules are called as Codd’s12 rules. Hardly any commercial product follows all.
0.
Foundation Rule
A RDBMS must manage its stored data using only its relational capabilities.
1. Information Rule
All information in the database should be represented in one and only one way - as values in a table.
2. Guaranteed Access Rule
Each and every datum (atomic value) is guaranteed to be logically accessible by resorting to a
combination of table name, primary key value and column name.
3. Systematic Treatment of Null Values
Null values (distinct from empty character string or a string of blank characters and distinct from
zero or any other number) are supported in the fully relational DBMS for representing missing
information in a systematic way, independent of data type.
4. Dynamic On-line Catalog Based on the Relational Model
The database description is represented at the logical level in the same way as ordinary data, so
authorized users can apply the same relational language to its interrogation as they apply to regular
data.
5. Comprehensive Data Sublanguage Rule
A relational system may support several languages and various modes of terminal use. However,
there must be at least one language whose statements are expressible, per some well-defined syntax,
as character strings and whose ability to support all of the following is comprehensible:
a. data definition
b. view definition
c. data manipulation (interactive and by program)
d. integrity constraints
e. authorization
f. transaction boundaries (begin, commit, and rollback).
6. View Updating Rule
All views that are theoretically updateable are also updateable by the system.
7. High-level INSERT, UPDATE, and DELETE
The capability of handling a base relation or a derived relation as a single operand applies nor only to
the retrieval of data but also to the insertion, update, and deletion of data.
8. Physical Data Independence
Application programs and terminal activities remain logically unimpaired whenever any changes are
made in either storage representation or access methods.
9. Logical Data Independence
Application programs and terminal activities remain logically unimpaired when information
preserving changes of any kind that theoretically permit unimpairment are made to the base tables.
10. Integrity Independence
Integrity constraints specific to a particular relational database must be definable in the relational
data sublanguage and storable in the catalog, not in the application programs.
11. Distribution Independence
The data manipulation sublanguage of a relational DBMS must enable application programs and
terminal activities to remain logically unimpaired whether and whenever data are physically
centralized or distributed.
12. Non - subversion Rule
If a relational system has or supports a low-level (single-record-at-a-time) language, that low-level
language cannot be used to subvert or bypass the integrity rules or constraints expressed in the
higher-level (multiple-records-at-a-time) relational language.
6. Write short notes on Fundamental Operations in Relational Algebra.
A. There are six fundamental Operations in relational algebra
1.
2.
3.
4.
5.
6.
SELECT
PROJECT
UNION
SET DIFFERENCE
CARTESIAN PRODUCT
RENAME
Select and project operations are unary operation as they operate on a single relation. Union, set
difference, Cartesian product and rename operations are binary operations as they operate on pairs of
relations.
1. The select operation: - to identify a set of tuples which is a part of a relation and to extract only these
tuples out. The select operation selects tuples that satisfy a given predicate or condition and it is denoted
as σ.
2. The project operation: - returns its argument relation with certain attributes left out and it is denoted
as Π.
3. The union operation: - is used when we need some attributes that appear in either or both of the two
relations and it is denoted as U.
4. The set difference operation: - finds tuples in one relation but not in other and it is denoted as –
5. The Cartesian product operation: - allows combining information from two relations and it is denoted
as r X s where r and s are relations.
6. The rename operation: - used to rename and it is denoted as ρ.
UNIT – IV
SQL
Short Answer Type Questions
1. What is database and DBMS ?
A. A database is an organized collection of data in a systematic manner.
DBMS: A Database management system (DBMS) can be defined as a collection of software
packages for processing the database.
2. What are the internal data types in SQL ?
A. varchar , varchar2 , numb, long, date ,etc
3. What are the DDL and DML commands ?
A.
DDL commands: create, alter and drop.
DML commands: Insert, select, delete & update.
4. What is integrity constraint ?
A. An integrity constraint is a mechanism used by oracle to prevent invalid data entry into the
table.
5. What are the SET operators in SQL.
A.
Union , Union all , Intersect ,
Minus
6. Write the syntax of joining table in SQL
A. Select columns from table1, table2 where logical expressions;
7. What is a sub query?
A. Nesting of queries, one within another, is termed as subquery.
Long Answer Type Questions
1. Explain in detail three DDL commands with examples.
A.
DDL commands are create , alter, drop.
1. Create: Creating a table involves naming the table and defining its columns and each
column's data type & size.
Syntax:
Create table <table name > (column_name1 data type(size), column_name2 data type(size),…
column_namen data type(size))
Example
The following command illustrates how to create a table student with stno and stname.
SQL > create table student (stno number(3),stname varchar(10));
If the above command is executed successfully the message “table created” is displayed.
2. Alter : The ALTER TABLE command is used to add, delete or modify columns in an existing
table. You would also use ALTER TABLE command to add and drop various constraints on an
existing table.
Syntax:
alter table <table name> modify (column_name1 datatype(size));
alter table <table name> add (column_name datatype(size));
Example1:
Suppose if we want to change the size of stname from 10 to 15 characters which we created
in the previous example,
SQL > alter table student modify (stname varchar(15));
Example2:
The following example explains how to add a column stmarks and the type is numb.
SQL > alter table student add (stmarks number(3));
3. Drop: The DROP TABLE statement is used to remove a table definition and all data, indexes,
triggers, constraints, and permission specifications for that table.
Syntax:
Drop table <table name>;
Example:
drop table student;
If this statement is successfully executed then the message ‘table dropped’ would be
displayed.
2. Explain any four DML commands with examples.
A.
DML Commands: insert , select , delete and update
1. insert: The INSERT INTO Statement is used to add new rows of data to a table in the database.
Syntax:
Insert into <table name> values (value1 , value2 , value3 , ..valueN);
Example: Following statements would create three records in student table:
insert into student values(101 , ‘chanukya’);
insert into student values(102 , ‘kavya’);
insert into student values(101 , ‘satish’);
2.select:
SELECT statement is used to fetch the data from a database table which returns data
in the form of result table. These result tables are called result-sets.
Syntax:
Select column1 , column2 , column from <table name>;
Here, column1, column2...are the fields of a table whose values you want to fetch. If you
want to fetch all the fields available in the field, then you can use the following syntax:
Select * from <table_name>
Example1: select * from student;
Then the output will be
Stno
stname
-------
---------
101
chanukya
102
kavya
103
satish
Example2: select stname from student;
Stname
--------chanukya
kavya
satish
Example3: select * from student where stno >=102 ;
Then the output will be
Stno
stname
-------
---------
102
kavya
103
satish
3.update: The UPDATE command is used to modify the existing records in a table.
You can use WHERE clause with UPDATE query to update selected rows otherwise all the
rows would be affected.
Syntax:
UPDATE < table name >
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
Example:
Consider the student table having the following records:
Sql>select * from student;
Stno
-------
stname
---------
101
chanukya
102
kavya
103
satish
sql> update student set stname = ‘ratnam’ where stno = 101;
Sql>select * from student;
then the output will be as follows
Stno
stname
-------
---------
101
ratnam
102
kavya
103
satish
4.delete: DELETE command is used to delete the existing records from a table.
You can use WHERE clause with DELETE query to delete selected rows, otherwise all the
records would be deleted.
Syntax:
Delete from <table name> where [condition] ;
Example:
Sql>select * from student;
then the output will be as follows
Stno
stname
-------
---------
101
ratnam
102
kavya
103
satish
Sql>delete from student where stno = 101;
Sql> select * from student;
The output will be as follows
Stno
stname
-------
---------
102
kavya
103
satish
3. Write in detail about different SET operators with example.
A.
Set operators:
Set operators are used to join the results of two (or more) SELECT statements. The SET operators are
UNION,UNION ALL, INTERSECT, and MINUS.
1. UNION
When multiple SELECT queries are joined using UNION operator, SQL displays the combined
result from all the compounded SELECT queries, after removing all duplicates and in sorted order
(ascending by default), without ignoring the NULL values.
Consider the below five queries joined using UNION operator. The final combined result set contains value
from all the SQLs. Note the duplication removal and sorting of data.
UNION
SELECT 5 FROM DUAL
UNION
SELECT 3 FROM DUAL
UNION
SELECT 6 FROM DUAL
UNION
SELECT 3 FROM DUAL;
NUM
------1
3
5
6
2. UNION ALL
UNION and UNION ALL are similar in their functioning with a slight difference. But UNION ALL
gives the result set without removing duplication and sorting the data. For example, in above query UNION
is replaced by UNION ALL to see the effect.
SELECT 1 NUM FROM DUAL
UNION ALL
SELECT 5 FROM DUAL
UNION ALL
SELECT 3 FROM DUAL
UNION ALL
SELECT 6 FROM DUAL
UNION ALL
SELECT 3 FROM DUAL;
NUM
------1
5
3
6
3
3. INTERSECT
Using INTERSECT operator, Oracle displays the common rows from both the SELECT statements,
with no duplicates and data arranged in sorted order (ascending by default).
4. MINUS
Minus operator displays the rows which are present in the first query but absent in the second query, with no
duplicates and data arranged in ascending order by default.
4. Explain various integrity constraints in detail.
A. Constraints are the rules enforced on data columns on table. These are used to limit the type of
data that can go into a table. This ensures the accuracy and reliability of the data in the database.
Constraints could be column level or table level. Column level constraints are applied only to one
column, whereas table level constraints are applied to the whole table.
Following are commonly used constraints available in SQL.
1. NOT NULL Constraint: Ensures that a column cannot have NULL value.
2. DEFAULT Constraint: Provides a default value for a column when none is specified.
3. UNIQUE Constraint: Ensures that all values in a column are different.
4. PRIMARY Key: Uniquely identified each rows/records in a database table.
5. FOREIGN Key: Uniquely identified a rows/records in any another database table.
6. CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain
conditions.
7. INDEX: Use to create and retrieve data from the database very quickly.
5. Discuss briefly about simple joins, self joins and outer joins.
A.
1.Simple join:
The SQL Joins clause is used to combine records from two or more tables in a database. A
JOIN is a means of combining fields from two tables by using values common to each.
Consider the following two tables, (a) CUSTOMERS table is as follows:
ID NAME
ADDRESS
SALARY
1
BHEEMESH
HYD
60000
2
RATNAM
CHENNAI
30000
3
KAVYA
B’LORE
40000
4
SATISH
B’LORE
80000
(b) Another table is ORDERS as follows:
ORDER-ID
DATE
CUSTOMER_ID AMOUNT
102
11-10-2013
3
5000
103
10-10-2013
2
6000
104
12-10-2013
4
4000
Now, let us join these two tables in our SELECT statement as follows:
SQL> SELECT ID, NAME,AMOUNT
FROM CUSTOMERS, ORDERS
WHERE CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
This would produce the following result:
ID
NAME
AMOUNT
3
KAVYA
5000
2
RATNAM
6000
4
SATISH
4000
Here, it is noticeable that the join is performed in the WHERE clause. Several operators can be used
to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join
tables. However, the most common operator is the equal symbol.
Self join
Joining of a table to itself is known as a self join, i.e., it joins one row in a table to another. It can
compare each row of the table to itself and also with other rows of the same table.
Outer Join
The outer join extends the result of a simple join. An outer join returns all the rows returned by
simple join as well as those rows from one table that do not match any row from the other table. The
symbol, (+) represent outer join.
6. Explain about database objects like View, Synonym, sequences and index.
A. 1.View
A view is an imaginary table and it contains no data and the tables upon which a view is based are
called base tables. The advantages of views are as follows.
They provide table security by restricting access to predetermined set of rows or columns of a
table.
They simplify commands for the user because they allow them to select information from multiple
tables.
They provide data in a different perspective than that of base table by remaining columns without
affecting the base table.
2.Synonym
A synonym is a database object which is used as an alias (alternative name) for a table, view or
sequence. They are used to
• Simplify SQL statement.
• Mask the name and owner of an object
• Provide public access to an object.
Synonym can either private or public,. The former is created by the user, which is available only to that
person whereas the latter is created by the DBA, which can be availed by any database user.
3.Sequences
A sequence is databse object which can generate unique, sequential integer values. It can be used to
automatically generate primary key or unique key values. A sequence can be either an ascending or a
descending sequence.
4.Index
An index is a database object. Its purpose is to increase the performance of data retrieval and thereby
provide faster access path to the table data. Indexes can be created on more than one column of a table
UNIT-V
PL / SQL
1. What are the advantages of PL – SQL over SQL?
A) Advantages of PL/SQL
1. Support to SQL
2. Higher Productivity
3.
4.
5.
6.
Better Performance
Portability
Integration with oracle
Architecture
2. What are the different data types in PL/SQL?
A)
Data type
Purpose
Number
For storing numeric data
Char
For storing charter data
Date
For storing date and time data
Boolean
For storing TRUE or FALSE or NULL
%TYPE
Variables based on definitions of columns in a table. And allows programs
to adapt to changes made to the table.
NOT NULL
To create a variable or a constant that cannot have a null value.
3. What are the logical operators in PL/SQL?
A)
Logical Operator
Description
And
If both the operands are true then condition
becomes true.
Or
If any of the two operands is true then condition
becomes true.
Not
It negates the operand
4. Write the predefined exception in PL/SQL?
A) The Oracle engine has a set of pre – defined Oracle error handlers called Named Exceptions. An
exception will be automatically raised implicitly when a PL/SQL program violates Oracle rule.
Ex:
DUP_VAL_INDEX,
LOGIN_DENIED,
NO_DATA_FOUND,
NOT_LOGGED_ON,
PROGRAM_ERROR, TIMEOUT_ON_RESOURCE, TOO_MANY_ROWS, VALUE_ERROR, OTHERS.
5. What is a database Trigger?
A) Database Trigger: A database trigger is a stored procedure that will be executed when an event is
occurred i.e., insert, update, delete statement is issued against the associated table.
Long Answer Questions:
1. Write the structure of PL/SQL?
A.
PL/SQL is a block-structured language, meaning that PL/SQL programs are divided and written in
logical blocks of code. Each block consists of three sub-parts:
S.N. Sections & Description
1
Declarations
This section starts with the keyword DECLARE. It is an
optional section and defines all variables, cursors,
subprograms, and other elements to be used in the program.
2
Executable Commands
This section is enclosed between the
keywords BEGIN and END and it is a mandatory section. It
consists of the executable PL/SQL statements of the program.
It should have at least one executable line of code, which may
be just a NULL command to indicate that nothing should be
executed.
3
Exception Handling
This section starts with the keyword EXCEPTION. This
section is again optional and contains exception(s) that handle
errors in the program.
Every PL/SQL statement ends with a semicolon (;). PL/SQL blocks can be nested within other
PL/SQL blocks using BEGIN and END. Here is the basic structure of a PL/SQL block:
DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling>
END;
Here is an Example:
DECLARE
message varchar2(30):= 'Welcome to II CSE Students';
BEGIN
dbms_output.put_line(message);
END;
/
The END; line signals the end of the PL/SQL block. To run the code from SQL command line, you may
need to type / at the beginning of the first blank line after the last line of the code. When the above code is
executed at SQL prompt, it produces the following result:
Welcome to II CSE Students
PL/SQL procedure successfully completed.
2. Explain data types and their usage in PL / SQL?
A)
Data type
Purpose / Usage
Number
For storing numeric data
Char
For storing charter data
Date
For storing date and time data
Boolean
For storing TRUE or FALSE or NULL
%TYPE
Variables based on definitions of columns in a table. And allows programs
to adapt to changes made to the table.
NOT NULL
To create a variable or a constant that cannot have a null value.
3. Explain the control structures in PL/SQL?
A) PL/SQL can process the data using flow of control statements. The flow of control can be classified into
three categories
 Conditional Controls
 Iterative Controls
 Sequential Controls
Conditional Controls: Conditional Statements are three types, those are
A. if statements
B. if then else statements
C. if then else if statements.
A) if statement: Sequence of statements can be executed based on some condition using the if
statement.
Syntax: if <condition> then
Statements;
end if;
B) if then else : Sequence of statements can be executed based on some condition using the if statement.
An else clause in the ‘if then else’ statement defines what is to be done if the condition is false or null.
Syntax: if <condition> then
Statements;
else
Statement;
end if;
Iterative Controls: These statements are used to execute a particular statement for repeated number of
times.
A. Simple Loop
B. for Loop
C. while Loop
A) Simple Loop: Simple “loop” should be placed before the first statement in the sequence and the
keyword “end loop” after the last statement.
Syntax: loop
Statements;
end loop;
B) for Loop: The “for” loop will be executed for repeated number of times by automatically declaring loop
variable and also loop variable is always incremented by 1.
Syntax: for <variable> in [reverse] start …… end (star=lower bound, end= upper bound)
loop
Statements;
end loop;
C) while Loop: In while loop the keyword “loop” has to be placed before the first statement in the
sequence statements to be repeated, while the keyword “end loop” will be placed immediately after the last
statement.
Syntax: while<condition>
loop
Statements;
end loop;
Sequential Controls:
GOTO: GOTO statement change of the flow of control within PL/SQL block.
Syntax: GOTO<code_block_name>;
4.Write about error handling concept in PL / SQL?
A)
Error handling in PL / SQL is termed as an exception. An exception is raised when an error occurs.
In that case, normal execution stops and the control is immediately transferred to the exception handling
part of the PL/SQL block.
There are two types of exceptions
I.
Predefined exceptions
II.
User defined exceptions
Predefined exceptions: The Oracle engine has a set of pre – defined Oracle error handlers called Named
Exceptions. An exception will be automatically raised implicitly when a PL/SQL program violates Oracle
rule.
Ex:
DUP_VAL_INDEX,
LOGIN_DENIED,
NO_DATA_FOUND,
NOT_LOGGED_ON,
PROGRAM_ERROR, TIMEOUT_ON_RESOURCE, TOO_MANY_ROWS, VALUE_ERROR, OTHERS.
User defined exception: A user defined exception should be declared and raised explicitly by a “raise”
statement. It can be declared only in the declarative part of the PL / SQL block.
Syntax: <exception_name> exception;
The syntax for a ‘raise’ statement follows
raise <exception_name>
5. What is a Trigger? Explain with an example?
A) Database Trigger: A database trigger is a stored procedure that will be executed when an event is
occurred i.e., insert, update, delete statement is issued against the associated table.
Syntax: Create or replace trigger<trigger_name>
[before/after] (insert/delete) on <table_name> (for each statement / for each row) (when
<condition)
Parts of trigger: A database trigger has three parts, those are,
 trigger statement
 trigger body
 trigger restrictions
Trigger statement: The trigger statements specifies the DML statements like UPDATE, DELETE,
INSERT and it fires the trigger body. It is also specifies the table to which the trigger is associated.
Trigger body: It is PL / SQL block that is executed when a triggering statement is issued.
Trigger restriction: Restrictions on a trigger can be achieved using the WHEN clause. They can be
included in the definition of a row trigger, where in , the condition in the WHEN clause is evaluated for
each row that is affected by the trigger.
6. Discuss briefly about types of triggers?
A) Before defining a trigger, the number of times the trigger action is to be executed can be specified. This
can be once for every row affected by the triggering statement, or once for the triggering statement, no
matter how many rows are affected.
Triggers are basically four types. Those are
I.
Row Triggers
II.
Statement Triggers
III.
Before Triggers
IV.
After Triggers
Row Triggers: A row trigger is fired each time in the table is affected by the triggering statement. If the
triggering statement affects no rows, the trigger is not executed at all. Row triggers should be used when
some processing is required whenever a triggering statement affects a single row in a table.
Statement Triggers: A statement trigger is fired once on behalf of the triggering statement, independent of
the number of rows the triggering statement affects. Statement triggers should be used when a triggering
statement affects rows in a table but the processing required is completely independent of the number of
rows affected.
Before Triggers: BEFORE triggers are used when the trigger action before the triggering statement. These
types of statements are commonly used in the following situations.
 Before triggers are used when the trigger action should determine whether or not the triggering
statement should be allowed to complete. By using a BEFORE trigger, we can eliminate
unnecessary processing of the triggering statement.
 Before triggers are used to derive specific column values before completing a triggering INSERT or
UPDATE statement.
After Triggers: AFTER trigger executes the trigger action after the triggering statement is executed. These
types of triggers commonly used in the following situations.
 AFTER triggers are used when you want the triggering statement to complete “before executing the
trigger action”.
 If a BEFORE trigger is already present, an AFTER trigger can perform different actions on the same
triggering statement.
UNIT – VI
SDLC
Short Answer Questions
1. What is System and sub system
1A. System: System is an orderly grouping of interdependent components linked together to approach
a Specific object or goal. Ex: Railway reservation system , Net banking system.
Sub System: One of the number of component parts of a system. All the subsystems must
function together in an integrated manner for the system to operate as designed.
2. What is System Analysis?
A. Analysis is detailed study of a Software system.
3. Who will be called as System Analyst?
A. A person who analyses a system by the use of scientific techniques in order to determine where and
how the improvements can be made with a view to meet objectives in a more efficient and
economical manner is called System Analyst.
4. What are different methods of system testing?
A. 1.Unit testing
2. white box testing
3. black box testing
4. Peak Load testing
5. Storage testing
6. Performance time testing
7. Recovery testing
8. Procedure testing
9. Human factor testing
5. What are the methods of system implementation?
A. 1. Direct Conversion
2. parallel conversion
3. phase conversion.
6. What is Data Dictionary?
A. Data Dictionary is a repository that contains descriptions of all data objects produced by the
software.
7. What are the elements of a system?
A. The elements of a system are
1. Inputs and outputs
2. Processor
3. Control
4. Environment
5. Feedback
6. Boundaries and interface
8.
What are the fact finding techniques?
 Review of written Documents
 Onsite observation
 Interviews
 Questionnaires
Long Questions
1. Explain different stages of Software Development Life Cycle in detail?
A. System Development Life Cycle :
The stages involved during System Development Life Cycle are ::
1.
Recognition of need
2.
Feasibility study
3.
Analysis
4.
Design
5.
Implementation
6.
Post implementation and maintenance
1. Recognition of need: This gives a clearer picture of what actually the existing system is. The
preliminary investigation must define the scope of the project and the perceived problems,
opportunities and directives that triggered the project.
2. Feasibility Study: The goal of feasibility study is to evaluate alternative system and to purpose the
most feasible and desirable system for development. In the process of feasibility study, the cost and
benefits are estimated with greater accuracy. If cost and benefit can be quantified, they are tangible ;
if not , they are called intangible.
3. System Analysis: System analysis is an in-depth study of end user information needs that produces
functional requirements that are used as the basis for the design of a new information system.
4. System Design: System design can be viewed as the design of user interface, data, process and
system specification .
5. System Implementation: Implementation is the stage where theory is converted into practical. The
implementation is a vital step in ensuring the success of new systems. Even a well designed system
can fail if it is not properly implemented.
6. Post Implementation and Maintenance: Once a system is fully implemented and being operated
by end user, the maintenance function begins. Systems maintenance is the monitoring, evaluating
and modifying of operational information system to make desirable or necessary improvements.
2. What is testing? Write different types of testing can be considered while testing a software
product?
Testing
The system testing checks the readiness, and accuracy of the system to access, update and retrieve
data from new files.
Testing of each component of computer system by using actual data (or) by pathetical data and
analyzing the result in order to ensure that the system is trouble free.
Types of Software Testing
Basically there are 3 different types of testing is involved in testing of a software system.
Those are
• Unit Testing
• White Box Testing
• Black Box Testing
Unit Testing
Unit Testing mainly focus on the verification of the smallest unit of software design or the module of
a system. Using the procedural design description as a guide, important control paths are tested to uncover
errors within the boundary of a module.
White - Box Testing
White box testing, sometimes called GLASS BOX TESTING, is a test case design method that
uses the control structure of the procedural design to derive test cases.
Black – Box testing
Black – Box testing deals with the functional requirements of the software. i.e. Black – Box testing
enables the software engineer to derive sets of input conditions that will fully exercise all functional
requirements for a program.
Other Types of Testing
1. Peak Load testing
2. Storage testing
3. Performance time testing
4. Recovery testing
5. Procedure testing
6. Human factor testing.
1. Peak Load testing
These are critical types in many systems particularly on line systems.
Ex: Banking systems.
2. Storage Testing
Analyst specifies a capacity for the system when it is designed and constructed storage testing. Often
require entering data until capacity is reached.
3. Performance time testing
This test will be conducted prior to implementation to determine how long it takes to receive a
response to inquiry, make a backup of a file or send a transmission and receive a response.
4. Recovery Testing
Analyst must always assume that the system will fail and data will be damaged or lost. By creating a
failure or data loss event where the users forced to reload and recover from a backup copy, Analyst can
readily determine recovery procedures to get data which is lost.
5. Procedure testing
Analyst should concentrate on removing diskettes before powering down, instructions about when to
depress the enter key etc., and explain to user or should give proper messages to user on screen with
regarding procedures.
6. Human factor testing
This testing includes finding answers to questions about how people will react to the system in ways
not anticipated.
EXPANSIONS
DBMS: Data Base Management System
RDBMS: Relational Data Base Management System
DDL: Data Definition Language
DML: Data Manipulation Language
DCL: Data Control Language
DBA: Data Base Administrator
DBM: Data Base Manager
FPS: File Processing System.
ERD: Entity Relationship Diagram
SQL: Structured Query Language
PL/SQL: Programming Logic / Structured Query Language
DFD: Data Flow Diagram
SDLC: System Development Life Cycle
SAD: System Analysis and Design
DBTG: Data Base Task Group
QBE: Query By Example
SRS: System Requirement Specification
FQL: Formal Query Language
CQL: Commercial Query Language
DSD: Data Structure Diagram
TSD: Tree Structure Diagram
Model paper-I
COMPUTER SCIENCE & ENGG- 2ND YEAR
PAPER-2: RELATIONAL DATA BASE MANAGEMENT SYSTEM. [THEORY]
Time:- 3 Hrs
Max. Marks:- 50
SECTION-A
10 x 2=20
Note:- 1. Answer ALL Questions:
2. Each Question carries 2Marks.
1. Define DBMS.
A. A Database management system (DBMS) can be defined as a collection of software packages for
processing the database.
2. What is an Entity and a Relationship?
A. Entity: An Entity is an “object” that exists and is distinguishable from other objects.
For example, Roll Number of a Student, is an entity, it is uniquely identifies a person in a class.
Relationship: A Relationship is an association among several entities. For example, we can define a
relationship between a student entity and a bank account entity.
3. What are different types of symbols used in E-R Diagram?
A. Lines, Double Lines, Rectangles , Double Rectangles , Ellipses, Double ellipses ,Dashed ellipses ,
Diamonds.
4. What are the different types of attributes in relational model?
A. The different types of attributes are
1. Simple attributes
2. Complex/ composite attributes
3. Single – valued attributes
4. Multi - valued attributes
5. Derived attributes
6. Null Attributes.
5. What are the unary operations in relational model?
A. The SELECT, PROJECT and RENAME operations are called UNARY Operations, because they
operate on one relation.
6. Write the structure of SQL
A.
The structure of SQL query has the form:
select A1, A2, ..., An from r1, r2, ..., rm where P
– A is represent attributes
– r is represent relations
– P is a predicate.
7. What are basic operations in SQL?
A. The basic operations in SQL are
-Arithmetic operations
- Comparison operations
-Logical operations
- Negate operations
8. What is a Trigger?
A. A database trigger is a stored procedure that is fired when an insert, update or delete statement is
issued against the associated table.
9. Define System.
A. System is an orderly grouping of interdependent components linked together to approach a specific
object or goal. Ex: Railway reservation system , Netbanking system.
10. What is Questionnaire in System analysis?
A. A questionnaire is a document containing a number of standard questions that can be
sent to many individuals to know the opinions of how the job could be performed.
SECTION - B
Note:- 1. Answer any FIVE Questions:
2. Each Question carries 2Marks.
11. Explain the advantages of DBMS over File processing system.
A. Advantages of DBMS over File Processing system are
5 x 6 = 30
1) Provides for mass storage of relevant data.
2) Make easy access of the data to user.
3) Allows for the modification of data in a consistent manner.
4) Allows multiple users to be active at a time
5) Eliminate or reduce the redundant data.
6) Provide prompt response to the users request for data.
7) Supports Backup and recovery of data.
8) Protect data from physical hardware failure and unauthorized access.
9) Constraints can be set to database to maintain data integrity.
12. Write the functions of Database Administrator.
A.
1. Schema definition
2. Storage structure and Access method definition
3. Schema physical organization and modification
4. Granting of authorization for data access
5. Routine maintenance
-
-
1. Schema Definition: The DBA creates the original database schema by executing a set of
definition statements in the DDL.
2. Storage structure and Access method definition: DBA will decide the actual storage structure
and different access methodologies for the database.
3. Schema physical organization and modification: The DBA carries out the changes to the
schema and physical organization to reflect the changing needs of the organization or to alter the
physical organization to improve the performance.
4. Granting of authorization for data access: By granting different types of authorization, the
database administrator can regulate which of the database various can access.
5. Routine maintenance: DBA is the final authority to regulate daily activities.
13. Draw an ER diagram to show relation between a Student and Bank.
A.
14. Explain basic structure of Relational Model.
A.
In the relational data model, the data in a database is organized in relations. A relation is synonymous
with a ’table’. A table consists of columns and rows, which are referred as attributes and tuples in
Relational Model. The following is the structure of Relational model.
Tuple
Tuple is a record (row) is a complete set of related fields.
Attribute
An attribute(field) is a property or characteristics that hold some information
about an entity. For an example a ‘Student ’ is an entity , has attributes such as a
Stno, stname. mm, pm, and cm.
Domain
Domain is a pool of values of a specific attribute. Separate domains for separate attributes.
Degree
Number of attributes is called degree.
Cardinality
Number of tuples is called cardinality.
15. Explain Binary operations in Relational data base.
A. The binary operators are Union, set difference, Cartesian product and rename because they operate on
pairs of relations.
1. UNION:
When multiple SELECT queries are joined using UNION operator, SQL displays the combined
result from all the compounded SELECT queries, after removing all duplicates and in sorted order
(ascending by default), without ignoring the NULL values.
Consider the below five queries joined using UNION operator. The final combined result set contains value
from all the SQLs. Note the duplication removal and sorting of data.
UNION
SELECT 5 FROM DUAL
UNION
SELECT 3 FROM DUAL
UNION
SELECT 6 FROM DUAL
UNION
SELECT 3 FROM DUAL;
NUM
------1
3
5
6
2. UNION ALL:
UNION and UNION ALL are similar in their functioning with a slight difference. But UNION ALL
gives the result set without removing duplication and sorting the data. For example, in above query UNION
is replaced by UNION ALL to see the effect.
SELECT 1 NUM FROM DUAL
UNION ALL
SELECT 5 FROM DUAL
UNION ALL
SELECT 3 FROM DUAL
UNION ALL
SELECT 6 FROM DUAL
UNION ALL
SELECT 3 FROM DUAL;
NUM
------1
5
3
6
3
3. INTERSECT:
Using INTERSECT operator, Oracle displays the common rows from both the SELECT statements,
with no duplicates and data arranged in sorted order (ascending by default).
4. MINUS:
Minus operator displays the rows which are present in the first query but absent in the second query, with no
duplicates and data arranged in ascending order by default.
16. Explain any five DDL commands with an example
A. The DDL command are
1.create
2.drop
3.alter
4.rename
5.truncate
1. create: The create table command defines each column of the table uniquely. Each
column has minimum of three attributes.



Name
Data type
Size(column width).
Each table column definition is a single clause in the create table syntax. Each table column
definition is separated from the other by a comma. Finally, the SQL statement is terminated
with a semicolon.
The Structure of Create Table Command
Table name is Student
Column name
Data type
Size
Itemno
numb
3
Itemname
char
10
cost
numb
5
Example:
create table item (itemno numb(3),
itemname char(10), cost numb(5));
2. drop: The drop table statement is used to remove a table definition and all data,
indexes, triggers, constraints, and permission specifications for that table.
Syntax:
DROP TABLE <table_name>
Example:
drop table item;
3. alter: The ALTER Table Command is used to modify an existing table.
Adding New Columns
Syntax:
ALTER TABLE <table_name>
ADD (<NewColumnName> <Data_Type>(<size>),......n)
Example:
ALTER TABLE item ADD (itemcolor varchar(5));
The item table is already exist and then we added one column itemcolor, by the use of above command.
4.rename :The RENAME Command is used to give a new name to a table.
Syntax:
RENAME <OldTableName> TO <NewTableName>
Example:
RENAME <Student> TO <Stu>
The old name table was Student now new name is the Stu.
5. truncate: The TRUNCATE TABLE command is used to delete complete data from an existing table.
Syntax:
TRUNCATE TABLE <Table_name>
Example:
TRUNCATE TABLE item;
17. Explain main parts of Trigger with an example
A. Parts of a trigger
A database trigger has three parts, namely, a trigger statement, a trigger body and a trigger
restrictions.
Trigger statements
The trigger statements specifies the DML statements like update, delete ad insert and it fires the
trigger body. It is also specifies the table to which the trigger is associated .
Trigger body
It is PL/SQL block that is executed when a triggering statement is issued.
Trigger Restriction
Restrictions on a trigger can be achieved using the WHEN clause as shown in the above syntax.
They can be included in the definition of a row trigger, wherein, the condition in the WHEN clause is
evaluated for each row that is affected by the trigger.
Note : * A subquery cannot be included in the WHEN clause
18. Explain various stages of System Development Life Cycle
A. System Development Life Cycle :
The stages involved during System Development Life Cycle are ::
7.
Recognition of need
8.
Feasibility study
9.
Analysis
10. Design
11. Implementation
12. Post implementation and maintenance
7. Recognition of need: This gives a clearer picture of what actually the existing system is. The
preliminary investigation must define the scope of the project and the perceived problems,
opportunities and directives that triggered the project.
8. Feasibility Study: The goal of feasibility study is to evaluate alternative system and to purpose the
most feasible and desirable system for development. In the process of feasibility study, the cost and
benefits are estimated with greater accuracy. If cost and benefit can be quantified, they are tangible ;
if not , they are called intangible.
9. System Analysis: System analysis is an in-depth study of end user information needs that produces
functional requirements that are used as the basis for the design of a new information system.
10. System Design: System design can be viewed as the design of user interface, data, process and
system specification .
11. System Implementation: Implementation is the stage where theory is converted into practical. The
implementation is a vital step in ensuring the success of new systems. Even a well designed system
can fail if it is not properly implemented.
12. Post Implementation and Maintenance: Once a system is fully implemented and being operated
by end user, the maintenance function begins. Systems maintenance is the monitoring, evaluating
and modifying of operational information system to make desirable or necessary improvements.
Model paper - II
COMPUTER SCIENCE & ENGG- 2ND YEAR
PAPER-2:
RELATIONAL DATA BASE MANAGEMENT SYSTEM. [THEORY]
Time:- 3 Hrs
Max. Marks:- 50
SECTION-A
10 x 2=20
Note:- 1. Answer ALL Questions:
2. Each Question carries 2Marks.
01. What is data independence?
A. The ability to modify a schema definition in one level without affecting a schema definition in the
next higher level is called data Independence.
02. What is an Entity and Entity set?
A.
Entity: An Entity is an “object” that exists and is distinguishable from other objects.
For example, Admission Number of a Student, is an entity, it is uniquely identifies a person in a class.
Entity Set: The Entity Set is a set of entities of the same type, that share the same properties or
Attributes. The set of all students in a class., can be defined as the entity-set.
03. What is a domain?
A.
Domain: Domain is a pool of values of a specific attribute. Separate domains for separate
attributes.
04. What is a relational database?
A. A Relational database is a database that has a collection of tables of data items, all of which is formally described
and organized according to the relational model.
05. What is a Primary key?
A.
Primary key: The Primary key of a relational data base table is a column name which uniquely
identifies each record in the table. It cannot contain NULL entries.
06. What is an integrity constraint ?
A. An integrity constraint is a mechanism used by oracle to prevent invalid data entry into the
table.
07. What are the SET operators in SQL.
A. The set operators are Union , Union all , Intersect and Minus.
08. What are the logical operators in PL-SQL ?
A.
Logical Operator
Description
And
If both the operands are true then condition
becomes true.
Or
If any of the two operands is true then condition
becomes true.
Not
It negates the operand
09. Who
called as System Analyst?
will be
A. A person who analyses a system by the use of scientific techniques in order to determine where and
how the improvements can be made with a view to meet objectives in a more efficient and
economical manner is called System Analyst.
10. What are the methods of system implementation?
A. 1. Direct Conversion
2. parallel conversion
3. phase conversion.
SECTION – B
Note:- 1. Answer any FIVE Questions:
2. Each Question carries 2Marks.
11. What are the functions of DBA?
A.
-
Creating primary database storage structures
-
Modifying the structure of the database
-
Monitoring database performance and efficiently
-
Transferring data between the database and external file
-
Monitoring and reestablishing database consistency
-
Controlling and monitoring user access to the database
-
Manipulating the physical location of the database.
12. Discuss briefly about different types database users.
5 x 6 = 30
A.
Depending on the way that the users expect to interact with the database system, the users are
classified in to
5. Application Programmers: - Application Programmers are computer professionals
interacting with the system through DML calls, embedded in a program written in a
language like high level languages like COBOL, C, etc.
6. Sophisticated users; - These users interact with system without writing programs. They
form their request by writing queries in a database query language. Those are submitted
to a query processor that breaks a DML statement down in to instructions for the database
manager’s module.
7. Unsophisticated users: - Who interact with the system by using permanent applications.
Example ATM.
8. Specialized users: - These users write specialized database applications that do not fir in
to the traditional data processing frame work. These applications include Computer –
aided design (CAD) systems, Knowledge base expert systems etc.
13. Explain the mapping constraints with neat diagram.
A.
There are 4 types of mapping constraints.
1. ONE – to – ONE relationship
2. MANY – to – ONE relationship
3. ONE – to – MANY relationship
4. MANY – to – MANY relationship
2. ONE – to – ONE relationship: An entity in A is associated with at most one entity in B , An entity
in B is also associated with at most one entity in A.
Example : Relationship between the entities principal and college. i.e., Principals can lead a single college and a
principal can have only one college
2. Many – to – One relationship: An entity set in A is associated with at most one entity in B, An entity in B however
can be associated with any number of entities in A.
Example: Relationship between the entities Districts and state .i.e. many districts belong to a single state but many
states cannot belong to single district.
3. ONE – to - MANY relationship: An entity set A is associated with any number of entities in B. An entity in B,
however can be associated with at most one entity in A.
Example: Relationship between the entities class and student i.e., a class can have many students but a student
cannot be in more than one class at a time.
4. MANY – to – MANY relationship: An entity set in A is associated with any number of entities in B and an entity
set in B is associated with any number of entities in A.
Example: Relationship between the Entities College and course .i.e. a college can have many courses and course can
be offered by many colleges.
14. What is an attribute? Write about types in it.
A.
Attributes - Types of attributes
Each entity has certain characteristics are called attributes. For instance the student entity might include the
following attributes, student no , Student name etc. For each attribute, there is a set of permitted values, called the
domain of that attribute.
The attributes can be classified in to
1. Simple attributes
2. Complex/ composite attributes
3. Single – valued attributes
4. Multi - valued attributes
5. Derived attribute
6. Null Attribute
1. Simple attributes: The attributes have been simple; that is, they cannot be subdivided
into
parts.
Example : Age, Sex etc.
2. Composite attributes. The attributes, which can be sub divided in to sub parts.
Example : Student Name, Which can be divided in parts like First name, Middle
name and Last name etc.,
3. Single – valued attributes: The attribute which contain/ accept only one
value/character.
Example : Sex: Male or Female Marital status : Married or Unmarried
4. Multivalued attributes. The attributes which has set of values for a specific entity.
Example 1: Number of dependents in a family may 0,1,2,3,4…..
Example 2: A student may have several phone numbers, and different students may
have
different numbers of phones.
5. Derived attributes : The value of this type of attribute can be derived from the values
of other related attributes or entities. The value of a derived attribute is not stored
but is computed when required.
6. Null Attributes : An attribute takes a null value when an entity does not have a
value for it. The null value may indicate “not applicable” – that is, that the value does
not exist for the entity.
15. What are the Codd rules in Relational Model?
A. Codd Rules:
0
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Foundation Rule
A RDBMS must manage its stored data using only its relational capabilities.
Information Rule
All information in the database should be represented in one and only one way - as values in a table.
Guaranteed Access Rule
Each and every datum (atomic value) is guaranteed to be logically accessible by resorting to a combination of
table name, primary key value and column name.
Systematic Treatment of Null Values
Null values (distinct from empty character string or a string of blank characters and distinct from zero or any
other number) are supported in the fully relational DBMS for representing missing information in a
systematic way, independent of data type.
Dynamic On-line Catalog Based on the Relational Model
The database description is represented at the logical level in the same way as ordinary data, so authorized
users can apply the same relational language to its interrogation as they apply to regular data.
Comprehensive Data Sublanguage Rule
A relational system may support several languages and various modes of terminal use. However, there must
be at least one language whose statements are expressible, per some well-defined syntax, as character
strings and whose ability to support all of the following is comprehensible:
a. data definition
b. view definition
c. data manipulation (interactive and by program)
d. integrity constraints
e. authorization
f. transaction boundaries (begin, commit, and rollback).
View Updating Rule
All views that are theoretically updateable are also updateable by the system.
High-level Insert, Update, and Delete
The capability of handling a base relation or a derived relation as a single operand applies nor only to the
retrieval of data but also to the insertion, update, and deletion of data.
Physical Data Independence
Application programs and terminal activities remain logically unimpaired whenever any changes are made in
either storage representation or access methods.
Logical Data Independence
Application programs and terminal activities remain logically unimpaired when information preserving
changes of any kind that theoretically permit unimpairment are made to the base tables.
Integrity Independence
Integrity constraints specific to a particular relational database must be definable in the relational data
sublanguage and storable in the catalog, not in the application programs.
Distribution Independence
The data manipulation sublanguage of a relational DBMS must enable application programs and terminal
activities to remain logically unimpaired whether and whenever data are physically centralized or
distributed.
12. Nonsubversion Rule
If a relational system has or supports a low-level (single-record-at-a-time) language, that low-level language
cannot be used to subvert or bypass the integrity rules or constraints expressed in the higher-level (multiplerecords-at-a-time) relational language.
16. Explain in detail three DDL commands with examples.
A.
DDL commands are create , alter, drop.
4. Create: Creating a table involves naming the table and defining its columns and each
column's data type & size.
Syntax:
Create table <table name > (column name1 data type(size), column name2 data type(size)..));
Example
The following command illustrates how to create a table student with stno and stname.
SQL > create table student (stno number(3),stname varchar(10));
If the above command is executed successfully the message “table created” is displayed.
5. Alter : The ALTER TABLE command is used to add, delete or modify columns in an existing
table. You would also use ALTER TABLE command to add and drop various constraints on an
existing table.
Syntax:
alter table <table name> modify (column name1 data type(size));
alter table <table name> add (column name1 data type(size));
Example1:
Suppose if we want to change the size of stname from 10 to 15 characters which we created in the
previous example,
SQL > alter table student modify (stname varchar(15));
Example2:
The following example explains how to add a column stmarks and the type is numb.
SQL > alter table student add (stmarks number(3));
6. Drop: The DROP TABLE statement is used to remove a table definition and all data, indexes,
triggers, constraints, and permission specifications for that table.
Syntax:
Drop table <table name>;
Example: drop table student;
If this statement is successfully executed then the message ‘table dropped’ would be displayed.
17. Write about types of triggers?
A.
Triggers are basically four types. Those are
V.
Row Triggers
VI.
Statement Triggers
VII.
Before Triggers
VIII.
After Triggers
Row Triggers: A row trigger is fired each time in the table is affected by the triggering statement. If the
triggering statement affects no rows, the trigger is not executed at all. Row triggers should be used when
some processing is required whenever a triggering statement affects a single row in a table.
Statement Triggers: A statement trigger is fired once on behalf of the triggering statement, independent of
the number of rows the triggering statement affects. Statement triggers should be used when a triggering
statement affects rows in a table but the processing required is completely independent of the number of
rows affected.
Before Triggers: BEFORE triggers are used when the trigger action before the triggering statement. These
types of statements are commonly used in the following situations.
 Before triggers are used when the trigger action should determine whether or not the triggering
statement should be allowed to complete. By using a BEFORE trigger, we can eliminate
unnecessary processing of the triggering statement.
 Before triggers are used to derive specific column values before completing a triggering INSERT or
UPDATE statement.
After Triggers: AFTER trigger executes the trigger action after the triggering statement is executed. These
types of triggers commonly used in the following situations.
 AFTER triggers are used when you want the triggering statement to complete “before executing the
trigger action”.
 If a BEFORE trigger is already present, an AFTER trigger can perform different actions on the same
triggering statement.
18. What is testing? Write different types of testing can be considered
product.
while testing a software
A.
Testing: The system testing checks the readiness, and accuracy of the system to access, update and
retrieve data from new files.
Types of Software Testing
Basically there are 3 different types of testing is involved in testing of a software system.
Those are
• Unit Testing
• White Box Testing
• Black Box Testing
Unit Testing
Unit Testing mainly focus on the verification of the smallest unit of software design or the module of a
system. Using the procedural design description as a guide, important control paths are tested to uncover errors
within the boundary of a module.
White - Box Testing
White box testing, sometimes called GLASS BOX TESTING, is a test case design method that uses the control
structure of the procedural design to derive test cases.
Black – Box testing
Black – Box testing deals with the functional requirements of the software. i.e. Black – Box testing enables
the software engineer to derive sets of input conditions that will fully exercise all functional requirements for a
program.
Other Types of Testing
1. Peak Load testing
2. Storage testing
3. Performance time testing
4. Recovery testing
5. Procedure testing
6. Human factor testing.
1. Peak Load testing
These are critical types in many systems particularly on line systems.
Ex: Banking systems.
2. Storage Testing
Analyst specifies a capacity for the system when it is designed and constructed storage testing. Often require
entering data until capacity is reached.
3. Performance time testing
This test will be conducted prior to implementation to determine how long it takes to receive a response to
inquiry, make a backup of a file or send a transmission and receive a response.
4. Recovery Testing
Analyst must always assume that the system will fail and data will be damaged or lost. By creating a failure
or data loss event where the users forced to reload and recover from a backup copy, Analyst can readily determine
recovery procedures to get data which is lost.
5. Procedure testing
Analyst should concentrate on removing diskettes before powering down, instructions about when to
depress the enter key etc., and explain to user or should give proper messages to user on screen with regarding
procedures.
6. Human factor testing
This testing includes finding answers to questions about how people will react to the system in ways not
anticipated.
Download