PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Relational Algebra: Selection (σ) and Projection (π) Operators (सेलेक्शन ऑपरेटर (σ) और प्रोजेक्शन ऑपरेटर (π) की कार्यप्रणाली) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Relational Algebra Selection (σ) filters horizontal rows satisfying a predicate condition, while Projection (π) selects vertical columns and automatically eliminates duplicate tuples in set-based relations.
अध्याय सार: रिलेशनल अलजेब्रा में Selection (σ) ऑपरेटर दी गई शर्त के आधार पर क्षैतिज पंक्तियों (Rows/Tuples) को फ़िल्टर करता है, जबकि Projection (π) केवल चुनिंदा स्तंभों (Columns) को दिखाता है और डुप्लीकेट रोज़ हटा देता है।
Relational Algebra: Selection (σ) and Projection (π) Operators: Detailed Notes & Architecture (सेलेक्शन ऑपरेटर (σ) और प्रोजेक्शन ऑपरेटर (π) की कार्यप्रणाली)
1. Selection Operator (σ - Sigma): Horizontal Row Filtering (सेलेक्शन ऑपरेटर (σ): पंक्तियाँ चुनना)
[EN] Selection is a unary relational algebra operator written as σ_condition(Relation), using the Greek lowercase sigma (σ). It inspects every tuple in the relation and outputs only rows where the boolean predicate (using =, !=, <, >, AND ∧, OR ∨, NOT ¬) evaluates true. Selection preserves all columns (degree remains unchanged) and reduces or keeps row count (0 <= result cardinality <= input cardinality).
[HI] Selection (σ) एक यूनरी ऑपरेटर है जो σ_शर्त(टेबल) के रूप में लिखा जाता है। यह टेबल के सभी कॉलम्स को बनाए रखते हुए केवल शर्त पर खरी उतरने वाली पंक्तियों (Tuples) को चुनता है; अर्थात कॉलम्स की संख्या (Degree) समान रहती है।
2. Projection Operator (π - Pi): Vertical Column Filtering (प्रोजेक्शन ऑपरेटर (π): स्तंभ चुनना)
[EN] Projection is a unary operator denoted by Greek pi (π_A1,A2,...(Relation)). It vertically slices only the listed attribute columns, potentially lowering the degree of the relation. Crucially, because strict relational algebra operates on mathematical Sets rather than Multisets, π automatically discards duplicate rows—whereas SQL SELECT retains duplicates unless DISTINCT is specified.
[HI] Projection (π) दिए गए कॉलम्स (Attributes) को ही परिणाम में दिखाता है, जिससे डिग्री कम हो सकती है। चूँकि रिलेशनल अलजेब्रा गणितीय सेट (Set) पर कार्य करता है, इसलिए π स्वतः डुप्लीकेट रोज़ को हटा देता है (SQL के SELECT DISTINCT की तरह)।
3. Commutativity & Cascading Properties in Query Optimization (क्वेरी ऑप्टिमाइजेशन में क्रमविनिमेय व कैस्केडिंग नियम)
[EN] Query optimizers exploit algebraic equivalences on σ and π: cascading selections split conjuncts σ_{c1∧c2}(R) ≡ σ_{c1}(σ_{c2}(R)) and selections commute freely σ_{c1}(σ_{c2}(R)) ≡ σ_{c2}(σ_{c1}(R)). However, projections do NOT generally commute with selections unless all attributes tested inside selection σ exist inside projection π's list; cascading projections collapse to the outermost list: π_A(π_{A,B}(R)) ≡ π_A(R).
[HI] सेलेक्शन आपस में क्रमविनिमेय (Commutative) होते हैं: σ_c1(σ_c2(R)) = σ_c2(σ_c1(R))। इसी तरह नेस्टेड प्रोजेक्शन में सबसे बाहरी कॉलम सूची ही प्रभावी रहती है।
4. SQL Equivalents & Combining π and σ (SQL समतुल्य सिंटैक्स व संयोजन)
[EN] In relational queries, filters run before projections internally so only required rows pass upward. Equivalent SQL maps σ_cond(R) to SELECT * FROM R WHERE cond, and π_cols(σ_cond(R)) to SELECT DISTINCT cols FROM R WHERE cond.
[HI] रिलेशनल क्वेरी में सामान्यतः σ पहले चलाकर डेटा घटाया जाता है और फिर π से वांछित कॉलम निकाले जाते हैं; SQL में π_cols(σ_cond(R)) का सटीक रूप SELECT DISTINCT cols FROM R WHERE cond होता है।
Syntax, Formula & Technical Example (Relational Algebra: Selection (σ) and Projection (π) Operators)
-- Relational Algebra:
π_Name,City ( σ_Marks >= 75 ∧ Dept='CS' (Student) )
-- Exact SQL Equivalent:
SELECT DISTINCT Name, City FROM Student
WHERE Marks >= 75 AND Dept = 'CS';
Relational Algebra: Selection (σ) and Projection (π) Operators Quick Reference & Comparison Table
| Operator / Rule | Output Effect | SQL Mapping / Key Detail |
|---|---|---|
| Selection (σ) | Filters rows horizontally; keeps all columns | Maps directly to SQL WHERE clause |
| Projection (π) | Filters columns vertically; removes duplicates | Maps to SQL SELECT DISTINCT (columns) |
| Selection Commutativity | σ_c1(σ_c2(R)) == σ_c2(σ_c1(R)) | Used by query optimizers to push filters down |
| Degree under σ vs π | σ preserves degree; π reduces/equals degree | π_A1..Ak(R) produces degree k |
Relational Algebra: Selection (σ) and Projection (π) Operators Top 20 Bilingual MCQs with Answers
Q1. Which Greek symbol denotes the Selection operator in Relational Algebra?
(रिलेशनल अलजेब्रा में Selection ऑपरेटर को किस ग्रीक चिह्न से दर्शाया जाता है?)
(A) ⋈ (Bowtie)
(B) ρ (Rho)
(C) σ (Sigma)
(D) π (Pi)
Correct Answer: (C)
[EN] Lowercase sigma (σ) represents Selection (horizontal row filtering), while pi (π) represents Projection.
[HI] सिग्मा (σ) सेलेक्शन (पंक्तियाँ छांटना) को और पाई (π) प्रोजेक्शन (कॉलम चुनना) को दर्शाता है।
Q2. How does Relational Algebra Projection π_City(Student) handle duplicate city values?
(रिलेशनल अलजेब्रा में π_City(Student) चलाने पर एक जैसे शहर के नामों (Duplicates) का क्या होता है?)
(A) Throws DuplicateTupleError
(B) All duplicates remain like default SQL SELECT
(C) Nullifies duplicate rows
(D) Duplicates are automatically removed because relations are sets
Correct Answer: (D)
[EN] Pure relational algebra treats every relation strictly as a set, so π implicitly deduplicates rows.
[HI] रिलेशनल अलजेब्रा सेट थ्योरी पर चलता है इसलिए π स्वतः डुप्लीकेट पंक्तियों को हटा देता है।
Q3. Which SQL query accurately matches π_Name(σ_Age>20(Emp))?
(π_Name(σ_Age>20(Emp)) के बिल्कुल समतुल्य सही SQL क्वेरी कौन सी है?)
(A) SELECT DISTINCT Name FROM Emp WHERE Age > 20;
(B) SELECT * FROM Emp HAVING Age > 20;
(C) SELECT UNIQUE * FROM Emp WHERE Age > 20;
(D) SELECT Name FROM Emp WHERE Age > 20;
Correct Answer: (A)
[EN] DISTINCT is required in SQL because SQL uses multisets (bags) by default while π removes duplicates.
[HI] SQL डिफ़ॉल्ट रूप से डुप्लीकेट रखता है, जबकि π डुप्लीकेट हटाता है; इसलिए SELECT DISTINCT लिखना आवश्यक है।
Q4. If table Student has degree 6 and cardinality 100, what is the degree of σ_Dept='IT'(Student)?
(यदि Student टेबल की डिग्री 6 और कार्डिनैलिटी 100 है, तो σ_Dept='IT'(Student) की डिग्री कितनी होगी?)
(A) 1
(B) Changes dynamically based on rows
(C) Always 0
(D) 6 (Selection never drops columns)
Correct Answer: (D)
[EN] Selection filters rows only, keeping every attribute column intact—so degree stays 6.
[HI] Selection केवल पंक्तियों को छांटता है और कोई कॉलम नहीं हटाता, इसलिए डिग्री 6 ही रहेगी।
Q5. Which algebraic equivalence holds true for Selection cascading?
(Selection कैस्केडिंग के लिए कौन सा बीजगणितीय समीकरण हमेशा सत्य होता है?)
(A) σ_{c1 ∧ c2}(R) ≡ σ_{c1}(σ_{c2}(R))
(B) σ_{c1 ∨ c2}(R) ≡ σ_{c1}(σ_{c2}(R))
(C) π_A(σ_B=5(R)) ≡ σ_B=5(π_A(R)) always
(D) σ_{c1}(σ_{c2}(R)) ≠ σ_{c2}(σ_{c1}(R))
Correct Answer: (A)
[EN] AND (conjunctive) predicates decompose into nested selections that also commute safely.
[HI] AND शर्त वाले दो सेलेक्शन को अंदर-बाहर किसी भी क्रम में तोड़ा जा सकता है।
Q6. When is π_Name(σ_Salary>50000(Emp)) INVALID if rewritten blindly as σ_Salary>50000(π_Name(Emp))?
(π_Name(σ_Salary>50000(Emp)) को सीधे σ_Salary>50000(π_Name(Emp)) लिखना गलत क्यों होगा?)
(A) Because Salary cannot be compared in relational algebra
(B) Because π changes column names
(C) Because π_Name strips out the Salary column before σ_Salary>50000 can inspect it
(D) Because σ cannot run after π under any rule
Correct Answer: (C)
[EN] Reordering π inside σ requires that every attribute needed by the σ predicate remains in the inner projection.
[HI] π_Name पहले चलाने से Salary कॉलम हट जाता है, जिससे बाद वाला σ Salary की जांच नहीं कर पाएगा।
Q7. Both Selection (σ) and Projection (π) belong to which category of operators?
(Selection (σ) और Projection (π) दोनों किस श्रेणी के ऑपरेटर्स हैं?)
(A) Fundamental Unary Relational Algebra Operators
(B) SQL DDL Triggers
(C) Derived Binary Operators
(D) Concurrency Locking Primitives
Correct Answer: (A)
[EN] Codd's basic relational algebra has 5 fundamental operators: σ, π, ×, ∪, and -; σ and π operate on a single (unary) relation.
[HI] σ और π एक ही टेबल पर काम करने वाले मूलभूत (Fundamental) यूनरी ऑपरेटर्स हैं।
Q8. What does nested projection π_ID(π_ID,Name,City(Student)) simplify to?
(नेस्टेड प्रोजेक्शन π_ID(π_ID,Name,City(Student)) किसके समतुल्य सरल रूप में लिखा जा सकता है?)
(A) Empty set
(B) π_City(Student)
(C) π_ID,Name,City(Student)
(D) π_ID(Student)
Correct Answer: (D)
[EN] Cascading projections ignore intermediate extra columns and depend solely on the outermost attribute list (assuming ID was kept).
[HI] नेस्टेड प्रोजेक्शन में अंतिम परिणाम केवल सबसे बाहरी कॉलम सूची (π_ID(Student)) द्वारा तय होता है।
Q9. In σ_condition(R), what is the maximum number of tuples possible in the output if R has n rows?
(यदि टेबल R में n पंक्तियाँ हैं, तो σ_condition(R) के परिणाम में अधिकतम कितनी पंक्तियाँ आ सकती हैं?)
(A) n (when every row satisfies the condition)
(B) n * n
(C) n - 1
(D) n + 1
Correct Answer: (A)
[EN] Result cardinality of σ ranges from 0 (no matches) up to n (all rows match).
[HI] Selection में कम से कम 0 और अधिकतम n (जब सभी शर्त पूरी करें) पंक्तियाँ आ सकती हैं।
Q10. Which symbol represents logical AND inside a Relational Algebra selection predicate?
(रिलेशनल अलजेब्रा की सेलेक्शन शर्त में लॉजिकल AND को किस चिह्न से दर्शाते हैं?)
(A) ∧
(B) ∩
(C) ¬
(D) ∨
Correct Answer: (A)
[EN] Conjunction is ∧ (AND), disjunction is ∨ (OR), and negation is ¬ (NOT) inside σ predicates.
[HI] σ की शर्त के अंदर AND के लिए ∧ और OR के लिए ∨ चिह्न उपयोग होता है।
Q11. If R(A,B,C) has 50 tuples where column A has 10 unique values, what is the cardinality of π_A(R)?
(यदि R(A,B,C) में 50 पंक्तियाँ हैं जिनमें कॉलम A में 10 अलग-अलग मान हैं, तो π_A(R) में कितनी पंक्तियाँ होंगी?)
(A) 1
(B) 150
(C) 50
(D) 10
Correct Answer: (D)
[EN] Because Projection eliminates duplicate values, π_A(R) yields exactly 10 unique tuples.
[HI] प्रोजेक्शन डुप्लीकेट हटा देता है, इसलिए 50 में से केवल 10 अद्वितीय पंक्तियाँ मिलेंगी।
Q12. Which SQL keyword corresponds to the Rename operator ρ (Rho) in Relational Algebra?
(रिलेशनल अलजेब्रा के Rename ऑपरेटर ρ (Rho) के समतुल्य SQL कीवर्ड कौन सा है?)
(A) DISTINCT
(B) AS (aliasing table or column names)
(C) GROUP BY
(D) WHERE
Correct Answer: (B)
[EN] ρ_NewName(A1,A2)(R) renames relations and attributes, paralleling SQL's AS alias clause.
[HI] ρ ऑपरेटर टेबल या कॉलम का नाम बदलने हेतु है, जो SQL के AS कीवर्ड जैसा है।
Q13. Does Selection (σ) perform any column renaming or arithmetic computation on attributes?
(क्या Selection (σ) कॉलम का नाम बदलता है या कॉलम के मानों पर गणितीय गणना कर आउटपुट में नया कॉलम जोड़ता है?)
(A) Yes, σ drops primary key columns automatically
(B) Only when combined with Outer Join
(C) No — σ strictly evaluates conditions to filter existing rows unchanged
(D) Yes, via generalized arithmetic σ
Correct Answer: (C)
[EN] Standard Selection purely subsets rows without modifying attribute schemas or creating computed columns (extended projection handles expressions).
[HI] सामान्य Selection केवल मौजूदा पंक्तियों को बिना बदले छांटता है।
Q14. Which operator pair can reduce BOTH rows AND columns from a single table?
(एक ही टेबल से पंक्तियाँ और स्तंभ दोनों कम करने के लिए किन ऑपरेटर्स का संयोजन चाहिए?)
(A) ∪ (Union) and ∩ (Intersection)
(B) π (Projection) and σ (Selection)
(C) ρ (Rename) and ÷ (Division)
(D) × (Cartesian) only
Correct Answer: (B)
[EN] σ trims rows horizontally while π trims columns vertically.
[HI] σ से पंक्तियाँ कम होती हैं और π से स्तंभ कम होते हैं।
Q15. Why might σ_Marks=NULL(Student) require special care in SQL vs pure Relational Algebra?
(शून्य मान (NULL) की तुलना करते समय SQL में '=' क्यों काम नहीं करता?)
(A) SQL treats NULL as 0 automatically
(B) Relational algebra stores NULL as 'null' string
(C) SQL uses three-valued logic where NULL = NULL yields UNKNOWN; you must write WHERE Marks IS NULL
(D) Selection drops all NULL tables
Correct Answer: (C)
[EN] In SQL three-valued logic, comparing anything with = NULL returns UNKNOWN (falsey); use IS NULL instead.
[HI] SQL में '=' से NULL की तुलना करने पर UNKNOWN आता है, इसलिए IS NULL लिखना जरूरी है।
Q16. Which Relational Algebra operator is NOT fundamental (i.e., can be derived from the 5 basic operators)?
(इनमें से कौन सा ऑपरेटर मूलभूत (Fundamental) नहीं है बल्कि व्युत्पन्न (Derived) है?)
(A) Intersection (∩) and Natural Join (⨝)
(B) Projection (π)
(C) Selection (σ)
(D) Set Difference (-)
Correct Answer: (A)
[EN] Fundamental 5: σ, π, ∪, -, ×. Derived include ∩ (R - (R - S)), ⨝, and ÷.
[HI] 5 मूलभूत ऑपरेटर्स σ, π, ∪, -, × हैं; इंटरसेक्शन (∩) और जॉइन (⨝) व्युत्पन्न हैं।
Q17. Within Relational Algebra: Selection (σ) and Projection (π) Operators, which operator / rule directly maps to: "Filters rows horizontally; keeps all columns"?
(Relational Algebra: Selection (σ) and Projection (π) Operators में कौन सा Operator / Rule सीधे "Filters rows horizontally; keeps all columns" से संबंधित है?)
(A) Selection (σ)
(B) Selection Commutativity
(C) Projection (π)
(D) Degree under σ vs π
Correct Answer: (A)
[EN] In Relational Algebra: Selection (σ) and Projection (π) Operators, 'Selection (σ)' handles 'Filters rows horizontally; keeps all columns' (Maps directly to SQL WHERE clause).
[HI] Relational Algebra: Selection (σ) and Projection (π) Operators में 'Selection (σ)' का कार्य/विवरण 'Filters rows horizontally; keeps all columns' (Maps directly to SQL WHERE clause) है।
Q18. Which option accurately describes 'Projection (π)' in Relational Algebra: Selection (σ) and Projection (π) Operators?
(Relational Algebra: Selection (σ) and Projection (π) Operators के संदर्भ में 'Projection (π)' की सही विशेषता कौन सी है?)
(A) Filters columns vertically; removes duplicates
(B) Filters rows horizontally; keeps all columns
(C) σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))
(D) σ preserves degree; π reduces/equals degree
Correct Answer: (A)
[EN] 'Projection (π)' provides 'Filters columns vertically; removes duplicates' — key point: Maps to SQL SELECT DISTINCT (columns).
[HI] 'Projection (π)' का मुख्य विवरण 'Filters columns vertically; removes duplicates' है (Maps to SQL SELECT DISTINCT (columns))।
Q19. In Relational Algebra: Selection (σ) and Projection (π) Operators, identify the correct parameter for the specification: "σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))".
(Relational Algebra: Selection (σ) and Projection (π) Operators में "σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))" विवरण किस विकल्प के लिए सही है?)
(A) Projection (π)
(B) Selection Commutativity
(C) Selection (σ)
(D) Degree under σ vs π
Correct Answer: (B)
[EN] 'Selection Commutativity' corresponds to 'σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))' (Used by query optimizers to push filters down).
[HI] 'Selection Commutativity' का संबंध 'σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))' (Used by query optimizers to push filters down) से है।
Q20. Considering Relational Algebra: Selection (σ) and Projection (π) Operators, what key behavior defines 'Degree under σ vs π'?
(Relational Algebra: Selection (σ) and Projection (π) Operators में 'Degree under σ vs π' की मुख्य भूमिका या मान क्या है?)
(A) σ preserves degree; π reduces/equals degree
(B) Filters rows horizontally; keeps all columns
(C) Filters columns vertically; removes duplicates
(D) σ_c1(σ_c2(R)) == σ_c2(σ_c1(R))
Correct Answer: (A)
[EN] 'Degree under σ vs π' represents 'σ preserves degree; π reduces/equals degree' (π_A1..Ak(R) produces degree k).
[HI] 'Degree under σ vs π' का अर्थ/मान 'σ preserves degree; π reduces/equals degree' है (π_A1..Ak(R) produces degree k)।
Relational Algebra: Selection (σ) and Projection (π) Operators — Exam FAQs
Q1: Why is SELECT Name FROM Emp not strictly identical to π_Name(Emp)?
SELECT Name FROM Emp और π_Name(Emp) में एक छोटा सा अंतर क्या है?
[EN] Relational algebra's π automatically drops duplicate names, whereas SQL's SELECT keeps duplicates unless you write SELECT DISTINCT Name FROM Emp.
[HI] π स्वतः डुप्लीकेट हटाता है जबकि SQL का साधारण SELECT डुप्लीकेट भी दिखाता है—इसके लिए SELECT DISTINCT लिखना होता है।
Q2: In π_A(σ_B=5(R)), which runs first mathematically: σ or π?
π_A(σ_B=5(R)) में अंदर से बाहर पहले क्या निष्पादित होता है?
[EN] Inner expressions run first: σ_B=5(R) filters matching rows, and then outer π_A extracts column A and removes duplicates.
[HI] गणित की तरह अंदर वाला ब्रैकेट σ_B=5(R) पहले पंक्तियाँ छांटता है, फिर बाहर वाला π_A कॉलम A निकालता है।
Q3: Does Selection (σ) change the order of rows permanently in the database?
क्या σ ऑपरेटर चलाने से डेटाबेस टेबल स्थायी रूप से बदल जाती है?
[EN] No. Relational algebra operators are pure read-only queries producing a new temporary output relation without modifying stored tables.
[HI] नहीं। रिलेशनल अलजेब्रा ऑपरेशन्स केवल नई अस्थायी आउटपुट टेबल देते हैं, मूल टेबल में कोई बदलाव नहीं होता।
Post a Comment
Post a Comment