Question: CREATE TABLE Person ( PersonID Number PRIMARY KEY, Name Char ( 4 5 ) Gender Char ( 1 ) ) ; CREATE TABLE Parent (

CREATE TABLE Person (
PersonID Number PRIMARY KEY,
Name Char(45)
Gender Char(1)
);
CREATE TABLE Parent (
ParentID Number,
ChildID Number
);
CREATE TABLE Spouse(
Spouse1ID Number,
Spouse2ID Number
);
INSERT INTO Person VALUES (1200,'E M,'F');
INSERT INTO Person VALUES (301,'R T','F');
INSERT INTO Person VALUES (302,'Z T,'M');
INSERT INTO Person VALUES (1201,S T,M);
INSERT INTO Person VALUES (1010,'B M','M');
INSERT INTO Person VALUES (1011,C G,F);
INSERT INTO Person VALUES (1001,'R M','F');
INSERT INTO Person VALUES (1000,'J M','M');
INSERT INTO Person VALUES (1100,'C M','M');
INSERT INTO Person VALUES (107,'S M','M');
INSERT INTO Person VALUES (108,'J M','M');
INSERT INTO Person VALUES (1110,'N B','F');
INSERT INTO Person VALUES (1300,'J M','F');
INSERT INTO Person VALUES (1310,'S G,'F');
INSERT INTO Person VALUES (1301,L G,M);
INSERT INTO Person VALUES (1020,'D V,'F');
INSERT INTO Person VALUES (1021,'J V','M');
INSERT INTO Person VALUES (1202,'K V','F');
INSERT INTO Person VALUES (1201,'R V','M');
INSERT INTO Parent VALUES (105,104);
INSERT INTO Parent VALUES (103,);
INSERT INTO Parent VALUES (102,202);
INSERT INTO Parent VALUES (103,203);
INSERT INTO Parent VALUES (104,204);
INSERT INTO Parent VALUES (105,205);
INSERT INTO Spouse VALUES (1000,2000);
INSERT INTO Spouse VALUES (1100,2100);
INSERT INTO Spouse VALUES (1200,2200);
Using these tables Write:
b. a query to return the two parents of each child (if you arent careful, the rows will show up twice).
c.You notice there might be siblings in there. Instead or returning the pair of parents for each child, modify the query to return pairs of people who have at least one child together.
d.Extend the prior query to count how many children they have together
e.Write a query to connect each female in the dataset to her children (one child per row). If she has no children, it should return NULL.
f.Write a query to determine if each mother has a spouse. If they do not have a spouse, the return should be NULL.
g.Write a query to determine all of the grandsons.
h.Using a semi-join, determine all the People who are fathers.
i.Using an anti-join, determine all of the unwed people.
j.Determine all brother-sister combinations.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!