Sunday, April 25, 2021

Quick reference in database management systems

Quick reference in DBMS, Database management systems quick reference section, quick reference to multiple basic questions in DBMS, database questions and answers

Quick Reference

Is it mandatory to give value to primary key when record is inserted?

Yes. Primary key is an attribute with the following property;

PRIMARY KEY = UNIQUE + NOT NULL

Due to NOT NULL property, we need to include data for primary key attribute while inserting a record.

 

Two different ways to insert primary key in table

  1. You can include a primary key in the CREATE TABLE statement while creating a table.
  2. You can include a primary in the ALTER TABLE statement using ADD PRIMARY KEY(column(s)).

Example (Oracle SQL):

  • CREATE TABLE x (abc CHAR(10) PRIMARY KEY, xyz VARCHAR(20));
  • ALTER TABLE z ADD PRIMARY KEY(Sno);

 

3 different techniques to achieve 1nf with suitable examples

  • Reducing ER diagram into database schema
  • Flatten the records of an un-normalized table
  • Decompose an un-normalized table into one or more tables.

 

What is the name of the schema that contains definitions for schema objects in a catalog?

Data dictionary is the name of schema.

Name for data dictionary schema by various RDBMSs

  • Oracle – Data dictionary
  • MySQL – Information Schema
  • IBM DB2 – SYSCAT schema

 

What will happen if locks are released just before commit? Will other transactions interfere and acid property is affected?

If the locks on data items are released before commit, there is a possibility that the released data items values (which are uncommitted) may be consumed by other ongoing transactions (if any). This may result in inconsistent database.

 

The person involved with database design is called.

Usually DBA designs a database. In case of very large organizations, it may be divided between various DBAs with names like “database designer” or “database architect”.

 

Advantages and disadvantages of using foreign key in same table as primary key or in different table

 

Give pros and cons of lock based protocols for concurrency control

 

How to avoid lost update problem?

Let us assume two transactions A and B are working on same data item Q. If both of them are trying to update the value of Q, this will result in lost update problem. To avoid this situation, the transactions that are working on same data item must update the data item after the other transactions commit.

 

How to avoid dirty read problem?

Reading the value of a data item that was produced by an uncommitted transaction is referred as dirty read problem. This will be avoided if we permit transactions to read the values that are produced by committed transactions.

 

What is the solution for lost update and dirty read problems?

Transactions should be permitted to read/use the data items that are produced by committed transactions.

 

Where do we use BCNF? Why?

We use BCNF when there are more than one candidate keys in a table and they are overlapping.

BCNF is a stronger version of 3NF because it restricts both prime and non-prime attributes, while 3NF only restricts non-prime attributes.

 

Is deadlock prevention preferred over deadlock detection in database concurrency?

No. Deadlock prevention is costly when compared with the cost of deadlock detection. Hence, deadlock detection is preferred most of the time.

 

What's the difference between minimal cover and closure of a functional dependency?

A minimal cover of a set of functional dependencies (FDs) F is a minimal set of FDs Fmin that is equivalent to F.

Closure of set F of FDs is a set of all possible FDs (denoted as F+) that are logically implied by F. Closure is derived using Armstrong’s axioms and additional rules.

Simply put, for a set F, minimal cover includes only required number of FDs that imply F, whereas closure has redundant FDs that imply F.

 

Compare and contrast various indexing techniques in different database systems

To insert date and time in the database data type is used

How can we delete particularly a second row from a table in a single line SQL command?

 

*********************

 

 

Sunday, March 28, 2021

Operating systems multiple choice questions for GATE exams - Set 23

Operating systems exams - multiple choice questions (MCQ) and answers, Objective type questions, OS exam questions, MCQ in memory management, process management, disk scheduling, process state transition, race condition


Operating Systems MCQ questions and answers – Set 23

1. A computer system has a 36-bit virtual address space with a page size of 8K, and 4 bytes per page table entry. How many pages are in the virtual address space?

a) 8,192

b) 4,096

c) 68,71,94,76,736

d) 83,88,608

Answer: (d) 83,88,608  

A 36 bit address can address 2^36 bytes in a byte addressable machine. Since the size of a page 8K bytes (2^13), the number of addressable pages is 2^36 / >2^13 = 2^23 = 83,88,608.

 

2. Which is true about process termination?

a) The waitpid operation always blocks the calling process

b) A child process can kill another child process of the same parent process

c) A child process that exits before the parent process does a waitpid operation becomes a zombie process

d) None of the above

Answer: (d) None of the above    

Process termination is a technique in which a process is terminated and releases the CPU after completing the execution. It may happen in the following situations;

normal conditions (exit() call), abnormal termination (due to programming error, runtime error, i/o error etc.), parent may terminate child process, due to memory requirement etc.

 

3. In the process state transition diagram, the transition from the Ready state to the Running state:

a) Indicates that a process was preempted by another process

b) Indicates that a process is chosen by CPU for execution

c) Indicates that a process is done waiting for an I/O operation

d) Indicates that a process has blocked on an I/O operation

Answer: (b) Indicates that a process is chosen by CPU for execution         

Ready state - The task has completed preparations for running, but cannot run because a task with higher precedence is running. In this state, the task is able to run whenever it becomes the task with the highest precedence among the tasks in READY state.

Running state - A process moves into the running state when it is chosen for execution. The process's instructions are executed by one of the CPUs (or cores) of the system.

The transition from ready state to running state happens if the process is chosen for execution by the CPU.

 

4. Disk scheduling algorithms attempt to reduce

a) Transfer time

b) Rotational latency

c) Seek time

d) All of the above

Answer: (c) Seek time 

In operating systems, seek time is very important. Since all device requests are linked in queues, the seek time is increased causing the system to slow down. Disk Scheduling Algorithms are used to reduce the total seek time of any request.

Seek time – Seek time is the time taken for a hard disk controller to locate a specific piece of stored data. It measures the delay for the disk head to reach the track.

Transfer time – It is about how long the actual data read or write takes. It is the time actually taken to transfer a span of data.

Rotational latency - Rotational latency (or just latency) is the delay waiting for the rotation of the disk to bring the required disk sector under the read-write head. It accounts for the time to get to the right sector.

 

5. Two threads in the same process share the same

a) Address space

b) Program counter

c) Stack

d) All of the above

Answer: (a) Address space

In a multi-threaded process, all of the process’ threads share the same memory and open files. Within the shared memory, each thread gets its own stack. Each thread has its own instruction pointer and registers.

Threads allow for efficient sharing of information, since the address space is shared, multiple threads can directly access the same memory.

 

*********

Related links:


OS Interview questions with answers

How disk scheduling algorithms reduce the seek time

GATE questions in system programming and operating systems

Why threads are good at information sharing

Operating systems interview questions for competitive exams

objective type OS questions for IIT JEE entrance exam

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents