Question
I need to execute below SQL query Populate the tables with data (using Sequence and Sub Query), ensuring that there are at least 5 people,
I need to execute below SQL query
Populate the tables with data (using Sequence and Sub Query), ensuring that there are at least 5 people, at least 8 posts, and at least 4 likes. Make sure to use sequences to generate the primary and foreign key values. Most of the fields are self?explanatory. As far as the "content" field in Post, make them whatever you like, such as "Take a look at these new pics" or "Just arrived in the Bahamas", and set the summary as the first 12 characters of the content, followed by "...".
I created following tables -
CREATE TABLE Person (
person_id DECIMAL(12) NOT NULL,
first_name VARCHAR(32) NOT NULL,
last_name VARCHAR(32) NOT NULL,
username VARCHAR(20) NOT NULL,
PRIMARY KEY (person_id)
);
CREATE TABLE Post (
post_id DECIMAL(12) NOT NULL,
person_id DECIMAL(12) NOT NULL,
content VARCHAR(255) NOT NULL,
created_on DATE NOT NULL,
summary VARCHAR(255) NOT NULL,
PRIMARY KEY (post_id),
FOREIGN KEY (person_id) REFERENCES Person
);
CREATE TABLE Likes (
likes_id DECIMAL(12) NOT NULL,
person_id DECIMAL(12) NOT NULL,
post_id DECIMAL(12) NOT NULL,
liked_on DATE,
PRIMARY KEY (likes_id),
FOREIGN KEY (person_id) REFERENCES Person,
FOREIGN KEY (post_id) REFERENCES Post
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started