SlideShare a Scribd company logo
DBMS
SEMINAR
SHINANA UZHUNNAN
27 MAY, 2024
201
Q 8
Consider the employee database given below. Give an expression in SQL for each of the following queries:
EMPLOYEE (Employee-Name, City) WORKS (Employee-Name, Company-Name, Salary) COMPANY (Company-Name,
City) MANAGES (Employee-Name, Manager-Name)
EMPLOYEE (Employee-Name, City)
create table employee(empname varchar(20) primary key,city varchar(20));
COMPANY (Company-Name, City)
create table company(company_name varchar(20) primary key,city varchar(20));
WORKS (Employee-Name, Company-Name, Salary)
create table works(empname varchar(20) primary key references employee(empname),cname varchar(20) references
company(company_name),salary int);
MANAGES (Employee-Name, Manager-Name)
create table manages(empname varchar(20) references employee(empname),manager_name varchar(20) references
employee(empname),primary key(empname,manager_name));
Table Creation
insert into employee values('Swathi','Kozhikode'),('Vishnu','Trivandrum'),('Shreya','USA'), ('Adam','Dubai'),('Sajid','Malappuram');
select * from employee;
insert into company values('Infosys','Trivandrum'),('Chandrika','Trissur'),('Wipro','Kochi'), ('Tata','Mumbai'),('Bajaj','Delhi');
select * from company;
insert into works values('Swathi','Infosys',10000),('Vishnu','Infosys',15000), ('Shreya','Wipro',71500,('Adam','Infosys',8000),
('Sajid','Wipro',18000);
select * from works;
insert into manages values('Swathi','Adam'),('Vishnu','Adam'),('Sajid','Shreya');
select * from manages;
insertion to tables
dbms  calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdf
A) Find the names of all employees who work in Infosys
B) Find the names and cities of residence of all employees who works in Wipro
C) Find the names, and cities of all employees who work in Infosys and earn
more than Rs. 10,000.
D) Find the employees who live in the same cities as the companies for which
they work.
E) Find all employees who do not work in Wipro Corporation.
F) Find the company that has the most employees.
A)
B)
C)
D)
E)
F)
Q 14
Create a function to check whether a given number is prime or not
create or replace function prime(n int)
returns varchar(25) as $$
declare i int;
begin if n<2 then return n ||'is not a prime no';
end if;
for i in 2..n/2 loop if mod(n,i)=0 then return n ||'is not a prime
no';
end if;
end loop;
return n||'is a prime no';
end;
$$ language plpgsql;
select prime(5);
dbms  calicut university B. sc Cs 4th sem.pdf
Thank You
SHINANA UZHUNNAN

More Related Content

Similar to dbms calicut university B. sc Cs 4th sem.pdf

Les09
Les09Les09
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdfOn SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
infomalad
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
 
Database management system file
Database management system fileDatabase management system file
Database management system file
Ankit Dixit
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
SabrinaShanta2
 
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database Programming
Ahmed Swilam
 

Similar to dbms calicut university B. sc Cs 4th sem.pdf (6)

Les09
Les09Les09
Les09
 
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdfOn SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Database management system file
Database management system fileDatabase management system file
Database management system file
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
 
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database Programming
 

Recently uploaded

Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
Emerging Tech
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
Inglês no Mundo Digital
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
Ivanti
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
aslasdfmkhan4750
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
CEPTES Software Inc
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
paysquare consultancy
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 

Recently uploaded (20)

Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 

dbms calicut university B. sc Cs 4th sem.pdf

  • 2. Q 8 Consider the employee database given below. Give an expression in SQL for each of the following queries: EMPLOYEE (Employee-Name, City) WORKS (Employee-Name, Company-Name, Salary) COMPANY (Company-Name, City) MANAGES (Employee-Name, Manager-Name) EMPLOYEE (Employee-Name, City) create table employee(empname varchar(20) primary key,city varchar(20)); COMPANY (Company-Name, City) create table company(company_name varchar(20) primary key,city varchar(20)); WORKS (Employee-Name, Company-Name, Salary) create table works(empname varchar(20) primary key references employee(empname),cname varchar(20) references company(company_name),salary int); MANAGES (Employee-Name, Manager-Name) create table manages(empname varchar(20) references employee(empname),manager_name varchar(20) references employee(empname),primary key(empname,manager_name)); Table Creation
  • 3. insert into employee values('Swathi','Kozhikode'),('Vishnu','Trivandrum'),('Shreya','USA'), ('Adam','Dubai'),('Sajid','Malappuram'); select * from employee; insert into company values('Infosys','Trivandrum'),('Chandrika','Trissur'),('Wipro','Kochi'), ('Tata','Mumbai'),('Bajaj','Delhi'); select * from company; insert into works values('Swathi','Infosys',10000),('Vishnu','Infosys',15000), ('Shreya','Wipro',71500,('Adam','Infosys',8000), ('Sajid','Wipro',18000); select * from works; insert into manages values('Swathi','Adam'),('Vishnu','Adam'),('Sajid','Shreya'); select * from manages; insertion to tables
  • 6. A) Find the names of all employees who work in Infosys B) Find the names and cities of residence of all employees who works in Wipro C) Find the names, and cities of all employees who work in Infosys and earn more than Rs. 10,000. D) Find the employees who live in the same cities as the companies for which they work. E) Find all employees who do not work in Wipro Corporation. F) Find the company that has the most employees.
  • 9. Q 14 Create a function to check whether a given number is prime or not create or replace function prime(n int) returns varchar(25) as $$ declare i int; begin if n<2 then return n ||'is not a prime no'; end if; for i in 2..n/2 loop if mod(n,i)=0 then return n ||'is not a prime no'; end if; end loop; return n||'is a prime no'; end; $$ language plpgsql; select prime(5);