SlideShare a Scribd company logo
1 of 5
Download to read offline
Mrs. Sunita M Dol
Page 1
Views
We define a view in SQL by using the create view command. To define a view, we must
give the view a name and must state the query that computes the view. The form of the
create view command is
create view v as <query expression>
where <query expression> is any legal query expression. The view name is represented by v.
Create the view faculty which consist of an instructor’s ID, name and department name
select * from instructor;
ID name dept_namesalary
10101SrinivasanComp. Sci. 65000
12121Wu Finance 90000
15151Mozart Music 40000
22222Einstein Physics 95000
32343El Said History 60000
33456Gold Physics 87000
45565Katz Comp. Sci. 75000
58583Califieri History 62000
76543Singh Finance 80000
76766Crick Biology 72000
83821Brandt Comp. Sci. 92000
98345Kim Elec. Eng. 80000
create view faculty as select ID, name, dept_name from instructor;
ID name dept_name
10101SrinivasanComp. Sci.
12121Wu Finance
15151Mozart Music
Mrs. Sunita M Dol
Page 2
ID name dept_name
22222Einstein Physics
32343El Said History
33456Gold Physics
45565Katz Comp. Sci.
58583Califieri History
76543Singh Finance
76766Crick Biology
83821Brandt Comp. Sci.
98345Kim Elec. Eng.
Create a view that lists all course sections offered by the Biology department in the
summer 2017 semester with the building and room number of each section
select * from course;
course_id title dept_name credits
BIO-101 Intro. to Biology Biology 4
BIO-301 Genetics Biology 4
BIO-399 Computational Biology Biology 3
CS-101 Intro. to Computer Science Comp. Sci. 4
CS-190 Game Design Comp. Sci. 4
CS-315 Robotics Comp. Sci. 3
CS-319 Image Processing Comp. Sci. 3
CS-347 Database System Concepts Comp. Sci. 3
EE-181 Intro. to Digital Systems Elec. Eng. 3
FIN-201 Investment Banking Finance 3
HIS-351 World History History 3
MU-199 Music Video Production Music 3
PHY-101 Physical Principles Physics 4
select * from section;
Mrs. Sunita M Dol
Page 3
course_id sec_id semester year building room_number time_slot_id
BIO-101 1 Summer 2017 Painter 514 B
BIO-301 1 Summer 2018 Painter 514 A
CS-101 1 Fall 2017 Packard 101 H
CS-101 1 Spring 2018 Packard 101 F
CS-190 1 Spring 2017 Taylor 3128 E
CS-190 2 Spring 2017 Taylor 3128 A
CS-315 1 Spring 2018 Watson 120 D
CS-319 1 Spring 2018 Watson 100 B
CS-319 2 Spring 2018 Taylor 3128 C
CS-347 1 Fall 2017 Taylor 3128 A
EE-181 1 Spring 2017 Taylor 3128 C
FIN-201 1 Spring 2018 Packard 101 B
HIS-351 1 Spring 2018 Painter 514 C
MU-199 1 Spring 2018 Packard 101 D
PHY-101 1 Fall 2017 Watson 100 A
create view Biology_Summer_2017 as
select course.course_id, sec_id, building, room_number
from course, section
where course.course_id = section.course_id
and course.dept_name = 'Biology'
and section.semester = 'Summer'
and section.year = 2017;
select * from Biology_Summer_2017;
course_idsec_idbuildingroom_number
BIO-101 1 Painter 514
select course_id
from Biology_Summer_2017
Mrs. Sunita M Dol
Page 4
where building= 'Painter';
course_id
BIO-101
Create a view that finds the department-wise total salary
select * from instructor;
ID name dept_namesalary
10101SrinivasanComp. Sci. 65000
12121Wu Finance 90000
15151Mozart Music 40000
22222Einstein Physics 95000
32343El Said History 60000
33456Gold Physics 87000
45565Katz Comp. Sci. 75000
58583Califieri History 62000
76543Singh Finance 80000
76766Crick Biology 72000
83821Brandt Comp. Sci. 92000
98345Kim Elec. Eng. 80000
create view departments_total_salary (dept_name, total_salary) as
select dept_name, sum (salary)
from instructor
group by dept_name;
select * from departments_total_salary
dept_name total_salary
Biology 72000
Mrs. Sunita M Dol
Page 5
Comp. Sci. 232000
Elec. Eng. 80000
Finance 170000
History 122000
Music 40000
Physics 182000
Practice Problem Statements
1. Consider the clerk who needs to access all data in the instructor relation, except
salary. The clerk should not be authorized to access the instructor relation. Create
view relation faculty that can be made available to the clerk,
2. Create a view that lists all course sections offered by the Physics department in the
Fall 2009 semester with the building and room number of each section.
3. Define a view physics_fall_2009_watson that lists the course ID and room number of
all Physics courses offered in the Fall 2009 semester in the Watson building
References:
 Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan
(McGraw Hill International Edition) sixth edition.
 Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan
(McGraw Hill International Edition) fifth edition.
 http://codex.cs.yale.edu/avi/db-book/db4/slide-dir/
 http://codex.cs.yale.edu/avi/db-book/db5/slide-dir/
 http://codex.cs.yale.edu/avi/db-book/db6/slide-dir/

More Related Content

Similar to 8.Views.pdf

Numerical estimation 1
Numerical estimation 1Numerical estimation 1
Numerical estimation 1Isaac Ayuba M.
 
43.3 d cob2016
43.3 d cob201643.3 d cob2016
43.3 d cob2016saxor29
 
Redefining the unit
Redefining the unitRedefining the unit
Redefining the unitThoughtworks
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah Assagaf
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah Assagaf
 
Boeing Undergraduate Case Competition 2016
Boeing Undergraduate Case Competition 2016 Boeing Undergraduate Case Competition 2016
Boeing Undergraduate Case Competition 2016 Caleb Kwok
 
Sales forecasting using sas
Sales forecasting using sasSales forecasting using sas
Sales forecasting using sasHaritha Easan
 
Q3 2014 industrial market report
Q3 2014 industrial market reportQ3 2014 industrial market report
Q3 2014 industrial market reportdevengriffin
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah Assagaf
 
Scheduling by Primavera - Training
Scheduling by Primavera - TrainingScheduling by Primavera - Training
Scheduling by Primavera - TrainingMohammed Feroze
 
Chapter 4 power point ( BUAD 111 Financial Accounting I)
Chapter 4 power point ( BUAD 111 Financial Accounting I)Chapter 4 power point ( BUAD 111 Financial Accounting I)
Chapter 4 power point ( BUAD 111 Financial Accounting I)Jach Inder
 
Appendix  A  Future value in.docx
Appendix  A  Future value in.docxAppendix  A  Future value in.docx
Appendix  A  Future value in.docxrossskuddershamus
 
Oracle trace data collection errors: the story about oceans, islands, and rivers
Oracle trace data collection errors: the story about oceans, islands, and riversOracle trace data collection errors: the story about oceans, islands, and rivers
Oracle trace data collection errors: the story about oceans, islands, and riversCary Millsap
 
Cisco certification exams 300 070
Cisco certification exams 300 070Cisco certification exams 300 070
Cisco certification exams 300 070adam_jhon
 
Balloon Project Summary
Balloon Project SummaryBalloon Project Summary
Balloon Project Summaryrhlee46
 
Inventor Drawing Assignment
Inventor Drawing AssignmentInventor Drawing Assignment
Inventor Drawing AssignmentP1666
 
Multiviews
MultiviewsMultiviews
MultiviewsP1666
 

Similar to 8.Views.pdf (20)

Numerical estimation 1
Numerical estimation 1Numerical estimation 1
Numerical estimation 1
 
43.3 d cob2016
43.3 d cob201643.3 d cob2016
43.3 d cob2016
 
Redefining the unit
Redefining the unitRedefining the unit
Redefining the unit
 
Human Performance AI Enhanced
Human Performance AI EnhancedHuman Performance AI Enhanced
Human Performance AI Enhanced
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyek
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyek
 
Boeing Undergraduate Case Competition 2016
Boeing Undergraduate Case Competition 2016 Boeing Undergraduate Case Competition 2016
Boeing Undergraduate Case Competition 2016
 
Sales forecasting using sas
Sales forecasting using sasSales forecasting using sas
Sales forecasting using sas
 
Q3 2014 industrial market report
Q3 2014 industrial market reportQ3 2014 industrial market report
Q3 2014 industrial market report
 
Aminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyekAminullah assagaf mp2 manajemen proyek
Aminullah assagaf mp2 manajemen proyek
 
Kema switch certified
Kema switch certifiedKema switch certified
Kema switch certified
 
Scheduling by Primavera - Training
Scheduling by Primavera - TrainingScheduling by Primavera - Training
Scheduling by Primavera - Training
 
Time cost-trade-off
Time cost-trade-offTime cost-trade-off
Time cost-trade-off
 
Chapter 4 power point ( BUAD 111 Financial Accounting I)
Chapter 4 power point ( BUAD 111 Financial Accounting I)Chapter 4 power point ( BUAD 111 Financial Accounting I)
Chapter 4 power point ( BUAD 111 Financial Accounting I)
 
Appendix  A  Future value in.docx
Appendix  A  Future value in.docxAppendix  A  Future value in.docx
Appendix  A  Future value in.docx
 
Oracle trace data collection errors: the story about oceans, islands, and rivers
Oracle trace data collection errors: the story about oceans, islands, and riversOracle trace data collection errors: the story about oceans, islands, and rivers
Oracle trace data collection errors: the story about oceans, islands, and rivers
 
Cisco certification exams 300 070
Cisco certification exams 300 070Cisco certification exams 300 070
Cisco certification exams 300 070
 
Balloon Project Summary
Balloon Project SummaryBalloon Project Summary
Balloon Project Summary
 
Inventor Drawing Assignment
Inventor Drawing AssignmentInventor Drawing Assignment
Inventor Drawing Assignment
 
Multiviews
MultiviewsMultiviews
Multiviews
 

More from Sunita Milind Dol (20)

9.Joins.pdf
9.Joins.pdf9.Joins.pdf
9.Joins.pdf
 
4. DML.pdf
4. DML.pdf4. DML.pdf
4. DML.pdf
 
3. DDL.pdf
3. DDL.pdf3. DDL.pdf
3. DDL.pdf
 
2. SQL Introduction.pdf
2. SQL Introduction.pdf2. SQL Introduction.pdf
2. SQL Introduction.pdf
 
1. University Example.pdf
1. University Example.pdf1. University Example.pdf
1. University Example.pdf
 
Assignment12
Assignment12Assignment12
Assignment12
 
Assignment11
Assignment11Assignment11
Assignment11
 
Assignment10
Assignment10Assignment10
Assignment10
 
Assignment9
Assignment9Assignment9
Assignment9
 
Assignment8
Assignment8Assignment8
Assignment8
 
Assignment7
Assignment7Assignment7
Assignment7
 
Assignment6
Assignment6Assignment6
Assignment6
 
Assignment5
Assignment5Assignment5
Assignment5
 
Assignment4
Assignment4Assignment4
Assignment4
 
Assignment3
Assignment3Assignment3
Assignment3
 
Assignment2
Assignment2Assignment2
Assignment2
 
Assignment1
Assignment1Assignment1
Assignment1
 
Handout#12
Handout#12Handout#12
Handout#12
 
Handout#11
Handout#11Handout#11
Handout#11
 
Handout#10
Handout#10Handout#10
Handout#10
 

Recently uploaded

Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Recently uploaded (20)

Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 

8.Views.pdf

  • 1. Mrs. Sunita M Dol Page 1 Views We define a view in SQL by using the create view command. To define a view, we must give the view a name and must state the query that computes the view. The form of the create view command is create view v as <query expression> where <query expression> is any legal query expression. The view name is represented by v. Create the view faculty which consist of an instructor’s ID, name and department name select * from instructor; ID name dept_namesalary 10101SrinivasanComp. Sci. 65000 12121Wu Finance 90000 15151Mozart Music 40000 22222Einstein Physics 95000 32343El Said History 60000 33456Gold Physics 87000 45565Katz Comp. Sci. 75000 58583Califieri History 62000 76543Singh Finance 80000 76766Crick Biology 72000 83821Brandt Comp. Sci. 92000 98345Kim Elec. Eng. 80000 create view faculty as select ID, name, dept_name from instructor; ID name dept_name 10101SrinivasanComp. Sci. 12121Wu Finance 15151Mozart Music
  • 2. Mrs. Sunita M Dol Page 2 ID name dept_name 22222Einstein Physics 32343El Said History 33456Gold Physics 45565Katz Comp. Sci. 58583Califieri History 76543Singh Finance 76766Crick Biology 83821Brandt Comp. Sci. 98345Kim Elec. Eng. Create a view that lists all course sections offered by the Biology department in the summer 2017 semester with the building and room number of each section select * from course; course_id title dept_name credits BIO-101 Intro. to Biology Biology 4 BIO-301 Genetics Biology 4 BIO-399 Computational Biology Biology 3 CS-101 Intro. to Computer Science Comp. Sci. 4 CS-190 Game Design Comp. Sci. 4 CS-315 Robotics Comp. Sci. 3 CS-319 Image Processing Comp. Sci. 3 CS-347 Database System Concepts Comp. Sci. 3 EE-181 Intro. to Digital Systems Elec. Eng. 3 FIN-201 Investment Banking Finance 3 HIS-351 World History History 3 MU-199 Music Video Production Music 3 PHY-101 Physical Principles Physics 4 select * from section;
  • 3. Mrs. Sunita M Dol Page 3 course_id sec_id semester year building room_number time_slot_id BIO-101 1 Summer 2017 Painter 514 B BIO-301 1 Summer 2018 Painter 514 A CS-101 1 Fall 2017 Packard 101 H CS-101 1 Spring 2018 Packard 101 F CS-190 1 Spring 2017 Taylor 3128 E CS-190 2 Spring 2017 Taylor 3128 A CS-315 1 Spring 2018 Watson 120 D CS-319 1 Spring 2018 Watson 100 B CS-319 2 Spring 2018 Taylor 3128 C CS-347 1 Fall 2017 Taylor 3128 A EE-181 1 Spring 2017 Taylor 3128 C FIN-201 1 Spring 2018 Packard 101 B HIS-351 1 Spring 2018 Painter 514 C MU-199 1 Spring 2018 Packard 101 D PHY-101 1 Fall 2017 Watson 100 A create view Biology_Summer_2017 as select course.course_id, sec_id, building, room_number from course, section where course.course_id = section.course_id and course.dept_name = 'Biology' and section.semester = 'Summer' and section.year = 2017; select * from Biology_Summer_2017; course_idsec_idbuildingroom_number BIO-101 1 Painter 514 select course_id from Biology_Summer_2017
  • 4. Mrs. Sunita M Dol Page 4 where building= 'Painter'; course_id BIO-101 Create a view that finds the department-wise total salary select * from instructor; ID name dept_namesalary 10101SrinivasanComp. Sci. 65000 12121Wu Finance 90000 15151Mozart Music 40000 22222Einstein Physics 95000 32343El Said History 60000 33456Gold Physics 87000 45565Katz Comp. Sci. 75000 58583Califieri History 62000 76543Singh Finance 80000 76766Crick Biology 72000 83821Brandt Comp. Sci. 92000 98345Kim Elec. Eng. 80000 create view departments_total_salary (dept_name, total_salary) as select dept_name, sum (salary) from instructor group by dept_name; select * from departments_total_salary dept_name total_salary Biology 72000
  • 5. Mrs. Sunita M Dol Page 5 Comp. Sci. 232000 Elec. Eng. 80000 Finance 170000 History 122000 Music 40000 Physics 182000 Practice Problem Statements 1. Consider the clerk who needs to access all data in the instructor relation, except salary. The clerk should not be authorized to access the instructor relation. Create view relation faculty that can be made available to the clerk, 2. Create a view that lists all course sections offered by the Physics department in the Fall 2009 semester with the building and room number of each section. 3. Define a view physics_fall_2009_watson that lists the course ID and room number of all Physics courses offered in the Fall 2009 semester in the Watson building References:  Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan (McGraw Hill International Edition) sixth edition.  Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan (McGraw Hill International Edition) fifth edition.  http://codex.cs.yale.edu/avi/db-book/db4/slide-dir/  http://codex.cs.yale.edu/avi/db-book/db5/slide-dir/  http://codex.cs.yale.edu/avi/db-book/db6/slide-dir/