0% found this document useful (0 votes)
2 views5 pages

SQL Linux Unix Interview Master Guide

Sql

Uploaded by

bhangale.latesh
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)
2 views5 pages

SQL Linux Unix Interview Master Guide

Sql

Uploaded by

bhangale.latesh
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

Technical Interview Preparation Guide

COMPREHENSIVE CORE Q&A: SQL, LINUX & UNIX BASICS

Section 1: SQL Essentials

Q1. What is DBMS, and how does RDBMS differ from it?
A Database Management System (DBMS) is software used to store, manage, and retrieve data. A
Relational DBMS (RDBMS) is a subset of DBMS that explicitly stores data in tabular forms (rows and
columns) and enforces relationships between tables using keys (Primary Key, Foreign Key), adhering to
relational algebra.

Q2. Explain the differences between DDL, DML, DCL, and TCL commands.
SQL commands are structurally grouped based on their functionality:

Category Description Examples

Defines or alters the structural schema


DDL (Data Definition
of the database. Changes are auto- CREATE , ALTER , DROP , TRUNCATE
Language)
committed.

DML (Data
Manages and manipulates data within SELECT , INSERT , UPDATE ,
Manipulation
existing database structures. DELETE
Language)

DCL (Data Control Controls permissions and access


GRANT , REVOKE
Language) rights to the database.

TCL (Transaction Manages transactions within the


COMMIT , ROLLBACK , SAVEPOINT
Control Language) database to ensure atomic changes.

Q3. What is the precise difference between DELETE, TRUNCATE, and DROP?
DELETE: A DML command used to remove specific rows based on a WHERE clause. It logs individual
row deletions, making it slower, but the operation can be rolled back. Trigger invocation occurs.
TRUNCATE: A DDL command that removes all rows from a table. It cannot accept a WHERE clause. It
deallocates the data pages directly, making it extremely fast. It resets identity counters and cannot be
rolled back easily in some environments without active transactions. Triggers are not fired.
DROP: A DDL command that completely removes both the data and the table structural definition from
the database schema.

Master Interview Preparation Guide Page 1 of 5


Q4. Explain the various types of JOINS in SQL.
Joins are used to combine records from two or more tables based on a related logical column:

• INNER JOIN: Returns only the rows that have matching values in both tables.
• LEFT (OUTER) JOIN: Returns all records from the left table, and matching records from the right
table. If no match exists, NULL values are returned for the right table columns.
• RIGHT (OUTER) JOIN: Returns all records from the right table, and matching records from the left
table. If no match exists, NULL values are returned for the left table columns.
• FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
records. Unmatched rows display NULLs.
• CROSS JOIN: Produces a Cartesian product of both tables (multiplies every row of the first table
with every row of the second).

Q5. What is the difference between the WHERE clause and the HAVING clause?
The WHERE clause is applied to filter rows *before* any groupings or aggregate functions are calculated.
The HAVING clause is explicitly used to filter groups or aggregate results created by the GROUP BY
clause. You cannot use aggregate functions (like SUM() , COUNT() ) inside a standard WHERE clause.

Q6. What are Primary Keys, Foreign Keys, and Unique Keys?
Primary Key: Uniquely identifies each record in a table. It cannot contain NULL values, and a table can
only possess exactly one primary key.
Unique Key: Enforces uniqueness across a column or set of columns. Unlike primary keys, a unique key
column can accept a NULL value (depending on RDBMS implementation, usually exactly one NULL). A
table can have multiple unique keys.
Foreign Key: A column or combination of columns used to establish and enforce a link between data
across two tables (Referential Integrity). It maps to a primary key or unique key in the reference parent
table.

Q7. Explain ACID properties in relational databases.


ACID ensures reliable transaction processing:

• Atomicity: Ensures that the entire transaction succeeds, or it all completely fails (All-or-Nothing).
• Consistency: Guarantees that a transaction transforms the database from one valid state to
another, strictly adhering to all database schemas and constraints.
• Isolation: Ensures concurrent execution of transactions leaves the database in the same state as
if they were executed sequentially.
• Durability: Guarantees that once a transaction commits, its modifications survive permanently,
even during a sudden power outage or system crash.

Master Interview Preparation Guide Page 2 of 5


Q8. What is a Subquery? Contrast a Correlated vs. Non-Correlated Subquery.
A subquery is a query nested inside another statement (such as SELECT , INSERT , UPDATE , or
DELETE ).
A Non-Correlated Subquery is independent of the outer query and can be executed separately; it
evaluates once before the outer query runs.
A Correlated Subquery references columns from the outer query, meaning it must execute iteratively
once for every single row processed by the outer query, impacting performance.

Q9. Explain Clustered vs. Non-Clustered Indexes.


A Clustered Index physically alters the actual sorting and storage layout of rows inside the table based
on the index key. A table can have only one clustered index (typically assigned automatically to the
primary key). A Non-Clustered Index creates a separate structural object that points back to the
physical data rows; it behaves like an index at the back of a textbook, allowing multiple definitions on a
single table.

Section 2: Linux & Unix Fundamentals

Q10. What is the core difference between Unix and Linux?


Unix is an ancient, proprietary commercial operating system originally created by AT&T Bell Labs, widely
used in massive legacy corporate infrastructures (examples: IBM AIX, Oracle Solaris, HP-UX). Linux is a
completely open-source, free kernel developed by Linus Torvalds, packaged into multiple distributions
(Ubuntu, CentOS, RedHat) that conform to Unix standards.

Q11. Describe the layered architecture of a standard Linux system.


The system architecture comprises four critical layers:

1. Hardware: Physical machine components (CPU, RAM, Disks).


2. Kernel: The core core software interacting directly with physical hardware, handling process
management, memory allocation, and system safety.
3. Shell: The command-line interpreter workspace interface acting as a bridge where users input
commands executed by the kernel.
4. Applications / Utilities: User-level programs and system binaries (such as web browsers, scripts,
editors like vim ).

Master Interview Preparation Guide Page 3 of 5


Q12. How do you view and modify file permissions in Linux?
Running ls -l displays permissions formatted as 10 characters (e.g., -rwxr-xr-- ). The first
character denotes file type ( - for file, d for directory). The next 9 characters represent three sets of
permissions: **Owner**, **Group**, and **Others**.
Each set has Read ( r=4 ), Write ( w=2 ), and Execute ( x=1 ) permissions. To modify permissions, use
chmod :
Absolute/Numeric Mode: chmod 754 filename (Owner gets rwx=7, Group gets r-x=5, Others get r--
=4).
Symbolic Mode: chmod u+x,g-w filename (Adds execution to owner, removes write from group).

Q13. What is the absolute difference between a Hard Link and a Soft (Symbolic) Link?
Hard Link: Points directly to the identical physical inode data block on the storage drive as the source
file. If the original source file is deleted, the hard link remains active and fully accessible. It cannot cross
different file systems or link directories.
Soft Link (Symlink): Acts as a shortcut pointer containing the path text of the target file. If the original
source file is deleted, the symlink breaks ("dangling link"). It can freely link directories and cross separate
file system barriers.

Q14. What do Pipes and Redirections mean in Linux? Provide syntax examples.
Redirection: Changes standard input/output streams.

• > overwrites standard output to a file: ls > [Link]


• >> appends standard output to a file: echo "text" >> [Link]
• < reads standard input from a file.

Pipe ( | ): Feeds the standard output of the left-hand command directly into the standard input stream of
the right-hand command: cat [Link] | grep "ERROR"

Q15. Explain the Linux Directory Hierarchy purposes (/etc, /bin, /var, /tmp).

• /bin : Stores critical structural single-user system binaries needed for basic operations (e.g., ls ,
cp ).
• /etc : Contains system-wide configuration files for applications and services.
• /var : Holds variable files subject to continuous runtime growth, such as system logs, databases,
and mail queues.
• /tmp : Temporary storage directory accessible to all users; cleared automatically upon system
reboots.

Master Interview Preparation Guide Page 4 of 5


Q16. How do you track and manage active processes in Linux?
Use ps or ps -ef to display snapshots of currently active user processes. Use top for an interactive
real-time resource utilization monitor showing active CPU and RAM details. To stop a non-responsive
process, locate its Process ID (PID) and invoke kill [PID] . To forcefully terminate a process, use
kill -9 [PID] .

Section 3: Essential Commands Cheat Sheet

Must-Know System Operations and Commands Matrix:

Command Functional Purpose Practical Example Usage

pwd Print current active working directory path. pwd

grep -i "exception"
grep Search regular expression patterns within text.
[Link]

Search structural file paths inside hierarchical


find find /home/user -name "*.sh"
directories.

tar -cvzf [Link] /var/


tar Archive and compress system directories.
logs

Check total and available disk space in human-


df -h df -h
readable terms.

Display active system RAM memory


free -m free -m
consumption in megabytes.

Change owner and group metadata permissions


chown chown root:admin [Link]
of a file.

Master Interview Preparation Guide Page 5 of 5

You might also like