0% found this document useful (0 votes)
3 views4 pages

SQL & Relational Algebra Q&A Guide

Uploaded by

Shanthi.V
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)
3 views4 pages

SQL & Relational Algebra Q&A Guide

Uploaded by

Shanthi.V
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

COMPLETE SQL & RELATIONAL ALGEBRA QA PDF

---------------------------------------------------

1. DDL OPERATIONS IN SQL

CREATE TABLE Student (

StudentID INT PRIMARY KEY,

Name VARCHAR(50),

Age INT,

Major VARCHAR(30)

);

ALTER TABLE Student ADD Email VARCHAR(100);

ALTER TABLE Student MODIFY Age SMALLINT;

ALTER TABLE Student DROP COLUMN Email;

DROP TABLE Student;

TRUNCATE TABLE Student;

RENAME TABLE Student TO Learner;

---------------------------------------------------

2. ELDEST EMPLOYEE ON PROJECT 'IOT'


SELECT [Link], [Link], [Link]

FROM emp e, works_on w, projects p

WHERE [Link] = 'iot'

AND [Link] = [Link]

AND [Link] = [Link]

AND [Link] = (SELECT MIN(dob) FROM emp);

---------------------------------------------------

3. EMPLOYEES IN 'KR CIRCLE'

SELECT eid, dob, super_eid

FROM emp

WHERE address = 'KR Circle';

---------------------------------------------------

4. EMPLOYEES BORN IN 1982

SELECT eid, ename

FROM emp

WHERE YEAR(dob) = 1982;

OR

WHERE dob BETWEEN '1982-01-01' AND '1982-12-31';


---------------------------------------------------

5. SUPERVISOR DETAILS OF ALL DEPARTMENTS

SELECT DISTINCT [Link], [Link], [Link], [Link], [Link]

FROM emp e

JOIN emp s ON e.super_eid = [Link]

JOIN works_on w ON [Link] = [Link]

JOIN projects p ON [Link] = [Link]

JOIN dept d ON [Link] = [Link];

Explanation:

e = employee, s = supervisor (e.super_eid = [Link])

---------------------------------------------------

6. JOIN vs WHERE

Using JOIN (Modern):

SELECT [Link], [Link]

FROM emp e

JOIN dept d ON [Link] = [Link];

Using WHERE (Older):


SELECT [Link], [Link]

FROM emp e, dept d

WHERE [Link] = [Link];

Recommendation:

Use JOIN for combining tables.

Use WHERE for filtering (e.g., WHERE age > 30).

---------------------------------------------------

NOTE: Remaining answers like relational algebra examples, update operations, integrity constraints,

project-join-select examples, etc. were discussed earlier and will be included in a final compiled

revision version.

You might also like