Assignment
Assignment
1. Introduction
In today’s digital world, data is a crucial asset for organizations. Databases are
designed to store, organize, and manage large amounts of data efficiently. To
ensure that databases are structured logically and effectively, data modelling is
used during the design phase. One of the most important and widely used data
modelling techniques is the Entity-Relationship (ER) Model. It provides a
clear visual representation of data and the relationships between different types
of data. This assignment explores the components, structure, and purpose of ER
models in database design.
4. ER Diagrams
An ER diagram is the graphical representation of an ER model. The standard
symbols used include:
Rectangles for entities
Ellipses for attributes
Diamonds for relationships
Lines to connect entities to attributes and relationships
These diagrams provide a clear and structured view of how data is organized.
Student Table:
- StudentID (PK)
- Name
- DOB
Course Table:
- CourseID (PK)
- Title
3. Comparison:
Operate on whole
Use case Project specific attributes
tuples
Conclusion
TRC and DRC both define queries declaratively. They form the theoretical basis
for SQL and help in understanding how relational databases retrieve information.
StudentI Nam
Subjects
D e
Math,
1 John
Science
1 John Math
1 John Scienc
StudentI Nam Subjec
D e t
1 Math John
Here, the primary key is (StudentID, Subject), but StudentName depends only on
StudentID.
Corrected (2NF):
Student Table:
StudentI StudentNa
D me
1 John
Enrollment Table:
StudentI Subjec
D t
1 Math
101 D1 Sales
Employee DeptI
ID D
101 D1
Department Table:
DeptI DeptNa
D me
D1 Sales
DB Smith R1
Assume:
A course has one instructor.
An instructor teaches in only one room.
But an instructor can teach multiple courses.
Here, Instructor → Room, but Instructor is not a super key, violating BCNF.
Corrected (BCNF):
Instructor Table:
Instruct Roo
or m
Smith R1
Course Table:
Cours Instruct
e or
DB Smith
Conclusion
Normalization is a key concept in relational database design that helps maintain
data integrity, reduce redundancy, and avoid anomalies during data
operations. Understanding the different normal forms — 1NF, 2NF, 3NF, and
BCNF — provides the foundation for creating efficient and well-structured
databases.
Conclusion
Buffer management is a vital component of a DBMS that ensures efficient data
access and overall system performance. By minimizing disk I/O operations, using
intelligent replacement strategies, and managing memory efficiently, the buffer
manager helps optimize query execution and maintain data consistency during
concurrent transactions.
o Leaf nodes store actual data (records) and are linked together
for easy range traversal.
3. 🔗 Linked Leaves:
Leaf nodes are doubly linked, making range queries and sequential
access very fast.
4. 📈 High Fan-Out:
Nodes can have many children, reducing the tree height and improving
performance for large datasets.
Structure Example:
[20 | 40]
/ | \
[5,10] [25,30] [45,50]
Internal node [20 | 40] helps navigate.
Leaf nodes contain actual data (values).
Advantages:
🔍 Efficient search, insert, and delete operations: O(log n)
🚀 Great for range queries due to linked leaves
🧠 Minimizes disk I/O with high branching factor
Conclusion:
A B+ Tree is a powerful and efficient indexing structure ideal for databases. Its
balance, fast access, and support for range queries make it a preferred choice in
real-world applications where performance is critical.
1. INNER JOIN
Definition: Returns only the rows that have matching values in both
tables.
Use Case: When you only want data that exists in both tables.
Example:
SELECT A.name, B.salary
FROM Employees A
INNER JOIN Salaries B ON A.emp_id = B.emp_id;
✅ Matches only common records.
5. CROSS JOIN
Definition: Returns the Cartesian product of both tables (all possible
combinations).
Use Case: When you want every row of one table combined with every
row of another.
Example:
SELECT A.name, B.project
FROM Employees A
CROSS JOIN Projects B;
⚠️Can produce a very large number of rows.
6. SELF JOIN
Definition: A table is joined with itself.
Use Case: To compare rows within the same table.
Example:
sql
CopyEdit
SELECT A.name AS Employee, B.name AS Manager
FROM Employees A
JOIN Employees B ON A.manager_id = B.emp_id;
✅ Useful for hierarchical data like employees and managers.
Summary Table:
left rows
[1] [1]
[2] [2]
[3] [4]
A∪B
┌─────────┐
│█ █ █│
│█ █ █│
└─────────┘
5. CROSS JOIN
🟦 × 🟥 → All possible combinations (Cartesian product)
A has 3 rows, B has 2 rows → 3 × 2 = 6 rows
A = [1, 2, 3]
B = [X, Y]
6. SELF JOIN
Table joined with itself:
Employees:
[1, Alice, mgr_id=3]
[2, Bob, mgr_id=3]
[3, Carol, mgr_id=NULL]
🧮 Pseudocode (4-connected):
BoundaryFill(x, y, fillColor, boundaryColor):
if color at (x, y) ≠ boundaryColor and ≠ fillColor:
set color at (x, y) to fillColor
BoundaryFill(x+1, y, fillColor, boundaryColor)
BoundaryFill(x-1, y, fillColor, boundaryColor)
BoundaryFill(x, y+1, fillColor, boundaryColor)
BoundaryFill(x, y-1, fillColor, boundaryColor)
5. Stop when all connected pixels of the target color are filled.
🧮 Pseudocode (4-connected):
FloodFill(x, y, targetColor, newColor):
if color at (x, y) == targetColor:
set color at (x, y) to newColor
FloodFill(x+1, y, targetColor, newColor)
FloodFill(x-1, y, targetColor, newColor)
FloodFill(x, y+1, targetColor, newColor)
FloodFill(x, y-1, targetColor, newColor)
🧱 Structure / Concept:
The clipping window is defined by:
Left boundary: x_min
Right boundary: x_max
Bottom boundary: y_min
Top boundary: y_max
📋 Algorithm Steps:
1. Take the point (x, y) that needs to be tested.
2. Check the conditions:
if (x_min ≤ x ≤ x_max) AND (y_min ≤ y ≤ y_max)
→ The point is inside the clipping window → Accept
else
→ The point lies outside the window → Reject
✅ Example:
Clipping window:
x_min = 100, x_max = 300
y_min = 100, y_max = 200
Test point: (150, 150) → Inside ✅
Test point: (350, 150) → Outside ❌
🧱 Structure:
Input: A convex polygon and a rectangular clipping window.
Output: A new polygon formed by the intersection of the original polygon
and the window.
The algorithm clips the polygon edge-by-edge:
1. Left
2. Right
3. Bottom
4. Top
📋 Algorithm Steps:
1. Start with the original polygon vertices.
2. For each edge of the clipping window (left, right, bottom, top):
o Process each edge of the polygon:
*-----* *----*
/ \ +------------+ / \
* * | | * *
\ / +------------+ \ /
*-----* *----*
✅ Advantages:
Efficient for convex polygons
Preserves polygon shape within clipping window
⚠️Limitations:
Can produce incorrect results for concave polygons
Does not handle self-intersecting polygons
o Examples:
📋 Properties:
The curve starts at the first control point and ends at the last
control point.
It does not usually pass through intermediate control points.
The curve is smooth and continuous.
The shape is influenced by the positions of the control points.
The curve starts at P0, curves toward P1 and P2, and ends at P3.
You can draw a curve flowing from P0 to P3, gently pulled toward P1 and P2.
🧭 Parallel Projection
🔍 Definition:
Parallel projection is a type of projection used in computer graphics where
parallel lines in 3D space remain parallel when projected onto a 2D plane. It
does not simulate perspective, so objects do not appear smaller as they get
farther from the viewer.
🧱 Key Features:
No vanishing points
No foreshortening (size remains constant regardless of depth)
Used for technical drawings, engineering designs, and architectural
plans
Maintains proportions and true dimensions
Cavalier: Cabinet:
_______ _______
/ /| / /|
/______/ | /______/ |
| | | | | |
| | / | |/
|______/ |______/
✏️Applications:
Engineering and mechanical drawings
Architectural floor plans
Game development (for isometric views)
CAD tools and modeling software
✅ Advantages:
Maintains true dimensions
Easier for measuring and designing
Simpler to compute than perspective projection
❌ Disadvantages:
Lacks realism (no depth perception)
Not suitable for visual storytelling or lifelike rendering
📚 Core Concept:
The space is divided into two halves by a line/plane.
One side is called the front, the other the back.
The process is recursive, creating a binary tree structure.
[Plane A]
/ \
[Plane B] [Plane C]
/ \ / \
... ... ... ...
🧱 BSP Tree Construction Method:
📋 Steps:
1. Choose a partitioning line/plane (e.g., a polygon).
2. Classify all other objects as:
o In front
o Behind
✅ Advantages:
Efficient for rendering static scenes
Good for visibility ordering
Simplifies scene management
❌ Disadvantages:
Costly to build for dynamic objects
Not ideal for frequent updates
May create many split polygons
💻 Benefits of Using Visual Studio
Visual Studio is a powerful Integrated Development Environment (IDE)
developed by Microsoft. It is widely used by software developers for building
web, desktop, mobile, and cloud-based applications.
Key Benefits:
1. ✅ All-in-One IDE
Supports multiple programming languages: C#, C++, Python,
JavaScript, etc.
Integrated tools for coding, debugging, testing, and deployment.
3. 🐞 Advanced Debugging
Breakpoints, watch windows, step-by-step execution.
Visualizers help inspect complex data types easily during runtime.
4. 🔧 Built-in Tools and Extensions
Integrated Git support for version control.
Extensions available via Visual Studio Marketplace for UI design,
database tools, etc.
8. 🎨 User-Friendly Interface
Modern UI with customizable themes, window layout, and productivity
shortcuts.
9. 📊 Performance Profiler
Analyze CPU usage, memory usage, and app performance.
Helps in optimizing applications before deployment.
📝 Conclusion:
Visual Studio boosts developer productivity with powerful tools, smart
features, and support for various platforms and programming languages —
making it one of the most trusted IDEs in the software industry.
🌟 Key Features:
1. ✅ Cross-Platform Support
o Works on Windows, macOS, and Linux.
2. 🧠 IntelliSense
o Smart code suggestions, syntax highlighting, and auto-
completion.
3. 🧩 Extensions & Plugins
o Thousands of extensions available for languages, tools, themes, and
frameworks.
o Popular extensions: Python, Prettier, ESLint, Live Server.
4. 🐞 Built-in Debugger
o Supports step-by-step debugging with breakpoints, watch, and
call stack.
5. 🌐 Integrated Terminal
o Run command-line tasks without leaving the editor.
6. 🔄 Git Integration
o Easily manage version control with built-in Git support (commit,
push, pull).
7. 💡 Customizable UI
o Themes, icon packs, and layout adjustments for a personalized
experience.
Use Cases:
Web development (HTML, CSS, JavaScript)
Python programming
Node.js and backend services
C++, Java, and other general-purpose coding
Data science and scripting
✅ Advantages:
Free and open-source
Fast and lightweight
Actively maintained with regular updates
Large community and rich extension ecosystem
📝 Conclusion:
VS Code is an excellent code editor for both beginners and professionals.
With its rich features, ease of use, and flexibility, it has become one of the
most popular development tools in the world.
💼 Various Types of Projects in Visual Studio
Visual Studio (VS) supports a wide variety of project types for developing
applications across different platforms like Windows, web, mobile, cloud,
and gaming.
1. Console Applications
Purpose: Create simple applications that run in the command-line
interface.
Languages: C#, C++, VB.NET
Use Case: Testing logic, automation scripts, basic I/O operations.
Example: A calculator program in C#.
🌐 2. Web Applications
Purpose: Create dynamic websites and web services.
Frameworks: ASP.NET, ASP.NET Core, Blazor
Languages: C#, HTML, CSS, JavaScript
Example: An e-commerce website using ASP.NET MVC.
📱 3. Mobile Applications
Purpose: Build cross-platform mobile apps.
Tools: Xamarin, .NET MAUI
Platforms: Android, iOS, Windows
Example: A fitness tracker app for Android and iOS using .NET MAUI.
📝 Conclusion:
Visual Studio offers a wide variety of project templates that cater to
developers in every domain, from beginners building simple apps to
professionals working on enterprise-level solutions, cloud platforms, or
cross-platform mobile development.
📚 1. Creating a Database
🔍 Definition:
Creating a database is the process of setting up a new structured storage
system to hold and manage data. In SQL (Structured Query Language), we
use the CREATE DATABASE statement.
SQL Syntax:
CREATE DATABASE SchoolDB;
✅ Explanation:
This SQL command creates a new database named SchoolDB. You can now
use it to store tables like Students, Teachers, Courses, etc.
SQL Syntax:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Age INT,
Grade VARCHAR(10)
);
✅ Explanation:
This creates a Students table with 5 columns:
StudentID: a unique ID for each student.
FirstName, LastName: names stored as text.
Age: student’s age as a number.
Grade: the class or level.
💡 Example:
CREATE TABLE Books (
BookID INT PRIMARY KEY,
Title VARCHAR(100),
Author VARCHAR(100),
PublishedYear INT
);
➡️This adds a Books table to your LibraryDB database.
📝 Conclusion:
Creating a database sets up a container for your data.
Adding a table organizes that data into structured formats.
🧬 Class Inheritance
🔍 Definition:
Inheritance is a fundamental concept in Object-Oriented Programming
(OOP) where one class (called the child or derived class) inherits properties
and behaviors (methods) from another class (called the parent or base
class).
It promotes code reusability, extensibility, and hierarchical
classification.
✅ Benefits of Inheritance:
Reuse existing code
Simplify maintenance
Enable polymorphism
Promote hierarchical modeling
📘 Example 1: C++
#include <iostream>
using namespace std;
// Base class
class Animal {
public:
void eat() {
cout << "This animal eats food." << endl;
}
};
// Derived class
class Dog : public Animal {
public:
void bark() {
cout << "The dog barks." << endl;
}
};
int main() {
Dog d;
d.eat(); // Inherited from Animal
d.bark(); // Defined in Dog
return 0;
}
💡 Output:
This animal eats food.
The dog barks.
🐍 Example 2: Python
# Base class
class Animal:
def eat(self):
print("This animal eats food.")
# Derived class
class Dog(Animal):
def bark(self):
print("The dog barks.")
📝 Conclusion:
Inheritance helps build relationships between classes, allowing the child
class to reuse the code of the parent class while adding its own unique
features.
📄 1. Design (Default.aspx)
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Student Info Form</title>
</head>
<body>
<form id="form1" runat="server">
<h2>Student Information Form</h2>
💻 2. Code-Behind (Default.aspx.cs)
using System;
using System.Data;
using System.Web.UI;
DataRow dr = studentTable.NewRow();
dr["Name"] = txtName.Text;
dr["Roll No"] = txtRoll.Text;
dr["Department"] = txtDept.Text;
studentTable.Rows.Add(dr);
ViewState["StudentTable"] = studentTable;
gvStudents.DataSource = studentTable;
gvStudents.DataBind();
// Clear inputs
txtName.Text = "";
txtRoll.Text = "";
txtDept.Text = "";
}
}
How to Run:
1. Open Visual Studio
2. Create a New ASP.NET Web Forms App
3. Add the above code to Default.aspx and Default.aspx.cs
4. Run the app with Ctrl+F5
✅ Output:
A simple form that:
Accepts student details (Name, Roll No, Department)
Displays them in a GridView
Stores data in ViewState (temporary memory)