Saturday, February 21, 2026

functional dependency and its types DBMS

Functional dependency is a constraint applied on a relation in which user can able to access values of all attributes of relation by giving value of a single attribute. it means "We can access record / row / tuple of a relation with the help of only one special attribute (key)"

Let R[A] is a relational schema. 
Here A is a set of attributes present in relation R and x,y are subset of A. 
We can say that y depends on x. 
If set of all YA then T1,T2єR such that

T1[x] = T2[x] => T1[y] = T2[y]

It shows that if two or more tuple's have same value in column x then they also have same value in column y. Thus y column depends on x column. 
We can understand functional dependency with the help of following table-



Here,   T1[A]=T2[A] => T1[C] = T2[C]
thus,  A→C

In above relation values of attribute C depend on values of attribute A but converse is not true (C→A)

There are three types of functional dependency-

(1) full functional dependency-  If relation R has a functional dependency A→B then attribute B is called full functional dependent on attribute A, if there is no Subset cєA exist for which c→B it means value of B only depend on values of A attribute.
Example-  If  all the non-key attributes depend on Primary key of table then this type of functional dependency is called full functional dependency. Similarly in account table all the non-key attributes depend on account number primary key. 

(2) partial functional dependency- If relation R has a functional dependency A→B than B is called partial functional dependent on attribute A if there is Subset cєA exist for which C→B  It means values of  attribute B can be determined by any proper subset of A. 
for example we have a relation R(A,B,C,D) where AC is primary key  AC→B, AC→D, but A→B Here A is alone capable of determining B which means B is partially dependent on AC.

Ex-  









In above table (Roll-no,Name) is a primary key then Roll-no, Name → course, Roll-no→ course, and Name→ course Thus course is partially dependent on primary key (Roll-no, name).

(3) Transitive functional dependency-
 If a relation R has two or more non-key attributes which are functionally dependent and satisfy following condition 
A→B, B→C=> A→C for R(A, B, C)

Then C attribute is transitively dependent on attribute A.
To understand transitive functional dependency consider following table:-



In above table transitive functional dependency is
D_name →city, city → State => D_name → State.

Conclusion :-
functional dependency is very important for relational model.so it is neccessary that all the non-key attributes must be dependent on key attribute. it means "a relation which shows full functional dependency is free from anomalies but if a relation has partial functional dependency or transitive functional dependency or both then it affects operations of database. It Shows bad anomalies which affects Data Storing, data accessing, data manipulation and applying constraint etc operations of database. Due to which database performance decreases. In addition database with anomalies will generate incorrect result and give slow response against query. Hence, Normalisation is used to remove anomalies like Partial functional dependency, transitive functional dependency and others from the database.




Friday, December 19, 2025

System calls in os

System calls (syscalls) are the programmatic way for an application to request services from the operating system's kernel. They act as a vital bridge between user-space applications (with limited privileges) and the kernel (with full hardware access). 

How System Calls Work:

  1. User Mode: The application runs in a restricted "user mode" where it cannot directly touch hardware or memory of other processes.
  2. The Request: When it needs a service (like saving a file), it issues a system call instruction (often called a trap or software interrupt).
  3. Mode Switch: The CPU switches from user mode to kernel mode, giving the OS full authority to perform the task safely.
  4. Execution & Return: The kernel executes the requested service, then switches the CPU back to user mode and returns the results to the application. 
Types of System Calls with Examples
CategoryPurposeUnix/Linux ExampleWindows Example
Process ControlCreating, stopping, or managing programs.fork()exit()wait()CreateProcess()ExitProcess()
File ManagementOpening, reading, writing, or deleting files.open()read()write()close()CreateFile()ReadFile()
Device ManagementInteracting with hardware like printers or disks.ioctl()read()write()SetConsoleMode()ReadConsole()
Information MaintenanceGetting/setting system time or attributes.getpid()sleep()alarm()GetCurrentProcessID()Sleep()
CommunicationExchanging data between different programs.pipe()shmget()mmap()CreatePipe()MapViewOfFile()
ProtectionControlling access permissions.chmod()chown()SetFileSecurity()
Real-World Example: Saving a Document
When you click "Save" in a text editor like Notepad:
  1. The editor calls an API function (e.g., WriteFile in Windows).
  2. This triggers a system call to the kernel.
  3. The kernel verifies your permissions and physically writes the data to your SSD/HDD.
  4. Once done, the kernel tells the editor "Success," and you can continue typing.

Linker in OS

A linker (or link editor) is a system utility that combines multiple separately compiled object files and library modules into a single, cohesive executable file. It serves as a bridge between the translation phase (compilation/assembly) and the execution phase. 

Key Functions of a Linker

  • Symbol Resolution: The linker scans object files to match function and variable references (symbols) with their actual definitions. For example, if a program calls printf(), the linker finds the implementation of printf in the standard C library.
  • Relocation: Since compilers typically assume a program starts at address zero, the linker "relocates" these code and data segments to their final assigned memory addresses.
  • Code Consolidation: It merges various sections (like .text for code and .data for variables) from different modules into one continuous block. 


Types of Linking
Feature Static LinkingDynamic Linking
TimingPerformed during compilationPerformed at load or run time
File SizeLarger (includes all library code)Smaller (only contains references)
MemoryRedundant; each program has its own copyEfficient; multiple programs share one copy
UpdatesRequires recompilation if libraries changeLibraries can be updated independently
ExampleWindows .exe or Linux .a filesWindows .dll or Linux .so files
Practical Examples
  • C Programming: When you run the command gcc main.c utils.c -o myprog, the compiler first generates main.o and utils.o. The linker then "glues" these together with the standard C library to create the final myprog executable.
  • Shared Libraries: Most modern programs on Windows use dynamic linking for the DirectX or C++ Runtime libraries. This allows many different games or apps to use the same system files rather than each app carrying its own 100MB copy.

loader in os

A loader is a system utility and an essential component of an operating system responsible for taking an executable file (generated by the linker) from secondary storage (disk) and placing it into the main memory (RAM) for execution. It acts as the final bridge between static code on your disk and a running process in the CPU. 

Core Functions of a Loader
The loader typically performs four fundamental tasks to prepare a program: 
  1. Allocation: Reserving the required space in main memory based on the program's size.
  2. Linking: Resolving symbolic references between different modules or libraries that were not settled during static linking.
  3. Relocation: Adjusting internal memory addresses within the code so it can run correctly at its assigned location in RAM.
  4. Loading: Physically copying the machine code and data into the allocated memory space. 
Types of Loaders
  • Absolute Loader: Loads the program into a fixed, predetermined memory location. It is simple but inflexible because the program cannot be moved if that specific memory spot is occupied.
  • Relocating Loader: Allows a program to be loaded anywhere in available memory by modifying addresses on the fly during the loading process.
  • Dynamic Loader: Loads libraries and modules only when they are actually needed during program execution, which saves memory.
  • Bootstrap Loader: A specialized loader located in ROM that starts as soon as the computer is turned on; its only job is to load the primary operating system into RAM. 
Example Scenario
When you double-click a game icon on Windows:
  1. The OS Loader (invoked by a system call like execve() on Linux) reads the game's executable file.
  2. It checks for dependencies (like DirectX.dll) and finds space for them in memory.
  3. It allocates RAM for the game's code, player data, and sound files.
  4. Finally, it jumps the CPU's instruction pointer to the game's "entry point," and the game starts running.