15. List the first name for all contacts and whether they have a spouse or not (yes/no). Order by the first name. For example, your result set might look like this: I fÅKstname | Married? | Biff | George | Jennifer | Lorraine | Marty | no | yes | no | yes | no
15. List the first name for all contacts and whether they have a spouse or not (yes/no). Order by the first name. For example, your result set might look like this: I fÅKstname | Married? | Biff | George | Jennifer | Lorraine | Marty | no | yes | no | yes | no
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

Transcribed Image Text:**Example Task for an Educational Website:**
**Task 15: Creating a Contact List with Marital Status**
Your task is to list the first name of all contacts along with their marital status, indicating whether they have a spouse (yes/no). Sort the list by the first name. An example of how your result might appear is displayed below:
```
+-----------+---------+
| firstname | Married?|
+-----------+---------+
| Biff | no |
| George | yes |
| Jennifer | no |
| Lorraine | yes |
| Marty | no |
+-----------+---------+
```
**Explanation of the Table:**
- The table is organized with two columns:
- The first column labeled "firstname" holds individuals' first names.
- The second column labeled "Married?" indicates the individual's marital status with either "yes" (indicating they have a spouse) or "no" (indicating they do not).
- The contacts are ordered alphabetically by their first names in the list.

Transcribed Image Text:For the remaining questions, use the following table of people:
**people** (id *(pk)*, firstname, lastname, spouse_id *(fk)*)
The table was created as:
```sql
CREATE TABLE people (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30),
lastname VARCHAR(30),
spouse_id INT,
CONSTRAINT spouse_fk FOREIGN KEY (spouse_id) REFERENCES people (id)
);
```
This is some sample data:
**Participation Activity 9**
```
+----+-----------+-----------+-----------+
| id | firstname | lastname | spouse_id |
+----+-----------+-----------+-----------+
| 1 | Marty | McFly | NULL |
| 2 | Jennifer | Parker | NULL |
| 3 | Lorraine | McFly | 5 |
| 4 | Biff | Tannen | NULL |
| 5 | George | McFly | 3 |
+----+-----------+-----------+-----------+
```
In this table:
- `id`: An integer that serves as the primary key for the table.
- `firstname`: A string representing the person's first name, with a maximum length of 30 characters.
- `lastname`: A string representing the person's last name, with a maximum length of 30 characters.
- `spouse_id`: An integer that is a foreign key referencing the `id` in the same table, indicating the spouse's ID if applicable, otherwise `NULL`.
The sample data provides five entries with various relationships, including NULL values for those who are not married (i.e., not assigned a spouse ID).
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education