Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Suppose that you have a database about families such that each family is described by one PROLOG clause. For example: family( person(tom, fox, date(7,may,1950),

5. Suppose that you have a database about families such that each family is described by one PROLOG clause. For example:

family(

person(tom, fox, date(7,may,1950), works(bbc,15200)),

person(ann, fox, date(9,may, 1951), unemployed),

[person(pat, fox, date(5,may,1973), unemployed),

person(jim, fox, date(5,may,1973), unemployed)]).

From the previous clause it is easy to see that:

each family has three components: husband, wife and children.

as the number of children varies from family to family the children are represented by a list that is capable of accommodating any number of items.

each person is, in turn, represented by a structure of four components: name, surname, date of birth, job. The job information is unemployed or it specifies the working organization and salary.

Suppose that you have a following set of utility procedures for your database:

husband(X) :- family(X, _, _). % X is a husband

wife(X) :- family(_, X, _). % X is a wife

child(X) :- family( _, _, Children), % X is a child

member(X, Children).

member(X, [X|L]).

member(X, [Y|L]) :- member (X,L).

exist(Person) : - husband(Person); % any person in DB

wife(Person);

child(Person).

dateofbirth (person(_, _, Date, _), Date).

salary(person(_,_, _, works(_, S)),S). % Salary of work. person.

salary(person(_,_,_,unemployed),0). % Salary of unemployed.

Write queries to find the following from the family database:

(a) Find people born before 1970 whose salary is less than 30000

(b) Names of families without children.

(c) All employed children.

(d) Names of families with employed wives and unemployed husbands.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago