SlideShare a Scribd company logo
1 of 2
Problem 1. Please create the following tables with appropriate primary keys & foreign keys.
The list of tables is:
• Student table with 2 columns: sid (student ID), sname (student name).
• Teacher table with 2 columns: tid (teacher ID), tname (teacher name)
• Class table with 6 columns: cid (class ID), cname (class name), year (year of class), semester
(semester of class, e.g., fall, spring), credit (number of credits), tid (teacher ID).
• Grades table with 3 columns: sid (student ID), cid (class ID), grade (grade, 4 is A, 3 is B, 2 is
C, 1 is D, 0 is F).
Problem 2. Insert at least three rows of data to each table. Make sure you keep the primary key
and foreign key constraints.
Problem 3. Please write ONE SQL statement for each of the following tasks using tables created
in Problem 1.
Task 1: Return the total number of students
Task 2: Return the names of classes offered in Spring 2016 (spring is semester, 2016 is year).
Task 3: Return the names of classes taught by Dr. Chen in 2016.
Task 4: Return the IDs of classes with at least 2 students taking the class.
Task 5: Return the names of students who ever took Dr. Chen’s classes.
Task 6: Return the average grade of class IS 633 offered in spring 2016.
Solution
Question: Problem 1:
Table creations are given below: We have used CREATE TABLE syntax for table creation
i) CREATE TABLE Student (sid int NOT NULL, sname varchar(255), PRIMARY KEY (sid))
ii) CREATE TABLE Teacher (tid int NOT NULL, tname varchar(255), PRIMARY KEY (tid))
iii) CREATE TABLE Class (cid int NOT NULL, cname varchar(255), year int, semester
varchar(255), credit int, tid int NOT NULL, PRIMARY KEY (cid), FOREIGN KEY (tid)
REFERENCES Teacher(tid) )
iv) CREATE TABLE Grades (sid int NOT NULL, cid int NOT NULL, grade int)

More Related Content

Similar to Problem 1- Please create the following tables with appropriate primary.docx

Sequencing (Formulating the nth term rule) Explicit lesson plan grade VI
Sequencing (Formulating the nth term rule) Explicit lesson plan grade VISequencing (Formulating the nth term rule) Explicit lesson plan grade VI
Sequencing (Formulating the nth term rule) Explicit lesson plan grade VIApril Rose Anin
 
AECT 2010 - Homemade PowerPoint Games in a High School Science Setting
AECT 2010 - Homemade PowerPoint Games in a High School Science SettingAECT 2010 - Homemade PowerPoint Games in a High School Science Setting
AECT 2010 - Homemade PowerPoint Games in a High School Science SettingMichael Barbour
 
Business statistics (4)
Business statistics (4)Business statistics (4)
Business statistics (4)smumbahelp
 
Data structures; arrays By ZAK
Data structures; arrays By ZAKData structures; arrays By ZAK
Data structures; arrays By ZAKTabsheer Hasan
 
CMI2012 CCSS for Mathematics
CMI2012 CCSS for MathematicsCMI2012 CCSS for Mathematics
CMI2012 CCSS for MathematicsJanet Hale
 

Similar to Problem 1- Please create the following tables with appropriate primary.docx (10)

Project3
Project3Project3
Project3
 
C24
C24C24
C24
 
Algebra
AlgebraAlgebra
Algebra
 
DATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdfDATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdf
 
Sequencing (Formulating the nth term rule) Explicit lesson plan grade VI
Sequencing (Formulating the nth term rule) Explicit lesson plan grade VISequencing (Formulating the nth term rule) Explicit lesson plan grade VI
Sequencing (Formulating the nth term rule) Explicit lesson plan grade VI
 
AECT 2010 - Homemade PowerPoint Games in a High School Science Setting
AECT 2010 - Homemade PowerPoint Games in a High School Science SettingAECT 2010 - Homemade PowerPoint Games in a High School Science Setting
AECT 2010 - Homemade PowerPoint Games in a High School Science Setting
 
Excel Notes - Block #3
Excel Notes - Block #3Excel Notes - Block #3
Excel Notes - Block #3
 
Business statistics (4)
Business statistics (4)Business statistics (4)
Business statistics (4)
 
Data structures; arrays By ZAK
Data structures; arrays By ZAKData structures; arrays By ZAK
Data structures; arrays By ZAK
 
CMI2012 CCSS for Mathematics
CMI2012 CCSS for MathematicsCMI2012 CCSS for Mathematics
CMI2012 CCSS for Mathematics
 

More from shawnk7

An IP datagram has arrived with the following information in the heade.docx
An IP datagram has arrived with the following information in the heade.docxAn IP datagram has arrived with the following information in the heade.docx
An IP datagram has arrived with the following information in the heade.docxshawnk7
 
An Institutional Review Board (IRB) is concerned with how human partic.docx
An Institutional Review Board (IRB) is concerned with how human partic.docxAn Institutional Review Board (IRB) is concerned with how human partic.docx
An Institutional Review Board (IRB) is concerned with how human partic.docxshawnk7
 
An economy is characterized by the following behavioral equations- C -.docx
An economy is characterized by the following behavioral equations- C -.docxAn economy is characterized by the following behavioral equations- C -.docx
An economy is characterized by the following behavioral equations- C -.docxshawnk7
 
An auditor examines a sample of cancelled checks to verify that the ch.docx
An auditor examines a sample of cancelled checks to verify that the ch.docxAn auditor examines a sample of cancelled checks to verify that the ch.docx
An auditor examines a sample of cancelled checks to verify that the ch.docxshawnk7
 
All of the following are false regarding apportionment except- a Ap.docx
All of the following are false regarding apportionment except-    a Ap.docxAll of the following are false regarding apportionment except-    a Ap.docx
All of the following are false regarding apportionment except- a Ap.docxshawnk7
 
Also indicate all zero-force members- Check all that apply- Check all.docx
Also indicate all zero-force members- Check all that apply- Check all.docxAlso indicate all zero-force members- Check all that apply- Check all.docx
Also indicate all zero-force members- Check all that apply- Check all.docxshawnk7
 
Although objectives- functional tactics- and action items are included.docx
Although objectives- functional tactics- and action items are included.docxAlthough objectives- functional tactics- and action items are included.docx
Although objectives- functional tactics- and action items are included.docxshawnk7
 
prove or disprove that H - {n e(element) Z- n is divisible by both 8.docx
prove or disprove  that H - {n e(element) Z- n is divisible by both 8.docxprove or disprove  that H - {n e(element) Z- n is divisible by both 8.docx
prove or disprove that H - {n e(element) Z- n is divisible by both 8.docxshawnk7
 
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docx
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docxProject 3 is based on the materials from Freakonomics Radio Podcast- H.docx
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docxshawnk7
 
Problem 9-11A Time Value of Money Concept The following situations inv.docx
Problem 9-11A Time Value of Money Concept The following situations inv.docxProblem 9-11A Time Value of Money Concept The following situations inv.docx
Problem 9-11A Time Value of Money Concept The following situations inv.docxshawnk7
 
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docx
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docxProblem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docx
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docxshawnk7
 
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docx
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docxProblem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docx
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docxshawnk7
 
Problem 11-6A Problem 11-6A Irwin Corporation has been au.docx
Problem 11-6A             Problem 11-6A  Irwin Corporation has been au.docxProblem 11-6A             Problem 11-6A  Irwin Corporation has been au.docx
Problem 11-6A Problem 11-6A Irwin Corporation has been au.docxshawnk7
 

More from shawnk7 (13)

An IP datagram has arrived with the following information in the heade.docx
An IP datagram has arrived with the following information in the heade.docxAn IP datagram has arrived with the following information in the heade.docx
An IP datagram has arrived with the following information in the heade.docx
 
An Institutional Review Board (IRB) is concerned with how human partic.docx
An Institutional Review Board (IRB) is concerned with how human partic.docxAn Institutional Review Board (IRB) is concerned with how human partic.docx
An Institutional Review Board (IRB) is concerned with how human partic.docx
 
An economy is characterized by the following behavioral equations- C -.docx
An economy is characterized by the following behavioral equations- C -.docxAn economy is characterized by the following behavioral equations- C -.docx
An economy is characterized by the following behavioral equations- C -.docx
 
An auditor examines a sample of cancelled checks to verify that the ch.docx
An auditor examines a sample of cancelled checks to verify that the ch.docxAn auditor examines a sample of cancelled checks to verify that the ch.docx
An auditor examines a sample of cancelled checks to verify that the ch.docx
 
All of the following are false regarding apportionment except- a Ap.docx
All of the following are false regarding apportionment except-    a Ap.docxAll of the following are false regarding apportionment except-    a Ap.docx
All of the following are false regarding apportionment except- a Ap.docx
 
Also indicate all zero-force members- Check all that apply- Check all.docx
Also indicate all zero-force members- Check all that apply- Check all.docxAlso indicate all zero-force members- Check all that apply- Check all.docx
Also indicate all zero-force members- Check all that apply- Check all.docx
 
Although objectives- functional tactics- and action items are included.docx
Although objectives- functional tactics- and action items are included.docxAlthough objectives- functional tactics- and action items are included.docx
Although objectives- functional tactics- and action items are included.docx
 
prove or disprove that H - {n e(element) Z- n is divisible by both 8.docx
prove or disprove  that H - {n e(element) Z- n is divisible by both 8.docxprove or disprove  that H - {n e(element) Z- n is divisible by both 8.docx
prove or disprove that H - {n e(element) Z- n is divisible by both 8.docx
 
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docx
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docxProject 3 is based on the materials from Freakonomics Radio Podcast- H.docx
Project 3 is based on the materials from Freakonomics Radio Podcast- H.docx
 
Problem 9-11A Time Value of Money Concept The following situations inv.docx
Problem 9-11A Time Value of Money Concept The following situations inv.docxProblem 9-11A Time Value of Money Concept The following situations inv.docx
Problem 9-11A Time Value of Money Concept The following situations inv.docx
 
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docx
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docxProblem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docx
Problem 5- -9 points- A red laser of wavelength 670 nm is directed thr.docx
 
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docx
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docxProblem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docx
Problem 3-32 Internal and Sustainable Growth Rates (LG3-6) Use the fol.docx
 
Problem 11-6A Problem 11-6A Irwin Corporation has been au.docx
Problem 11-6A             Problem 11-6A  Irwin Corporation has been au.docxProblem 11-6A             Problem 11-6A  Irwin Corporation has been au.docx
Problem 11-6A Problem 11-6A Irwin Corporation has been au.docx
 

Recently uploaded

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 

Recently uploaded (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 

Problem 1- Please create the following tables with appropriate primary.docx

  • 1. Problem 1. Please create the following tables with appropriate primary keys & foreign keys. The list of tables is: • Student table with 2 columns: sid (student ID), sname (student name). • Teacher table with 2 columns: tid (teacher ID), tname (teacher name) • Class table with 6 columns: cid (class ID), cname (class name), year (year of class), semester (semester of class, e.g., fall, spring), credit (number of credits), tid (teacher ID). • Grades table with 3 columns: sid (student ID), cid (class ID), grade (grade, 4 is A, 3 is B, 2 is C, 1 is D, 0 is F). Problem 2. Insert at least three rows of data to each table. Make sure you keep the primary key and foreign key constraints. Problem 3. Please write ONE SQL statement for each of the following tasks using tables created in Problem 1. Task 1: Return the total number of students Task 2: Return the names of classes offered in Spring 2016 (spring is semester, 2016 is year). Task 3: Return the names of classes taught by Dr. Chen in 2016. Task 4: Return the IDs of classes with at least 2 students taking the class. Task 5: Return the names of students who ever took Dr. Chen’s classes. Task 6: Return the average grade of class IS 633 offered in spring 2016. Solution Question: Problem 1:
  • 2. Table creations are given below: We have used CREATE TABLE syntax for table creation i) CREATE TABLE Student (sid int NOT NULL, sname varchar(255), PRIMARY KEY (sid)) ii) CREATE TABLE Teacher (tid int NOT NULL, tname varchar(255), PRIMARY KEY (tid)) iii) CREATE TABLE Class (cid int NOT NULL, cname varchar(255), year int, semester varchar(255), credit int, tid int NOT NULL, PRIMARY KEY (cid), FOREIGN KEY (tid) REFERENCES Teacher(tid) ) iv) CREATE TABLE Grades (sid int NOT NULL, cid int NOT NULL, grade int)