For the following table structure, "tPersona" has next fields:
rut as varchar, PK
FullName as varchar,
date Birth as date,
live as boolean,
rutPadre as varchar, FK
rutMadre as varchar, FK
● The rut field contains the person's identi ? cation and is the primary key of the tPersona table.
● The FullName field contains names and surnames and does not support nulls.
● The Birthdate field contains the day, month and year of birth and allows nulls.
● The rutPadre and rutMadre data fields are references to the primary registry key of the same tPersona table,
can have a null value (padro or unknown mother)
and do not guarantee relational integrity (the parent record was deleted, but the value was maintained from rutPadre).
● The live data field is TRUE if the person is alive and FALSE if the person. is dead, does not support nulls.
Exercise:
1. Develop the SQL script or pseudocode that lists all the people whose father and mother were born on the same day.
2. List the name of people who have only one parent, father or mother alive.
3. Update the rutPadre that points to a non-existent record.
In other words, the routine it contains does not correspond to any person's routine in the table.
Thank a lot

Amira BedhiafiRank #601 · 4K reputationPosted Mar 5, 2025, 12:15 PM EST
List all people whose father and mother were born on the same day :
SELECT p.FullName FROM tPersona p JOIN tPersona padre ON p.rutPadre = padre.rut JOIN tPersona madre ON p.rutMadre = madre.rut WHERE padre.Birth = madre.Birth;List the name of people who have only one parent, father or mother alive.
SELECT p.FullName FROM tPersona p LEFT JOIN tPersona padre ON p.rutPadre = padre.rut LEFT JOIN tPersona madre ON p.rutMadre = madre.rut WHERE (padre.live = TRUE AND madre.live IS NULL) OR (madre.live = TRUE AND padre.live IS NULL)Update the rutPadre that points to a non-existent record.
UPDATE tPersona SET rutPadre = NULL WHERE rutPadre IS NOT NULL AND rutPadre NOT IN (SELECT rut FROM tPersona)Jignesh KumarRank #91 · 22.9K reputationPosted Mar 5, 2025, 11:04 PM EST
Hellio,
1. Develop the SQL script or pseudocode that lists all the people whose father and mother were born on the same day.
SELECT p.rut, p.FullName FROM tPersona p JOIN tPersona padre With(Nolock) ON p.rutPadre = padre.rut JOIN tPersona madre With(Nolock) ON p.rutMadre = madre.rut WHERE padre.Birthdate IS NOT NULL AND madre.Birthdate IS NOT NULL AND padre.Birthdate = madre.Birthdate;2. List the name of people who have only one parent, father or mother alive.
SELECT p.rut, p.FullName FROM tPersona p LEFT JOIN tPersona padre With(Nolock) ON p.rutPadre = padre.rut LEFT JOIN tPersona madre With(Nolock) ON p.rutMadre = madre.rut WHERE (padre.live = TRUE AND (madre.live IS NULL OR madre.live = FALSE)) OR (madre.live = TRUE AND (padre.live IS NULL OR padre.live = FALSE));3. Update the rutPadre that points to a non-existent record.
UPDATE tPersona SET rutPadre = NULL WHERE rutPadre IS NOT NULL AND rutPadre NOT IN (SELECT rut FROM tPersona);Hope above query help to get your work done