Web Dev Lab Assignment 6 @swaroop
Web Dev Lab Assignment 6 @swaroop
Welcome to the database schema design and implementation report for the "Solver" project. Solver is a platform
designed to address user doubts and queries effectively. This report outlines the creation of a database schema
tailored to accommodate various user roles, including administrators, question seekers, and experts. Through concise
steps, we demonstrate table creation, data insertion, and execution of diverse queries essential for the functionality
of the Solver project. This database schema serves as the backbone of the platform, facilitating seamless interaction
and resolution of user inquiries.
Task 1: Prepare tables along with required primary keys and foriegn key constraints
Code :
-- Create tables
ExpertiseDomain VARCHAR(50),
);
UserID INT,
QuestionText TEXT,
DatePosted DATE,
);
QuestionID INT,
UserID INT,
AnswerText TEXT,
DatePosted DATE,
);
Output :
Task 2 : Fill the required data in the tables.
Code :
-- Insert data into Users table
INSERT INTO Users (UserID, UserName, Email, UserType, ExpertiseDomain, RecStatus) VALUES
(1, 'Admin1', 'admin1@example.com', 'Admin', NULL, 'Active'),
(2, 'QuestionSeeker1', 'questionseeker1@example.com', 'QuestionSeeker', NULL, 'Active'),
(3, 'Expert1', 'expert1@example.com', 'Expert', 'Mathematics', 'Active'),
(4, 'Expert2', 'expert2@example.com', 'Expert', 'Programming', 'Inactive'),
(5, 'Expert3', 'expert3@example.com', 'Expert', 'Physics', 'Active');
FROM Questions q
Output:
FROM Answers a
WHERE a.QuestionID = 1;
Output:
Q3 Get the user who posted a specific question:
Code:
SELECT u.UserName
FROM Questions q
JOIN Users u ON q.UserID = u.UserID
WHERE q.QuestionID = 1;
Output: