Database and SQL
Database and SQL
SQL Analyzer is a powerful database tool used to write, test, execute, debug, and analyze SQL
queries before using them in real applications. When databases become large, queries may take
more time to run or may not give correct results. SQL Analyzer helps database developers and
administrators understand how a query is processed internally by the database engine.
It provides features such as query execution plans, which show how tables are accessed, which
indexes are used, and how much cost is involved in each step. By using SQL Analyzer, we can
identify slow-performing queries, remove unnecessary joins, optimize conditions in the
WHERE clause, and improve overall database performance. It also helps in detecting syntax
errors and logical mistakes in SQL statements. In short, SQL Analyzer is used to ensure that
SQL queries are efficient, fast, and error-free.
SQL Analyzer aik bohat important database tool hota hai jo SQL queries likhne, test karne,
execute karne, aur analyze karne ke liye use hota hai. Jab database bohat bara ho jata hai, to
queries slow ho sakti hain ya ghalat result de sakti hain. SQL Analyzer humein yeh samajhne
mein madad karta hai ke database engine query ko andar se kaise process karta hai.
Is tool ke zariye hum execution plan dekh sakte hain jisme bataya jata hai ke kaunsi table pehle
access ho rahi hai, kaunsa index use ho raha hai, aur kitna time lag raha hai. SQL Analyzer ki
madad se hum slow queries ko fast bana sakte hain, extra joins remove kar sakte hain aur
WHERE clause ko optimize kar sakte hain. Yeh syntax aur logical errors find karne mein bhi
help karta hai. Is liye SQL Analyzer ka use queries ko fast, efficient aur error-free banane ke
liye kiya jata hai.
DBMS (Database Management System) is software that is used to store, organize, and manage
data in a database. In DBMS, data is usually stored in the form of files or simple tables, and
relationships between data are not strictly enforced. Because of this, data redundancy occurs,
meaning the same data may be stored multiple times. DBMS does not always follow rules like
normalization and data integrity constraints.
DBMS aik software system hota hai jo data ko store, organize aur manage karta hai. DBMS
mein data zyada tar files ya simple tables ki form mein hota hai aur tables ke darmiyan proper
relation maintain nahi hota. Is wajah se data repeat ho jata hai jise redundancy kehte hain.
DBMS mein normalization aur integrity rules itne strict nahi hote.
RDBMS, DBMS ka advanced form hota hai jo data ko multiple related tables mein store karta
hai. Har table rows aur columns par mushtamil hoti hai. RDBMS mein primary key aur foreign
key ka use hota hai jis se tables ke darmiyan relation banta hai. Is system mein data redundancy
kam, data integrity strong, aur security behtar hoti hai. Is ke sath multi-user environment bhi
easily handle hota hai.
MySQL is one of the most widely used relational database systems because it is open-source,
fast, secure, and scalable. Many large platforms use MySQL to handle millions of users and
huge amounts of data.
1. Facebook – Uses MySQL to store user profiles, posts, messages, and interactions.
2. YouTube – Uses MySQL to manage video metadata, users, and comments.
3. WordPress – Uses MySQL as its backend database to store posts, pages, themes,
plugins, and user data.
4. Twitter (X) – Uses MySQL to manage tweets, user accounts, and real-time data.
5. LinkedIn – Uses MySQL to store professional profiles, connections, and job-related
data.
In MS-Access, a Query is a database object that allows users to interact with data stored in
tables. A query can be used to retrieve specific records, sort data, filter information,
calculate values, update records, or delete data. Queries help users extract meaningful
information from large databases by applying conditions.
Queries can be created using Query Design View or SQL View. They save time, reduce manual
work, and make data management more efficient. Queries are also used to create reports and
forms in MS-Access.
MS-Access mein Query aik database object hoti hai jo tables mein mojood data ke sath kaam
karne ke liye use hoti hai. Query ki madad se hum data ko search, filter, sort, update ya delete
kar sakte hain. Jab database bohat bara ho jaye to query bohat madadgar hoti hai.
Queries Query Design View ya SQL View ki madad se banai jati hain. Queries time bachati
hain aur data ko meaningful form mein show karti hain. Reports aur forms bhi aksar queries ki
madad se banaye jate hain.
Syntax:
The WHERE clause can include operators like =, >, <, >=, <=, AND, OR, NOT.
Example:
SELECT command database se data hasil karne ke liye use hota hai. WHERE clause ka use
condition lagane ke liye hota hai taake sirf required records show hon.
Syntax:
Example mein sirf woh students show hon ge jin ke marks 60 ya us se zyada hain.
Backup is the process of creating duplicate copies of data and storing them at a secure location
to protect against data loss. Data loss may occur due to hardware failure, virus attacks, accidental
deletion, or natural disasters. Regular backups are essential for businesses and organizations to
ensure continuity of operations.
Recovery is the process of restoring data from backup copies when the original data is lost,
damaged, or corrupted. Backup and recovery together form a critical part of database
management and disaster recovery planning. Without backup and recovery, permanent data loss
can cause serious financial and operational damage.
Backup ka matlab hota hai data ki duplicate copy banana aur usay kisi safe jagah par store
karna. Data loss system crash, virus attack, ya ghalti se delete hone ki wajah se ho sakta hai. Is
liye regular backup lena bohat zaroori hota hai.
Recovery ka matlab hota hai backup se data ko wapas restore karna jab original data kharab
ya delete ho jaye. Backup aur recovery database management ka bohat important hissa hain aur
business ko loss se bachate hain.
Long Answers
Q.1
(a) Difference between MS-Access, SQL, and MySQL
SQL (Structured Query Language) is not a software, but a standard language used to
communicate with databases. SQL is used to create databases, insert data, retrieve data,
update records, and delete records. Almost all database systems like MySQL, Oracle, SQL
Server, and MS-Access use SQL commands.
MySQL is a Relational Database Management System (RDBMS). It uses SQL as its query
language and is widely used for web applications. MySQL is fast, secure, open-source, and can
handle large databases. Websites like Facebook, WordPress, and YouTube use MySQL.
👉 In short:
MS-Access Microsoft ka banaya hua aik database software hai jo choti level ki databases ke
liye use hota hai. Is mein GUI (graphical interface) hota hai jis se tables, forms, queries aur
reports asaani se ban jati hain. Ye beginners aur small offices ke liye best hota hai.
SQL koi software nahi balkay aik language hai jo database se baat karne ke liye use hoti hai.
SQL ki madad se hum data insert, update, delete aur retrieve karte hain. Har database system
SQL ko support karta hai.
MySQL aik RDBMS hai jo SQL language use karta hai. Ye zyada tar websites aur online
systems mein use hota hai. MySQL fast, secure aur free hai aur bari databases handle kar sakta
hai.
1. UPPER()
Converts text into uppercase letters.
Example: UPPER('sql') → SQL
2. LOWER()
Converts text into lowercase letters.
Example: LOWER('HELLO') → hello
3. LTRIM()
Removes spaces from the left side of a text string.
Example: LTRIM(' Ali')
4. RTRIM()
Removes spaces from the right side of a text string.
Example: RTRIM('Ali ')
5. SUBSTRING()
Extracts part of a text from a given position.
Example: SUBSTRING('Database',1,4) → Data
Roman Urdu:
In MS-Access, data types define the kind of data that can be stored in a table field. Choosing
the correct data type is very important because it helps in saving memory, improving
performance, and maintaining data accuracy. MS-Access provides different data types to
store text, numbers, dates, and other kinds of information.
The Text data type is used to store alphabetic characters, numbers, and symbols that are not
used in calculations. It is mostly used for names, addresses, phone numbers, and email addresses.
A Text field can store up to 255 characters.
2. Number
The Number data type is used to store numeric values that are used in calculations, such as age,
marks, quantity, or total items. This data type allows mathematical operations like addition,
subtraction, multiplication, and division.
3. Date/Time
The Date/Time data type is used to store dates and time values such as date of birth, joining
date, or system time. MS-Access allows different date and time formats, making it easy to sort
and filter records based on dates.
4. Currency
The Currency data type is used to store monetary values like salary, price, or account balance. It
provides high accuracy and avoids rounding errors. This data type is mostly used in financial and
accounting applications.
5. Yes/No
The Yes/No data type stores Boolean values, meaning only two possible values: Yes/No or
True/False. It is commonly used for fields like paid/unpaid, active/inactive, or pass/fail.
Roman Urdu (Long Answer):
MS-Access mein data types ka matlab hota hai ke hum field mein kis type ka data store karna
chahte hain. Sahi data type select karna bohat zaroori hota hai kyun ke is se database fast,
accurate aur secure rehta hai.
Text data type alphabets, numbers aur symbols store karne ke liye use hota hai. Isay names,
addresses aur phone numbers ke liye use kiya jata hai. Text field maximum 255 characters store
kar sakti hai.
2. Number
Number data type numeric values ke liye hota hai jaise age, marks ya quantity. Is data type par
hum mathematical calculations bhi kar sakte hain.
3. Date/Time
Date/Time data type date aur time store karne ke liye use hota hai, jaise date of birth ya joining
date. Is se records ko date ke hisaab se sort aur filter karna asaan hota hai.
4. Currency
Currency data type paison se related values store karta hai jaise salary aur price. Is mein
rounding error nahi hota, is liye accounting systems mein bohat use hota hai.
5. Yes/No
Yes/No data type sirf do values store karta hai: Yes ya No (True ya False). Ye fields jaise
active/inactive ya pass/fail ke liye use hoti hai.
Database applications are widely used in almost every industry to store, manage, and retrieve
large amounts of data efficiently. These applications help organizations automate their work
and improve accuracy.
Aaj ke dor mein database applications har industry mein use hoti hain kyun ke yeh data ko
efficiently manage karti hain.
Industry mein use hone wali kuch database applications yeh hain:
1. Banking System – Customers ke accounts, transactions aur loans ka record rakhta hai.
2. Hospital Management System – Patients, doctors aur reports ka data store karta hai.
3. Airline Reservation System – Flight booking aur passenger record manage karta hai.
4. E-commerce System – Online shopping websites ka data handle karta hai.
5. Payroll System – Employees ki salary aur attendance calculate karta hai.
Q.3
(a) What is Network Database? What are its main features?
A Network Database is a database model in which data is organized using records and sets,
allowing a record to have multiple parent and child records. This model was developed to
overcome the limitations of the hierarchical database model. In a network database, data is
connected in the form of a graph structure, making it suitable for complex relationships.
Network databases are mainly used where many-to-many relationships are required, such as in
telecommunication systems and large organizations.
Network Database aik database model hota hai jismein data multiple relationships ke sath
connected hota hai. Is model mein aik record ke kai parents aur kai children ho sakte hain. Ye
model hierarchical database ki limitations ko door karne ke liye banaya gaya tha.
Network database ka structure graph jaisa hota hai, is liye ye complex systems ke liye suitable
hota hai.
SQL Server operators are symbols or keywords used to perform operations on data in SQL
queries. These operators are essential for filtering data and performing calculations.
1. Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division
2. Comparison Operators
Used to compare values:
= Equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal
3. Logical Operators
SQL Server ke basic operators queries mein data par operations perform karne ke liye use
hote hain.
1. Arithmetic Operators
Calculation ke liye:
+ jama
- minus
* guna
/ taqseem
2. Comparison Operators
= barabar
> bara
< chota
>= barabar ya bara
<= barabar ya chota
<> barabar nahi
3. Logical Operators
2022-23 Paper
The SELECT command with LIKE clause is used to retrieve data from a database table when
we want to search records based on patterns instead of exact values. The LIKE clause is
mostly used with text fields and works with wildcard characters such as % and _.
Syntax:
Example:
SELECT *
FROM emp
WHERE name LIKE 'A%';
This query displays all records where the name starts with letter “A”.
SELECT command LIKE clause ke sath tab use hota hai jab humein exact value ke bajaye
pattern ke basis par data chahiye hota hai. LIKE clause zyada tar text fields ke sath use hota
hai aur is mein wildcards use hote hain.
% ka matlab hota hai zero ya zyada characters
_ ka matlab hota hai sirf aik character
Syntax:
SELECT column_name
FROM table_name
WHERE column_name LIKE 'pattern';
Example mein wo tamam records show hon ge jin ka name “A” se start hota ho.
Data Redundancy refers to the unnecessary duplication of data in a database. This occurs when
the same data is stored in multiple places or tables. Data redundancy increases storage
requirements and can cause data inconsistency, meaning different values of the same data
appear in different locations. Redundancy often occurs in non-relational or poorly designed
databases. To reduce redundancy, techniques like normalization are used.
Data Redundancy ka matlab hota hai data ka bar bar repeat hona database ke andar. Jab aik hi
data multiple jagah par store ho jaye to redundancy paida hoti hai. Is se storage waste hoti hai
aur kabhi kabhi data inconsistent ho jata hai. Is problem ko door karne ke liye normalization use
ki jati hai.
SQL itself is not a database, but it is a standard language used with Relational Databases.
Databases that use SQL are called Relational Database Management Systems (RDBMS). SQL
works on tables consisting of rows and columns and is used to manage relational databases like
MySQL, Oracle, SQL Server, and PostgreSQL.
SQL koi database nahi balkay aik language hai jo Relational Databases ke sath use hoti hai. Jo
databases SQL use karti hain unhein RDBMS kaha jata hai. SQL tables ke zariye data ko
manage karti hai jisme rows aur columns hoti hain.
4. What do you understand about Data Normalization?
Data Normalization is the process of organizing data in a database to reduce redundancy and
improve data integrity. It involves dividing large tables into smaller related tables and
establishing relationships between them. Normalization helps eliminate insertion, update, and
deletion anomalies and improves database efficiency.
Data Normalization ka matlab hota hai database ko properly organize karna taake data repeat
na ho aur database efficient rahe. Is process mein bari tables ko choti related tables mein divide
kiya jata hai. Normalization se data errors aur inconsistency kam hoti hai.
In a relational database:
Relation ka matlab hota hai table jisme data store hota hai.
Attribute ka matlab hota hai column jo kisi cheez ki property batata hai, jaise name, age,
salary.
1. Hierarchical Database
2. Network Database
3. Relational Database
4. Object-Oriented Database
5. Distributed Database
DBMS (Database Management System) is software that allows users to create, store, retrieve,
update, and manage data efficiently. It provides security, data integrity, and multi-user access.
Examples include MySQL, Oracle, and MS-Access.
DBMS aik software system hota hai jo data ko store, manage aur retrieve karne mein madad
karta hai. DBMS data security, integrity aur multi-user access provide karta hai. Examples mein
MySQL aur MS-Access shamil hain.
Long Answers
Q.1
(a) Define Fields in MS-Access
In MS-Access, a Field is the smallest unit of data in a database table, representing a single
piece of information about an entity. Each field has a name and a data type, which determines
what kind of data can be stored, such as text, number, date, or currency.
Fields can also have properties like field size, default value, validation rules, and format. Proper
field design is essential to maintain data accuracy, consistency, and efficient database
management.
Example:
In an Employee table, the fields could be:
Here, each column (EmpID, FirstName, etc.) is a field that stores specific information about each
employee.
MS-Access mein Field aik table ka sab se chota unit hota hai jo kisi entity ka single
information store karta hai. Har field ka aik naam aur data type hota hai, jo decide karta hai ke
field mein kis type ka data store hoga (text, number, date, currency, etc.).
Fields ki properties bhi ho sakti hain jaise field size, default value, validation rules, aur format.
Fields ka sahi design database ko accurate, consistent aur fast banata hai.
Example:
Employee table ke fields:
EmpID (Number, Primary Key)
FirstName (Text)
LastName (Text)
DateOfBirth (Date/Time)
Salary (Currency)
Example:
EmpID in Employee table can be the primary key because each employee has a unique EmpID.
Example:
DeptID in Employee table can be a foreign key referring to DeptID in Department table.
Candidate Key:
A candidate key is any field or combination of fields that can uniquely identify a record. From
all candidate keys, one is chosen as the primary key.
Example:
In Employee table, both EmpID and EmailID could uniquely identify an employee, so both are
candidate keys. One of them (EmpID) is selected as PK.
Primary Key:
Primary key wo field hai jo table ke har record ko uniquely identify karti hai. Isme NULL ya
duplicate values nahi hoti.
Example:
Employee table ka EmpID primary key ho sakta hai kyun ke har employee ka unique EmpID hota
hai.
Foreign Key:
Foreign key aik table ki field hai jo dusre table ke primary key ko refer karti hai. Ye tables ke
darmiyan relation create karta hai.
Example:
Employee table ka DeptID foreign key ho sakta hai jo Department table ke DeptID ko refer kare.
Candidate Key:
Candidate key wo field hai jo record ko uniquely identify kar sakti hai. In me se aik ko primary
key banaya jata hai.
Example:
Employee table me EmpID aur EmailID dono uniquely identify kar sakte hain, dono candidate
keys hain. Primary key EmpID select ki jati hai.
Q.2
(a) Seven Major Components of MS-Access
Currency data type is used to store financial or monetary values. It provides high precision
and avoids rounding errors.
Example:
Employee salaries
Product prices
Account balances
Currency data type tab use hota hai jab paison ka data store karna ho. Ye rounding errors se
bachata hai aur accurate calculations provide karta hai.
Example:
Employees ki salary
Products ki price
Bank account balance
Q.3
(a) Client-Server Computing
Client-Server computing is a network architecture where the client requests services and the
server provides services.
Example: A web browser is the client, and a web server is the server.
Diagram (Conceptual):
Client-Server computing aik network model hai jahan client request bhejta hai aur server
usay process karke response bhejta hai.
Diagram:
A relationship in a database defines how data in one table is related to data in another table.
Relationships are established using primary and foreign keys.
Types of Relationships:
Tables ke darmiyan relation define karta hai ke ek table ka data dusre table ke data ke sath kaise
linked hai. Ye primary aur foreign keys ke zariye hota hai.
Types of Relationships:
1. One-to-One (1:1) – Table A ka aik record Table B ke aik record se match hota hai.
Example: Employee ↔ EmployeeDetails
2. One-to-Many (1:M) – Table A ka aik record Table B ke kai records se match hota hai.
Example: Department ↔ Employee
3. Many-to-Many (M:N) – Table A ke kai records Table B ke kai records se linked hain.
Junction table use hoti hai.
Example: Students ↔ Courses
Explanation:
CONCAT joins first and last names. WHERE filters employees under manager 986.
Explanation:
COUNT(*) counts total rows where project = 'P1'.
(c) Find maximum, minimum, and average salary
SELECT MAX(salary) AS MaxSalary,
MIN(salary) AS MinSalary,
AVG(salary) AS AvgSalary
FROM Emp;
Explanation:
MAX(), MIN(), and AVG() calculate maximum, minimum, and average values respectively.
Explanation:
UPPER() converts name to uppercase, LOWER() converts city to lowercase for formatting.
2024-25
1. What do you understand by Data
Redundancy?
English (Long Answer):
Data Redundancy occurs when the same piece of data is stored multiple times in a database
or in different databases. Redundant data increases storage requirements, creates data
inconsistency, and can lead to errors during updates, deletions, or insertions.
To reduce data redundancy, database normalization is used. Normalization organizes data into
smaller, related tables and eliminates unnecessary duplication.
Example:
If a company stores the address of a customer in both the Orders table and the Customer table,
the same address appears twice. If the customer changes their address, one table might be
updated while the other remains the old address, causing inconsistency.
Roman Urdu (Long Answer):
Data Redundancy tab hoti hai jab ek hi data multiple jagah store ho jaye. Is se storage zyada
lagti hai aur database inconsistent ho sakta hai.
Is problem ko solve karne ke liye normalization use hoti hai, jisme data ko choti aur related
tables mein divide kar diya jata hai.
Example:
Customer ka address Orders aur Customer table dono mein stored hai. Agar customer apna
address change kare aur sirf Orders table update ho, Customer table purana address dikhayega, jo
galat hai.
MySQL is one of the most popular Relational Database Management Systems (RDBMS). Its
strong features include:
Example:
Websites like Facebook, WordPress, and YouTube use MySQL for their databases
because of its speed, security, and scalability.
Types of Queries:
Example:
This query retrieves the names and salaries of employees earning more than 50,000.
MS-Access mein Query aik object hai jo tables se data retrieve, update ya manipulate karta
hai. Queries se hum filter, sort aur join kar sakte hain.
Types:
Example:
Ye query un employees ka name aur salary dikhati hai jinki salary 50000 se zyada hai.
4. What are the Data Types in MySQL?
English (Long Answer):
MySQL supports several data types grouped into three main categories:
These data types help in efficient storage and proper validation of data.
Example:
If you have a table Employee, the data dictionary may show:
A data dictionary helps DBAs and developers understand the structure of the database.
Data Dictionary aik central repository hai jo database ke bare mein information rakhta hai
(metadata).
Example:
Employee table ka data dictionary:
Table: Employee
Fields: EmpID (INT, PK), Name (VARCHAR), Salary (DECIMAL)
Data dictionary DBAs aur developers ke liye database structure samajhne mein madad karta hai.
Example:
Employee database with forms for entering employees, queries to calculate salaries, and
reports for monthly payroll.
Example:
Employee database: Form se employee enter karein, queries se salary calculate karein, aur report
generate karein.
Long Answers
Q.1
(a) What are the three (3) Database Models? Explain each
A Database Model defines the logical structure of a database and determines how data is
stored, organized, and accessed. The three main database models are:
Database Model database ka logical structure define karta hai aur data ka organization aur
access decide karta hai. Teen main models:
1. Hierarchical Database:
o Data tree structure mein hota hai (parent-child).
o Har child ka sirf aik parent hota hai.
o One-to-many relationships ke liye efficient.
Example: Department ke employees ka tree structure.
2. Network Database:
o Data graph structure mein hota hai, records aur sets se.
o Many-to-many relationships support karta hai.
o Flexible aur fast access.
Example: Students aur Courses ka relation.
3. Relational Database (RDBMS):
o Data tables (rows aur columns) mein hota hai.
o Primary key aur foreign key use hoti hain aur SQL se query hota hai.
o Most popular model.
Example: MySQL, MS-Access.
1. Primary Key:
o Field jo har record ko uniquely identify karti hai.
o NULL aur duplicate values allowed nahi.
Example: Employee table ka EmpID.
2. Foreign Key:
o Field jo dusre table ke PK ko refer karti hai.
o Tables ke darmiyan relation banata hai.
Example: Employee table ka DeptID Department table ke DeptID se linked.
3. Candidate Key:
o Wo field jo record ko uniquely identify kar sakti hai.
o Aik candidate key ko primary key banaya jata hai.
Example: EmpID aur EmailID dono candidate keys hain, EmpID primary key
banai gayi.
Q.2
(a) Define Comparison Operators with Description in MySQL
<> Not equal to SELECT * FROM emp WHERE city <> 'Karachi';
> Greater than SELECT * FROM emp WHERE salary > 50000;
< Less than SELECT * FROM emp WHERE age < 40;
>= Greater than or equal SELECT * FROM emp WHERE salary >= 30000;
<= Less than or equal SELECT * FROM emp WHERE age <= 50;
Roman Urdu (Long Answer):
<> Barabar nahi SELECT * FROM emp WHERE city <> 'Karachi';
>= Bara ya barabar SELECT * FROM emp WHERE salary >= 30000;
<= Chota ya barabar SELECT * FROM emp WHERE age <= 50;
Q.3
(a) Importance / Advantages of Database
Example: A company database ensures all employee records are accurate, secure, and up-to-
date.
Example: Company database mein employee records hamesha accurate aur secure rehte hain.
When a record is added via INSERT, MySQL automatically saves it in the table.
(b) Display all records from emp where ename starts with 'A'
SELECT * FROM emp
WHERE ename LIKE 'A%';
(d) Display ename and salary where age > 30 and city = 'Karachi'
SELECT ename, salary FROM emp
WHERE age > 30 AND city = 'Karachi';
2023-24 Paper
1. What is a Database and Database Schema?
English (Long Answer):
A Database Schema is the logical blueprint or structure of the database. It defines how the
data is organized, including tables, fields, data types, relationships, constraints, and keys. The
schema acts as a design template for the database.
Example:
In an Employee Management System, the database may contain tables like Employee,
Department, Salary. The schema defines the structure of these tables, such as the fields in
Employee table (EmpID, Name, Age, DeptID, Salary) and their data types.
Database aik structured data collection hai jo electronically store aur manage hoti hai. Ye
users ko data store, retrieve, update aur manage karne mein help karta hai. Database se data
organized, consistent, secure aur accessible rehta hai.
Database Schema database ka logical design ya blueprint hai. Ye define karta hai ke data kaise
organize hoga, jaise tables, fields, data types, relationships aur constraints. Schema database
ke design ka template hai.
Example:
Employee Management System mein tables: Employee, Department, Salary. Schema define
karta hai ke Employee table ke fields kya hain aur unke data types kya hain.
2. Components of DBMS Environment
English (Long Answer):
1. Hardware: Computers, storage devices, and network equipment that store and manage
the database.
2. Software: DBMS software (like MySQL, Oracle, MS-Access) that provides tools to
manage data.
3. Database: The actual collection of data organized in tables and relationships.
4. Users: People interacting with the database:
o Database Administrator (DBA): Manages and maintains the database.
o End Users: Access and manipulate data using queries or applications.
5. Procedures/Policies: Rules and guidelines for using the database efficiently and
securely.
Example:
In a bank, the hardware includes servers, the DBMS software could be MySQL, the database
stores customer accounts, the DBA manages it, and end users are bank staff using forms to
access customer information.
Example:
Bank ka example: Servers hardware, MySQL software, customer accounts database, DBA
manage karta hai, aur staff end users hain.
3. Advantages of DBMS
English (Long Answer):
Example:
A hospital database ensures patients’ data is secure, consistent, accessible to authorized users,
and can be restored after system failure.
Example:
Hospital database mein patient records secure, accurate aur accessible hote hain aur system
failure par restore kiye ja sakte hain.
A System Catalog (or Data Dictionary) is a repository that stores metadata about the
database. Metadata is data about data. The system catalog contains information like:
The system catalog helps DBAs and developers understand the database structure and maintain
it efficiently.
Example:
In an Employee database, the system catalog stores: Employee table fields (EmpID, Name,
Salary) and their data types.
System Catalog aik repository hai jo metadata (data about data) store karti hai.
DBA aur developers ke liye ye database structure samajhne aur maintain karne mein help karta
hai.
Example:
Employee database ke Employee table ka structure aur fields system catalog mein store hote
hain.
5. What is MySQL?
English (Long Answer):
Key Features:
Example:
Websites like Facebook, WordPress, and YouTube use MySQL for storing user data, posts, and
media.
Features:
Example:
Facebook, WordPress aur YouTube MySQL use karte hain data store karne ke liye.
Syntax:
Example:
This deletes all employee records where Age is greater than 60.
This deletes all records from Employees table (use with caution).
Roman Urdu (Long Answer):
SQL mein records delete karne ke liye DELETE statement use hoti hai.
Syntax:
Example:
Ye saray records delete kar dega. Caution ke sath use karna chahiye.
Long Answers
Q.1
(a) Explain Client–Server Architecture through diagram
Client–Server Architecture is a network model where the system is divided into two main
components:
1. Client:
o The client is a user interface that requests services or data from the server.
o It can be a computer, application, or web browser.
2. Server:
o The server provides resources, processes requests, and returns responses to
clients.
o Can handle multiple clients simultaneously.
Features:
Diagram:
Example:
Client–Server Architecture aik network model hai jahan system do main components mein
divided hota hai:
1. Client:
oUser interface jo server se request bhejta hai.
oComputer, browser ya application ho sakta hai.
2. Server:
o Server request process karta hai aur response bhejta hai.
o Multiple clients simultaneously serve kar sakta hai.
Features:
Diagram:
1. Both SQL and MySQL use Structured Query Language (SQL) for managing
databases.
2. Both allow data retrieval, insertion, deletion, and updates.
3. Both support data types like INT, VARCHAR, DATE.
4. Both can use queries with conditions, joins, and aggregates.
5. Both provide functions for string, numeric, and date operations.
Example:
Example:
Q.2
(a) List out all MySQL Data Types
Example: Employee table mein INT, VARCHAR, DECIMAL aur DATE use kiye gaye.
Advantages:
Disadvantages:
1. Limited support for very complex queries compared to Oracle or SQL Server
2. Limited stored procedures and triggers
3. Not fully compliant with some advanced SQL features
Example: Websites like WordPress use MySQL because of its speed and open-source nature,
but for extremely complex enterprise applications, Oracle may be preferred.
Advantages:
Disadvantages:
Example: WordPress MySQL use karta hai speed aur free hone ki wajah se.
Q.3
(a) Short Note on Backup and Recovery Importance
Backup and Recovery is the process of creating copies of database data to prevent loss and
restoring data in case of accidental deletion, corruption, or system failure.
Importance:
Example: Daily backup of bank transactions ensures that in case of server failure, all customer
transaction data can be restored.
Backup and Recovery data ka copy create karna aur restore karna hota hai accidental
deletion ya corruption ki surat mein.
Importance:
Example: Bank ke transactions daily backup hote hain taake server failure par restore ho sake.
(b) Define Basic Four Network Topology with Diagram
1. Bus Topology:
o All devices share a single communication line.
o Simple and cheap, but one failure can break the network.
Diagram:
2. PC1---PC2---PC3---PC4
3. Star Topology:
o All devices connected to a central hub/switch.
o Hub failure affects all, but easy to maintain.
Diagram:
4. PC1
5. |
6. PC2---Hub---PC3
7. |
8. PC4
9. Ring Topology:
o Devices connected in a circular manner.
o Data travels in one direction.
Diagram:
10. PC1 → PC2 → PC3 → PC4 → PC1
1. Bus Topology: Sab devices aik line share karte hain, sasta, lekin failure se network
down.
2. Star Topology: Sab devices central hub se connected, maintain easy, hub failure se sab
down.
3. Ring Topology: Devices circular connected, data ek direction travel karta.
4. Mesh Topology: Har device sab ke sath connected, reliable lekin mehnga.
Q.4 — SQL Queries (Long Answer)
(a) Maximum, Minimum, and Average Salary
SELECT MAX(salary) AS MaxSalary,
MIN(salary) AS MinSalary,
AVG(salary) AS AvgSalary
FROM Emp;
Explanation:
Explanation:
Explanation:
Explanation:
The SELECT command retrieves data from database tables, while the WHERE clause applies conditions to filter the results, allowing for the retrieval of only necessary records. This combination enhances data retrieval by enabling precise queries with operators like =, >, <, and logical operators like AND, OR .
MS-Access provides various data types like Text, Number, Date/Time, each optimized for the specific type of data stored. This choice helps optimize performance, save memory, and maintain data accuracy by ensuring fields are used appropriately, such as storing numerical values or text .
A Database Schema provides the logical structure or blueprint of a database, defining how data is organized through tables, fields, data types, relationships, and constraints. It acts as a design template, crucial for ensuring consistency, organization, and easy accessibility of data .
SQL serves as a universal language for database management, enabling operations such as creation, data manipulation, retrieval, and deletion across various systems like MySQL, Oracle, and MS-Access. Its standardization allows compatibility and ease of use across different database environments .
Hierarchical database models organize data in a tree structure with strict parent-child relationships, only supporting one-to-many relationships, while network database models allow many-to-many relationships through a flexible graph structure, improving access speed and flexibility .
MySQL is a highly scalable RDBMS suitable for large-scale web applications due to its open-source, fast, and secure nature, widely used by platforms like Facebook and YouTube, whereas MS-Access is used for small-scale databases and desktop applications, primarily for beginners or small offices with its easy-to-use GUI .
Primary keys uniquely identify each record in a table, ensuring data integrity by preventing duplicates and null values. Foreign keys in one table refer to the primary key of another table, creating relationships between the tables and maintaining referential integrity .
RDBMS is an advanced form of DBMS that stores data in multiple, related tables, using primary and foreign keys to maintain relationships and ensure data integrity, whereas DBMS usually lacks strict integrity rules, leading to data redundancy .
Regular backup and recovery procedures are critical to prevent data loss due to accidental deletion, hardware failures, or disasters. They ensure business continuity by allowing restoration of data, thus averting significant financial and operational damage .
Queries in MS-Access allow users to perform operations like searching, filtering, updating, or deleting data efficiently, saving time in managing large databases. They extract meaningful information by applying conditions, which is essential for creating reports and forms .