C programming problems
C programming problems
And also
what data can we retrieve from those tables?
Ans:
We have declared the three tables Person, Company and Investment as follows:
Person
CREATE TABLE Person_07 (
person_id INT,
person_name VARCHAR(100) NOT NULL,
dob DATE NOT NULL,
gender ENUM('MALE','FEMALE') NOT NULL,
father INT,
mother INT,
PRIMARY KEY(person_id),
FOREIGN KEY(father) references Person_07(person_id),
);
Company
CREATE TABLE Company_07 (
company_id INT,
company_name VARCHAR(100) NOT NULL,
capital DECIMAL(20,2),
PRIMARY KEY(company_id)
);
Investment
CREATE TABLE Investment_07 (
company_id INT,
person INT,
share DECIMAL(5,2) NOT NULL,
1. Person and Investment: A person can have none or multiple investments in the
investment table. He/She can invest in multiple companies as well.
This is achieved by assigning person_id as a foreign key to the person field of
investment table.
2. Investment and Person: The total share of a country hold by multiple person must add
up to 100%. Each investor must belong to the person table.
3. Person and Family: Father and mother of a person must be present in the person table.
This is achived by assigning father and mother fields with a foreign key of person_id
4. Company and Investment: Each company in investment table must belong to the
company table.
This is achieved by assigning company_id as foreign key tocompany field of investment
table
Q2:
1. Retrieve all people and their investments: