0% found this document useful (0 votes)
18 views

Database and PLSQL Concepts

Uploaded by

MANI KANDAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Database and PLSQL Concepts

Uploaded by

MANI KANDAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Database and PL/SQL Concepts

11. (a) Purpose of a Database:

Purpose:

A database is designed to store, manage, and retrieve structured data efficiently. It ensures:

- Data Integrity: Accuracy and consistency of data.

- Concurrency: Multiple users can work with the data simultaneously.

- Security: Control who accesses what data.

- Data Independence: Data is separate from application logic.

- Backup and Recovery: Allows data to be recovered in case of failure.

Example:

In an e-commerce platform, the database stores:

- Product information

- Customer details

- Orders and transaction data

11. (b) Types of Data Models:

1. Hierarchical Model:

Data is stored in a tree-like structure.

Example: Employee -> Department -> Project. Each department has employees, and each

employee works on projects.

2. Network Model:
Similar to hierarchical, but allows multiple relationships (many-to-many).

Example: A project can have many employees, and an employee can work on multiple projects.

3. Relational Model:

Data is stored in tables with rows and columns. Relationships are defined by foreign keys.

Example: An employee table and a department table, linked by department_id.

4. Object-oriented Model:

Data is stored as objects, similar to OOP. Supports complex data types like multimedia, images, etc.

12. (a) Use of Oracle 9i:

Key Features of Oracle 9i:

1. Oracle Real Application Clusters (RAC): Enables multiple servers to access the same database.

2. Data Guard: Ensures backup and recovery for high availability.

3. Performance Tuning: Automatic optimization of queries and indexes.

12. (b) Personal Database System in a Multiuser Environment:

In a personal database system (e.g., Microsoft Access), only one user typically accesses the

database. In a multiuser environment, like Oracle, the database is accessed by many users

simultaneously. Features include:

- Concurrency Control: Ensures data consistency when many users access data.

- Transaction Management: Makes sure changes are either fully completed or not applied.

- Security: Different users can have different access levels.


13. (a) Adding a New Row/Record in Oracle (INSERT):

INSERT INTO employees (employee_id, name, department, salary)

VALUES (102, 'John Doe', 'IT', 55000);

13. (b) Sorting (ORDER BY):

SELECT * FROM employees ORDER BY salary DESC;

14. (a) Explicit Cursors and Attributes in PL/SQL:

DECLARE

CURSOR emp_cursor IS SELECT name, salary FROM employees;

emp_name employees.name%TYPE;

emp_salary employees.salary%TYPE;

BEGIN

OPEN emp_cursor;

LOOP

FETCH emp_cursor INTO emp_name, emp_salary;

EXIT WHEN emp_cursor%NOTFOUND;

DBMS_OUTPUT.PUT_LINE(emp_name || ' earns ' || emp_salary);

END LOOP;

CLOSE emp_cursor;

END;

14. (b) Data Manipulation Commands in PL/SQL:

INSERT INTO employees (employee_id, name, department) VALUES (104, 'Anil', 'HR');

UPDATE employees SET salary = salary + 500 WHERE employee_id = 102;

DELETE FROM employees WHERE employee_id = 104;


15. (a) PL/SQL Varray:

DECLARE

TYPE salary_array IS VARRAY(5) OF NUMBER;

salaries salary_array := salary_array(50000, 55000, 60000, 45000, 65000);

BEGIN

FOR i IN 1..salaries.COUNT LOOP

DBMS_OUTPUT.PUT_LINE('Salary: ' || salaries(i));

END LOOP;

END;

15. (b) Initializing a Package in PL/SQL:

CREATE PACKAGE employee_pkg IS

PROCEDURE add_employee(emp_id NUMBER, emp_name VARCHAR2);

FUNCTION get_salary(emp_id NUMBER) RETURN NUMBER;

END employee_pkg;

CREATE PACKAGE BODY employee_pkg IS

PROCEDURE add_employee(emp_id NUMBER, emp_name VARCHAR2) IS

BEGIN

INSERT INTO employees (employee_id, name) VALUES (emp_id, emp_name);

END;

FUNCTION get_salary(emp_id NUMBER) RETURN NUMBER IS

emp_salary employees.salary%TYPE;

BEGIN
SELECT salary INTO emp_salary FROM employees WHERE employee_id = emp_id;

RETURN emp_salary;

END;

END employee_pkg;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy