SlideShare a Scribd company logo
1 of 3
Download to read offline
Design a database to store details about U.S. presidents and their terms in office. Also, record
details of their date and place of birth, gender, and political party affiliation (e.g., Caluthumpian
Progress Party). You are required to record the sequence of presidents so the predecessor and
successor of any president can be identified. How will you model the case of Grover Cleveland
who served nonconsecutive terms as president? Is it feasible that political party affiliation may
change? If so, how will you handle it? In populating your solution include the following
information (note this is not the format you will store it in the database):
Chester
Arthur
Born 10/05/1829
Whig until 01/01/1854
Republican after that
21st president
Grover
Cleveland
Born 03/18/1837
Democrat his entire career
22nd President
24th President
Benjamin
Harrison
Born 08/20/1833
Whig until 01/01/1856
Republican after that
23rd President
Chester
Arthur
Born 10/05/1829
Whig until 01/01/1854
Republican after that
21st president
Grover
Cleveland
Born 03/18/1837
Democrat his entire career
22nd President
24th President
Benjamin
Harrison
Born 08/20/1833
Whig until 01/01/1856
Republican after that
23rd President
Solution
Create table President(
PresidentID integer(6) primary key,
Name varchar (30)
Place varchar (20),
Dateofbirth date,
Gender varchar(1) check in (m,f),
Ruling_startdate date,
Ruling_end date date,
Affiliation_party varchar(20),
Terms varchar(30));
We will design all the attributes under one table or define separate table for president personal
details and party details.
We can separate the tables now.
President table:
Create table president(
PresidentId integer(6) primary key,
Name varchar(30) foreign key,
Dateofbirth date,
Gender varchar(1) check in (m,f)
Affiliation_party varchar(20),
Terms varchar(20));
Create table pres_det(
presidentID integer(6) primarykey,
Place_of_elect varchar(20),
Birthdate date,
Ruling_startdate date,
Ruling_enddate date,
);
CREATE SEQUENCE seq_presidentID
MINVALUE 10000
START WITH 10000
INCREMENT BY 100
Cycle.
If we execute this sequence president id is set to default value and increment by 100 for every
president value.
DECLARE @maxTerm INT
DECLARE @minTerm INT
SELECT @maxTerm = MAX(term_id), @minTerm = MIN(term_id) FROM President AS p
JOIN President AS p
ON p. presidentId = pres_det.presidentId
WHERE p.Name = 'name'
Then predecessor is
SELECT p.Name FROM pres_det AS t
JOIN President AS p
ON p.presidentId = t.presidentId
WHERE p.term = @minTerm - 1
To find the successor is
SELECT p.Name FROM pres_det AS t
JOIN President AS p
ON p.presidentId = t.presidentId
WHERE p.term = @maxTerm +1

More Related Content

More from monikajain201

Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdfChapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
monikajain201
 
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdfCHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
monikajain201
 
Civil Infrastructure Problems Why the public is not concerned about t.pdf
Civil Infrastructure Problems Why the public is not concerned about t.pdfCivil Infrastructure Problems Why the public is not concerned about t.pdf
Civil Infrastructure Problems Why the public is not concerned about t.pdf
monikajain201
 
Briefly discuss the adaptive changes seen in the chordates over the o.pdf
Briefly discuss the adaptive changes seen in the chordates over the o.pdfBriefly discuss the adaptive changes seen in the chordates over the o.pdf
Briefly discuss the adaptive changes seen in the chordates over the o.pdf
monikajain201
 
Argue in favor or against the following statements (include examples.pdf
Argue in favor or against the following statements (include examples.pdfArgue in favor or against the following statements (include examples.pdf
Argue in favor or against the following statements (include examples.pdf
monikajain201
 
What is the role of sequence numbers in the rdt protocolWhat is t.pdf
What is the role of sequence numbers in the rdt protocolWhat is t.pdfWhat is the role of sequence numbers in the rdt protocolWhat is t.pdf
What is the role of sequence numbers in the rdt protocolWhat is t.pdf
monikajain201
 
Which of the following statements about mitosis is true O a. Mitosis.pdf
Which of the following statements about mitosis is true O a. Mitosis.pdfWhich of the following statements about mitosis is true O a. Mitosis.pdf
Which of the following statements about mitosis is true O a. Mitosis.pdf
monikajain201
 
Which of the following factors would NOT contribute to allopatric spe.pdf
Which of the following factors would NOT contribute to allopatric spe.pdfWhich of the following factors would NOT contribute to allopatric spe.pdf
Which of the following factors would NOT contribute to allopatric spe.pdf
monikajain201
 
What would be the exact Materials and Method for this experiment2.pdf
What would be the exact Materials and Method for this experiment2.pdfWhat would be the exact Materials and Method for this experiment2.pdf
What would be the exact Materials and Method for this experiment2.pdf
monikajain201
 
What are some of the obstacles or barriers to implementing EBP (evid.pdf
What are some of the obstacles or barriers to implementing EBP (evid.pdfWhat are some of the obstacles or barriers to implementing EBP (evid.pdf
What are some of the obstacles or barriers to implementing EBP (evid.pdf
monikajain201
 
Type II hypersensitivity occurs when a.An immediate allergic or ana.pdf
Type II hypersensitivity occurs when  a.An immediate allergic or ana.pdfType II hypersensitivity occurs when  a.An immediate allergic or ana.pdf
Type II hypersensitivity occurs when a.An immediate allergic or ana.pdf
monikajain201
 

More from monikajain201 (20)

EnvironmentalCivil Engineering QuestionWhen chemicals are added t.pdf
EnvironmentalCivil Engineering QuestionWhen chemicals are added t.pdfEnvironmentalCivil Engineering QuestionWhen chemicals are added t.pdf
EnvironmentalCivil Engineering QuestionWhen chemicals are added t.pdf
 
Did Carl Linnaeus incorporate evolutionary thinking in the developme.pdf
Did Carl Linnaeus incorporate evolutionary thinking in the developme.pdfDid Carl Linnaeus incorporate evolutionary thinking in the developme.pdf
Did Carl Linnaeus incorporate evolutionary thinking in the developme.pdf
 
Do you think wood is mechanically homogeneous (i.e. as strong in all.pdf
Do you think wood is mechanically homogeneous (i.e. as strong in all.pdfDo you think wood is mechanically homogeneous (i.e. as strong in all.pdf
Do you think wood is mechanically homogeneous (i.e. as strong in all.pdf
 
Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdfChapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
Chapter 1 - A View of Life and its Chemical Basis. 1. Explain the.pdf
 
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdfCHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
CHOOSE THE CORRECT ANSWER1) PVC Corporation is considering an inv.pdf
 
Civil Infrastructure Problems Why the public is not concerned about t.pdf
Civil Infrastructure Problems Why the public is not concerned about t.pdfCivil Infrastructure Problems Why the public is not concerned about t.pdf
Civil Infrastructure Problems Why the public is not concerned about t.pdf
 
Cell Structure and FunctionLabel each of the arrows in the followi.pdf
Cell Structure and FunctionLabel each of the arrows in the followi.pdfCell Structure and FunctionLabel each of the arrows in the followi.pdf
Cell Structure and FunctionLabel each of the arrows in the followi.pdf
 
C Language ProblemThere are more than one wrong things I think.P.pdf
C Language ProblemThere are more than one wrong things I think.P.pdfC Language ProblemThere are more than one wrong things I think.P.pdf
C Language ProblemThere are more than one wrong things I think.P.pdf
 
Briefly discuss the adaptive changes seen in the chordates over the o.pdf
Briefly discuss the adaptive changes seen in the chordates over the o.pdfBriefly discuss the adaptive changes seen in the chordates over the o.pdf
Briefly discuss the adaptive changes seen in the chordates over the o.pdf
 
Argue in favor or against the following statements (include examples.pdf
Argue in favor or against the following statements (include examples.pdfArgue in favor or against the following statements (include examples.pdf
Argue in favor or against the following statements (include examples.pdf
 
27. What is a prosthetic group Identify prosthetic groups in the fol.pdf
27. What is a prosthetic group Identify prosthetic groups in the fol.pdf27. What is a prosthetic group Identify prosthetic groups in the fol.pdf
27. What is a prosthetic group Identify prosthetic groups in the fol.pdf
 
What is the role of sequence numbers in the rdt protocolWhat is t.pdf
What is the role of sequence numbers in the rdt protocolWhat is t.pdfWhat is the role of sequence numbers in the rdt protocolWhat is t.pdf
What is the role of sequence numbers in the rdt protocolWhat is t.pdf
 
Which of the following statements about mitosis is true O a. Mitosis.pdf
Which of the following statements about mitosis is true O a. Mitosis.pdfWhich of the following statements about mitosis is true O a. Mitosis.pdf
Which of the following statements about mitosis is true O a. Mitosis.pdf
 
Which of the following factors would NOT contribute to allopatric spe.pdf
Which of the following factors would NOT contribute to allopatric spe.pdfWhich of the following factors would NOT contribute to allopatric spe.pdf
Which of the following factors would NOT contribute to allopatric spe.pdf
 
What would be the exact Materials and Method for this experiment2.pdf
What would be the exact Materials and Method for this experiment2.pdfWhat would be the exact Materials and Method for this experiment2.pdf
What would be the exact Materials and Method for this experiment2.pdf
 
What are the most challenges of wireless networksSolutionThe .pdf
What are the most challenges of wireless networksSolutionThe .pdfWhat are the most challenges of wireless networksSolutionThe .pdf
What are the most challenges of wireless networksSolutionThe .pdf
 
What is particle What is a rigid body What is conservative .pdf
What is particle  What is a rigid body  What is conservative .pdfWhat is particle  What is a rigid body  What is conservative .pdf
What is particle What is a rigid body What is conservative .pdf
 
What are some of the obstacles or barriers to implementing EBP (evid.pdf
What are some of the obstacles or barriers to implementing EBP (evid.pdfWhat are some of the obstacles or barriers to implementing EBP (evid.pdf
What are some of the obstacles or barriers to implementing EBP (evid.pdf
 
Type II hypersensitivity occurs when a.An immediate allergic or ana.pdf
Type II hypersensitivity occurs when  a.An immediate allergic or ana.pdfType II hypersensitivity occurs when  a.An immediate allergic or ana.pdf
Type II hypersensitivity occurs when a.An immediate allergic or ana.pdf
 
The sum of two integers is 19. The larger integer is 5 less than twi.pdf
The sum of two integers is 19. The larger integer is 5 less than twi.pdfThe sum of two integers is 19. The larger integer is 5 less than twi.pdf
The sum of two integers is 19. The larger integer is 5 less than twi.pdf
 

Recently uploaded

Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
Elizabeth Walsh
 

Recently uploaded (20)

Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Ernest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell TollsErnest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell Tolls
 

Design a database to store details about U.S. presidents and their t.pdf

  • 1. Design a database to store details about U.S. presidents and their terms in office. Also, record details of their date and place of birth, gender, and political party affiliation (e.g., Caluthumpian Progress Party). You are required to record the sequence of presidents so the predecessor and successor of any president can be identified. How will you model the case of Grover Cleveland who served nonconsecutive terms as president? Is it feasible that political party affiliation may change? If so, how will you handle it? In populating your solution include the following information (note this is not the format you will store it in the database): Chester Arthur Born 10/05/1829 Whig until 01/01/1854 Republican after that 21st president Grover Cleveland Born 03/18/1837 Democrat his entire career 22nd President 24th President Benjamin Harrison Born 08/20/1833 Whig until 01/01/1856 Republican after that 23rd President Chester Arthur Born 10/05/1829 Whig until 01/01/1854 Republican after that 21st president Grover Cleveland Born 03/18/1837 Democrat his entire career
  • 2. 22nd President 24th President Benjamin Harrison Born 08/20/1833 Whig until 01/01/1856 Republican after that 23rd President Solution Create table President( PresidentID integer(6) primary key, Name varchar (30) Place varchar (20), Dateofbirth date, Gender varchar(1) check in (m,f), Ruling_startdate date, Ruling_end date date, Affiliation_party varchar(20), Terms varchar(30)); We will design all the attributes under one table or define separate table for president personal details and party details. We can separate the tables now. President table: Create table president( PresidentId integer(6) primary key, Name varchar(30) foreign key, Dateofbirth date, Gender varchar(1) check in (m,f) Affiliation_party varchar(20), Terms varchar(20)); Create table pres_det( presidentID integer(6) primarykey, Place_of_elect varchar(20), Birthdate date,
  • 3. Ruling_startdate date, Ruling_enddate date, ); CREATE SEQUENCE seq_presidentID MINVALUE 10000 START WITH 10000 INCREMENT BY 100 Cycle. If we execute this sequence president id is set to default value and increment by 100 for every president value. DECLARE @maxTerm INT DECLARE @minTerm INT SELECT @maxTerm = MAX(term_id), @minTerm = MIN(term_id) FROM President AS p JOIN President AS p ON p. presidentId = pres_det.presidentId WHERE p.Name = 'name' Then predecessor is SELECT p.Name FROM pres_det AS t JOIN President AS p ON p.presidentId = t.presidentId WHERE p.term = @minTerm - 1 To find the successor is SELECT p.Name FROM pres_det AS t JOIN President AS p ON p.presidentId = t.presidentId WHERE p.term = @maxTerm +1