Posts

Scheduling algorithm

  1. FCFS (First Come First Serve) Scheduling Algorithm: Input n processes with Arrival Time (AT) and Burst Time (BT). Sort processes by Arrival Time. For the first process: Completion Time (CT) = AT + BT For each next process: CT = max(previous CT, current AT) + BT Calculate Turnaround Time (TAT) = CT - AT. Calculate Waiting Time (WT) = TAT - BT. Calculate average TAT and WT.   Pseudo Code: text Start Input n For i = 1 to n Input AT[i], BT[i] Sort processes by AT CT[1] = AT[1] + BT[1] For i = 2 to n CT[i] = max(CT[i-1], AT[i]) + BT[i] EndFor For i = 1 to n TAT[i] = CT[i] - AT[i] WT[i] = TAT[i] - BT[i] EndFor Calculate average TAT and WT Print CT, TAT, WT, Average TAT, Average WT End 2. SJF (Shortest Job First) Non-preemptive Scheduling Algorithm: Input n processes with Arrival Time (AT) and Burst Time (BT). Initialize time = 0 and completed process count = 0. While all processes are not completed: Select...

dbms exercise 2

 welcome ---------------------------------------------------------------------- CREATE TABLE EMPLOYEE (     ENO NUMBER (4),     ENAME VARCHAR2(50) NOT NULL,     DEPTNO NUMBER (2),     JOBTITLE VARCHAR2(50),     DOB DATE,     SALARY NUMBER(8,2),     COMM NUMBER(8,2),     CONSTRAINT PM_KEY PRIMARY KEY(ENO),     CONSTRAINT CK CHECK (SALARY > 0),     CONSTRAINT CKR CHECK (DEPTNO BETWEEN 10 AND 90) );

SELECT COMMAND

 The DQL (Data Query Language) is a subset of SQL used to retrieve data from the database. In essence, DQL focuses on querying data stored in tables, and its most common command is SELECT . 1. DQL Commands The primary command in DQL is: SELECT : Used to retrieve data from one or more tables. DQL allows you to: Specify which columns or rows to retrieve. Filter data using conditions. Sort data. Aggregate and group data. Join data from multiple tables. 2. Syntax Basic Syntax sql SELECT column1, column2, ... FROM table_name WHERE condition ; column1, column2 : Columns to retrieve. table_name : The table to query data from. condition : Filter to retrieve specific rows. 3. Types of Queries A. Retrieve All Columns Retrieve all columns from a table: sql SELECT * FROM employees; B. Retrieve Specific Columns Retrieve only specific columns: sql SELECT emp_id, emp_name, salary FROM employees; C. Apply Filtering with WHERE Retrieve rows based on conditions: sql SELECT emp_id, emp_na...

DELETE COMMAND

 The DELETE command in SQL is used to remove rows from a table based on specific conditions. It is part of the Data Manipulation Language (DML) and allows precise control over which rows to delete, unlike the TRUNCATE command, which deletes all rows. 1. Purpose The DELETE command is used to: Remove specific rows matching a condition. Delete all rows from a table while retaining the table structure. 2. Syntax A. Basic Syntax DELETE FROM table_name WHERE condition; table_name : Name of the table from which rows will be deleted. condition : A filter specifying which rows to delete. B. Delete All Rows (Caution) If you want to delete all rows from a table: DELETE FROM table_name; ⚠️ Warning : If no WHERE clause is specified, all rows in the table will be deleted. 3. Examples A. Delete Specific Rows Delete an employee with emp_id = 101 : DELETE FROM employees WHERE emp_id = 101; B. Delete Based on Multiple Conditions Delete employees in department 20 earn...

UPDATE COMMAND

 The UPDATE command in SQL is used to modify existing records in a table. It allows you to update one or more rows by specifying a condition. If no condition is specified, all rows in the table will be updated (which should be done with caution). 1. Purpose The UPDATE command is used to: Modify specific columns for specific rows. Change multiple columns at once. Perform arithmetic or transformations on existing values. 2. Syntax Basic Syntax UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition; table_name : The name of the table to update. column1, column2, ... : Columns to modify. value1, value2, ... : New values for the columns. condition : Filters the rows to update. Without this, all rows are updated. 3. Examples A. Update a Single Column Update the salary of an employee with emp_id = 101 : UPDATE employees SET salary = 60000 WHERE emp_id = 101; B. Update Multiple Columns Update the name and salary of an employee: UPDATE em...

INSERT COMMAND

 The INSERT command in SQL is used to add new rows of data to a table. It is one of the most frequently used Data Manipulation Language (DML) commands, enabling users to populate tables with initial or additional data. 1. Purpose The INSERT command is used to: Add a single row to a table. Add multiple rows in one operation. Insert data from another table using a query. 2. Syntax A. Basic Insert Syntax INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); table_name : Name of the table where data will be inserted. column1, column2, ... : List of columns where data will be inserted. value1, value2, ... : Corresponding values for the specified columns. B. Inserting All Columns If all columns are to be populated, you can omit the column list: INSERT INTO table_name VALUES (value1, value2, value3, ...); C. Insert Multiple Rows INSERT ALL INTO table_name (column1, column2) VALUES (value1, value2) INTO table_name (colu...

DROP command

 The DROP command in Oracle Database is used to permanently delete database objects , such as tables, views, indexes, or even the entire database schema. Once a table or other object is dropped, it is removed from the database and cannot be recovered (unless you have enabled features like Oracle's Recycle Bin). 1. Purpose of DROP Command Completely removes the specified object from the database. Deletes the structure and data of the object. Drops dependent objects like constraints, indexes, and triggers associated with the table. 2. Syntax DROP TABLE table_name [CASCADE CONSTRAINTS] [PURGE]; 3. Parameters table_name : Specifies the name of the table to drop. CASCADE CONSTRAINTS : Drops the table along with all constraints (e.g., foreign key constraints) referencing it. PURGE : Removes the table from the Oracle Recycle Bin, making it unrecoverable. 4. Examples A. Basic Drop Table Deletes the table and all its data. DROP TABLE EMP1; B. Drop Ta...