You are on page 1of 6

# List disadvantages of typical file processing system (ANS) # List Four DDL commands with syntax (ANS)

1. Data redundancy and inconsistency 2. Difficulty in 1. 1.Create: Syntax : create


accessing data 3. Data isolation 4. Integrity problems 5. table<table_name>(Column_name1 datatype1,
Atomicity problems column_name2 Datatype2,…Column_nameN DatatypeN);
# Define i)Data Abstraction ii)Data Redundancy 2. Drop : Syntax: drop table<table_name>;
(ANS) 1. Data Abstraction : Many end users are not computer 3. Desc : Syntax: Desc<table_name>
trained so it is needed to hide complex data structures from 4. Truncate Syntax: truncate table<table_name>;
them Hiding complexity of data structures from end user # Define Normalization, list its types (ANS)
through different levels is known as data abstraction It has 3 Normalization: Normalization can be defined as process of
levels : a. Physical level b. logical level c. view level decomposition/division of database tables to avoid the data
2. Data redundancy : The repetition of information is known redundancy Types of Normalization: 1. 1NF 2. 2NF 3. 3NF 4.
as redundancy .This redundancy leads to higher storage and BCNF
access cost. It may lead to data inconsistency, that is # Enlist four aggregate functions (ANS) 1.SUM() 2.AVG()
different copies of the same data may have different values 3.MAX() 4.MIN() 5.COUNT()
# Define the term: i) Candidate key ii) Primary key # Define Cursor. List the two types of cursor (ANS) A cursor
(ANS) Candidate key: In a relation, there may be a primary is a temporary work area created in the system memory
key or may not, but there may be a key or combination of when a SQL statement is executed. Types of cursor are: 1)
keys which uniquely identify the record. Such a key is called Implicit cursor 2) Explicit cursor
as Candidate key Example, {STUD_NO, COURSE_NO} is a # Define : (i) Instance (ii) Scheme (ANS)
composite candidate key for relation STUDENT_COURSE (i) Instance: The data stored in database at a particular
Primary key: A key which is selected by the designer to moment of time is called instance of database. (ii) Schema:
uniquely identify the entity is called as Primary key. A Design of a database is called the schema. Schema is of three
primary key cannot contain duplicate values and it can types: Physical schema, logical schema and view schema.
never contain null values inside it. Example, RollNo attribute
is a primary key for Relation Student

# Distinguish network model and hierarchical # State any two E.F. Codd’s rule for RDBMS (ANS)
Hierarchical model network model 1. The Information rule: All information in an RDBMS is
represented logically in just one way - by values in tables 2.
1. Hierarchical model is 1. Network model is more The Guaranteed Access rule: Each item of data in an RDBMS
not more popular than popular than the is guaranteed to be logically accessible by resorting to a
network model hierarchical and relational combination of table name, primary key value, and column
2. It does not uses client model name 3. The View Updating rule: All views of the data which
server architecture 2. It uses client –server are theoretically updatable must be updatable in practice by
3. One to many architecture the DBMS
relationship is maintained. 3. One to many and many # List DCL commands (ANS) DCL is Data Control Language: 1.
4. Hierarchical model is to many relationship is GRANT 2. REVOKE
based on tree like maintained. # State any four PL/SQL data types (ANS) 1. DATE 2. CHAR 3.
structure with one root. 4. Network model is based RAW 4. ROWID 5. VARCHAR2
5. One child or many on tree like structure with # Enlist DML commands.  Insert - used to insert new row
children have only one many roots into table  Delete- used to delete a row from the table 
parent 5. Many children have
Update – used to modify data in the table.  Select – used to
6. Main application of many parent
view data from a table.
hierarchical model is in 6. It is upgraded version of
# Define primary key and foreign key. Primary key is an
the mainframe database hierarchical model so used
attribute or set of attributes used to identify an entity from
system in network
an entity set. All the values of a primary key should be
# List any four advantages of DBMS (ANS) unique and null values are not allowed. Foreign key is an
 Controlling Redundancy  Maintaining Integrity  attribute of an entity which is the primary key of another
Inconsistency can be avoided  Data can be shared  entity. It is used to show relation between entities. The table
Restricting unauthorized access  Providing Backup and containing foreign key is called the child table
Recovery
#List any four string functions in SQL (ANS) Initcap(String) – 4) Minus: The minus of two sets includes elements from set1
converts first character of string to upper case minus elements of set2. E.g. select ename from emp1 minus
Upper(String) – converts the string to upper case select ename from emp2;
Lower(String) – converts string to lower case # Explain implicit and explicit cursors (ANS)
Length(String) – returns the number of characters in the Implicit cursor: these types of cursors are generated and
string used by the system during the manipulation of a DML query.
# State any two advantages of functions in PL/SQL (ANS)  An implicit cursor is also generated by the system when a
Work can be divided into smaller modules so that it can be single row is selected by a SELECT command. Programmers
manageable and also enhances the readability of the code.  cannot control the implicit cursors. Explicit cursor: this type
It promotes reusability.  It is secure, as the code is in the of cursor is created by the user when the select command
database and hides the internal database details from the returns more than one row, and only one row is to be
user.  It improves performance against running SQL processed at a time. An explicit cursor can move from one
queries multiple times row to another in a result set. An explicit cursor uses a
# Explain any four set operators in SQL with example. Set pointer that holds the record of a row To create an explicit
operators combine the results of two component queries cursor the following steps are used. 1. Declare cursor: this is
into a single result. Queries containing set operators are done in the declaration section of PL/SQL program. 2. Open:
called as compound queries. Set operators in SQL are this step is done before the cursor is used to fetch the
represented with following special keywords as: Union, records. 3. Fetch: used to retrieve data row by row from the
Union all, intersection & minus. 1) Union: The Union of two cursor. 4. Close: once the processing of the data is done, the
or more sets contains all elements, which are present in cursor can be closed.
either or both. Union works as or. The duplicates of both the
tables will appear only once. E.g. select ename from emp1
union select ename from emp2; ) Union all: The Union of 2 or
more sets contains all elements, which are present in both,
including duplicates. E.g. select ename from emp1 union all
select ename from emp2; 3) Intersection: The intersection of
two sets includes elements which are present in both. E.g.
select ename from emp1 intersect select ename from emp2;

Explain ACID properties of traction. A transaction can be commits but the system fails before the data could be
defined as a group of tasks. A single task is the minimum written on to the disk, then that data will be updated once
processing unit which cannot be divided further (ANS)  the system springs back into action.
Atomicity: This property states that a transaction must be # Explain strong and weak entity set (ANS)
treated as an atomic unit, that is, either all of its operations 1. Strong entity set: An entity set that has sufficient
are executed or none. There must be no state in a database attributes to form a primary key is called as Strong entity
where a transaction is left partially completed. States should set. Example: Employee is a Strong entity with attributes as
be defined either before the execution of the transaction or empid, name, address, salary, birthdate among which empid
after the execution/abortion/failure of the transaction.  can be considered as primary key. 2. Weak entity set: The
Consistency: The database must remain in a consistent state entity set which does not have sufficient attributes to form a
after any transaction. No transaction should have any primary key is called as Weak entity set. A weak entity is an
adverse effect on the data residing in the database. If the entity that cannot be uniquely identified by its attributes
database was in a consistent state before the execution of a alone; therefore, it must use a foreign key in conjunction
transaction, it must remain consistent after the execution of with its attributes to create a primary key. The foreign key
the transaction as well.  Isolation: In a database system is typically a primary key of an entity it is related to.
where more than one transaction are being executed Example: Employee has "dependents" with name, birthdate,
simultaneously and in parallel, the property of isolation and relationship to employee and it can be related to
states that all the transactions will be carried out and employee with the help of empid, so "dependents" is a
executed as if it is the only transaction in the system. No weak entity which depends on strong entity "Employee"
transaction will affect the existence of any other
transaction.  Durability: The database should be durable
enough to hold all its latest updates even if the system fails
or restarts. If a transaction updates a chunk of data in a
database and commits, then the database will hold the
modified data. If a transaction
# Explain any four String functions with example # Describe commit and rollback with syntax and example
(ANS) i) Lower(char)- Returns the input string with all letters (ANS) The COMMIT command saves all transactions to the
in lower case. Example: SQL>Select lower (‘RAJESH’) from database since the last COMMIT or ROLLBACK command
dual; The syntax: SQL> COMMIT;
Output: rajesh ii) Upper(char)- Returns the input string with Example : SQL>Commit;
all letters in upper case. Example: SQL>Select upper Rollback: The ROLLBACK command is used to undo
(‘rajesh’) from dual; Output: RAJESH iii) Ltrim(char,set)- It transactions that have not already been saved to the
removes or trims from left of character string . Example: database
SQL>Select Ltrim(‘university’,’univ’) from dual; Output: The syntax : ROLLBACK;
ersity iv) Rtrim(char,set)- It removes or trims from right of Example: SQL>ROLLBACK;
character string. Example: SQL>Select # Explain database security with its requirements in detail
Rtrim(‘university’,’sity’) from dual; Output: univer (ANS) Database security: Database security refers to the
# Describe exception handling in brief (ANS) collective measures used to protect and secure a database
Exception Handling: Exception is nothing but an error. or database management software from illegal use and
Exception can be raise when DBMS encounters errors or it malicious threats and attacks * Requirements of Database
can be raised explicitly. When the system throws a warning Security: 1. For prevention of data theft such as bank
or has an error it can lead to an exception. Such exception account numbers, credit card information, passwords, work
needs to be handled and can be defined internally or user related documents or sheets, etc. 2. 2. To make data remain
defined. Exception handling is nothing but a code block in safe and confidential. 3. To provide confidentiality which
memory that will attempt to resolve current error condition ensures that only those individuals should ever
Syntax: be able to view data they are not entitled to.
DECLARE ; 4. To provide integrity which ensures that only authorized
Declaration section individuals should ever be able change or modify
…executable statement; information 5. To provide availability which ensure that the
EXCEPTION data or system itself is available for use when authorized
WHEN ex_name1 THEN ; user wants it
Error handling statements/user defined action to be carried
out;
END;
# State and Explain 1 NF and 2 NF with example Supplier:-
(ANS) A table is in the first normal form if it contains no SNO SNAME LOCATION
repeating elements groups. Example:
Supplier(sno,sname,location,pno,qty) S1 Abc Mumbai
SNO SNAME LOCATION PNO QTY
S2 Pqr Pune
S1 Abc Mumbai P1 200
S2 Pqr Pune P2 300 S3 Lmn Delhi

S3 Lmn Delhi P1 400


Supplier_Product:-
The above relation is in 1NF as all the domains are having SNO PNO QTY
atomic value. But it is not in 2NF
Second Normal Form (2NF): A relation is said to be in the S1 P1 200
second normal form if it is in first normal form and all the
non key attributes are fully functionally dependent on the S2 P2 300
primary key
Example: In the above relation NAME, LOCATION depends on S3 P1 400
SNO and QTY on (SNO, PNO) so the table can be split up into
two tables as Supplier(SNO,SNAME,LOCATION) and
SP(SNO,PNO,QTY) and now both the tables are in second
normal form
# Draw the block structure of PL/SQL. List advantages 3. It allows user to write as well as access the functions and
Declare (Optional) procedures from outside the programs
4. It has got built in libraries of packages
--Use for declaring variables # Explain Transaction ACID properties (ANS)
ACID properties of transaction 1. Atomicity: When one
transaction takes place, many operations occur under one
Begin (Mandatory) transaction. Atomicity means either all operations will take
place property and reflect in the database or none of them
--Use for writing executable code; will be reflected. 2. Consistency: Consistency keeps the
database consistent. Execution of a transaction needs to take
place in isolation. It helps in reducing complications of
Exception (Optional) executing multiple transactions at a time and preserves the
consistency of the database
--Use to write exceptions to be catch during run 3. Isolation: It is necessary to maintain isolation for the
time transactions. This means one transaction should not be
aware of another transaction getting executed. Also their
End; (Mandatory) intermediate result should be kept hidden. 4. Durability:
When a transaction gets completed successfully, it is
--To terminate PL-SQL block/ code important that the changes made by the transaction should
be preserved in database in spite of system failures

Advantages of PL/SQL: 1. PL/SQL is portable and high


transaction processing language. 2. PL/SQL is in fact
procedural language but it also supports object oriented
programming

# i) Display the emp_id of employee who live in city ‘Pune’ ii) Use a seq_1 to insert the values into table Student( ID
or ‘Nagpur’ (ANS) Number(10), Name char (20)); (ANS)
select emp_id insert into student values(Seq_1.nextval,’ABC’);
from Employee iii) Change the Seq_1 max value 20 to 50(ANS)
where emp_city=’Pune’ or emp_city=’Nagpur’ Alter sequence Seq_1 maxvalue 50;
ii) Change the employee name ‘Ayush’ to ‘Ayan’ iv) Drop the sequence (ANS)
update Employee Drop sequence Seq_1;
set emp_name=’Ayan’ # Write a PL/SQL program which accepts the customer_ID
where emp_name=’Ayush’ from the user. If the enters an invalid ID then the exception
iii) Display the total number of employee whose dept is 50 invalid_id is raised using exception handling (ANS)
Select count(*) DECLARE
from Employee c_id numeric(10);
where emp_dept=50; invalid_id_Exception Exception;
Consider the following schema Depositor (ACC_no, Name, BEGIN
PAN, Balance). Create a view on Depositor having c_id:=&c_id;
attributes(ACC_No,PAN) where balance is greater than if(c_id<0) then
100000 (ANS) raise invalid_id_Exception;
create view v1 end if;
as EXCEPTION
select ACC_No,PAN WHEN invalid_id_Exception THEN
from Depositor dbms_output.put_line('Invalid customer id');
where balance > 100000; END;
# i) Sequence name is Seq_1, Start with 1, increment by 1,
minimum value 1, maximum value 20 (ANS) i) create
sequence Seq_1 start with 1 increment by 1 minvalue 1
maxvalue 20;
DELETE TRUNCATE 2) If some attribute is mentioned, it gives total number of
It is DML(Data Manipulation It is a DDL( Data Definition not null values for that attribute Eg: Select count(*) from
Language) command Language) command emp; Returns total number of records from emp table. 1)
It is used to remove all or It is used to remove all Select count(telephone) from emp; Returns total number of
specific records of table records permanently employees having telephone numbers
WHERE clause can be used WHERE clause can be used 2. Sum() - It give total of all values from a numeric attribute
to remove specific records as it removes all records of the given table, Eg :Select sum(salary) from emp; Returns
total salary drawn of all employees from the emp table. 3.
Syntax: DELETE FROM Syntax: TRUNCATE TABLE Avg () - It gives average of all the numeric values of the
Table_name; Table_name; given attribute from the table. Eg :Select Avg(salary) from
Example: DELETE FROM Example: TRUNCATE TABLE emp; Returns average salary of employees from emp table.
Employees WHERE Employees; 4. Min () - It gives minimum of all the values of the numeric
Emp_id=100; given attribute from the table. Eg :Select Min(salary) from
ROLLBACK command can be ROLLBACK command emp; Returns minimum salary value from emp table,
used to get deleted record cannot be used to get # i)Create user (ANS)
records. New records can i)Create user CREATE USER IDENTIFIED BY ;
be added into a table as # ii) Grant privileges to user (ANS)
structure remains intact GRANT <privilege list> ON <relation name or view name>
# Explain any four aggregate functions with example (ANS) TO <user list>;
An aggregate function is a function where the values of # Iii) Remove privileges from user (ANS)
multiple rows are grouped together as input on certain REVOKE <privilege list> ON <relation name or view name
criteria to form a single value of more significant meaning >
Aggregate functions are : 1) Count() 2) Sum() 3) Avg() 4) FROM <user list>;
Min()
1. Count () - 1) It returns number of rows from the given
table if no attribute is mentioned.

# Describe Views and write a command to create view (ANS) Order_amount,Product_code,Product name,rate)
A view is a virtual table based on the result set of the SQL Step 1.To convert it into 2NF, We have to decompose the
statement. The fields in a view are fields from one or more given table into two tables with fully functional
than one table in the database. SQL functions, where, join dependencies and establishing
statements can be added to a view and the data in it can be a referential integrity constraint relationship among the
presented as if it were from one table. The database engine two tables
recreates the data, using the view’s SQL statement, every Table2: Supplier Details
time a user queries a view. A view can be updated using the (Supplier_no,Supplier_name,Supplier_city) Table 3:Order
create or replace view command. For deleting a view, drop Details
query can be used (Order_no,Order_ quantity,Order_amount,Supplier_no
General syntax to create a view: create view viewname as Product_code,
select query. Eg: create view vw_student as select stud_id, product_name,rate)
stud_name,ssc_per from student; Now the above two tables are in 2NF
# State and explain 3NF with example (ANS) 3NF Step 2: To convert the above tables in 3NF, we have to
An entity is said to be in the third normal form when, 1) It decomposehem in three tables satisfying the transitive
satisfies the criteria to be in the second normal form.2) dependencies property
There exists no transitive functional dependency (Transitive Table 4: Supplier Details
functional dependency can be explained with the (Supplier_no,Supplier_name,Supplier_city) Table 5:
relationship link between three tables. If table A is Product Details:
functionally dependent on B, and B is functionally dependent (Product_code, product_name,rate)
on C then C is transitively dependent on A) Table 6: Order Details (or Transaction Details)
Let us consider the Schema given: ((Order_no,Supplier_no,Product_code,Order_
(Supplier_no,SupplierName,Supplier_city, quantity,Order_amount)
Order_no,Order_quantity, Hence the above three tables are satisfying Transitive
dependencies. Thus they are in 3NF
# Define index. Explain it‟s types (ANS) and all the archive bits are then cleared.
An Index is a schema object. It is used by the oracle server Normal backups are the fastest source to restore lost data
to improve the speed of retrieval of the rows from a table because all the data on a drive is saved in one location. ii)
.Indexes are of two types based on number of columns Incremental Backups: A common way to deal with the long
included in the index. The types of index are: 1) Simple running times required for full backups is to run them only
index: An index created on a single column of table is called on weekends. Many businesses then run incremental
as simple index backups throughout the week since they take far less time.
Syntax: An incremental backup will grab only the files that have
SQL>Create Index index_name on tablename(attribute); been updated since the last normal backup. Once the
Example:Create index emp_index on emp(empno); incremental backup has run, that file will not be backed up
2) Composite Index: An index created on more than one again unless it changes or during the next full backup
column is called composite index. iii) Differential Backups: An alternative to incremental
Syntax: database backups that has a less complicated restore process
SQL>Create Index index_name on is a differential backup. Differential backups and recovery
tablename(attribute1,attribute2); are similar to incremental in that these backups grab only
Example: Create index emp_index on emp(empno,ename); files that have been updated since the last normal backup.
# Describe database backups with it‟s types (ANS) However, differential backups do not clear the archive bit.
Regular backups are required to protect database and So a file
ensure its restoration in case of failure. Various backup that is updated after a normal backup will be archived every
types provide different protection to our database. Backing time a differential backup is run until the next normal
up and restoring data is one of the most important backup runs and clears the archive bit
responsibilities of IT professionals
i) Normal or Full Backups: When a normal or full backup
runs on a selected drive, all the files on that drive are
backed up. This, of course, includes system files, application
files, user data — everything. Those files are then copied to
the selected destination (backup tapes, a secondary drive or
the cloud),

You might also like