DBMS Expt 6 PBL Grpoup 02

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Department of Electronics Engineering

Semester TE Electronics
Subject DBMS Laboratory
Laboratory Professor Prof. Uma Jaishankar

Group NO 02
Student Name Aditya Jalkote and Atharva Aurangabadkar
Roll Number 21103B0029 and 21103B0022

Experiment 6
No:

Experiment PBL: Government flat allotment scheme database


Title
Design a database management system for government flat allotment scheme for
under privileged and lower income citizens in the state of Maharashtra
Create 2 tables for applicants and eligible projects and write queries for
1)Complete detail for eligible applicants for slum development program
2)Find the least economical backward category of applicants
3) Find the most popular project
4) Find the list of applicants not eligible

5) Amount generated through registration

Resources / Hardware: Software:


Apparatus
PC Oracle/MySQL/PostgreSQL & Internet
Required

Objectives 1) To study different types of functions.

2) To use these commands for a given table and run the queries

SQL -- Create Eligible Projects Table


Queries CREATE TABLE eligible_projects (
with output project_id INT PRIMARY KEY,
project_name VARCHAR(100) NOT NULL,
popularity_score INT NOT NULL,
location VARCHAR(100) NOT NULL,
cost DECIMAL(12, 2) NOT NULL
);

Page|1
Department of Electronics Engineering

-- Create Applicants Table


CREATE TABLE applicants (
applicant_id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
category VARCHAR(50) NOT NULL,
income DECIMAL(10, 2) NOT NULL,
is_eligible BOOLEAN NOT NULL,
project_id INT,
FOREIGN KEY (project_id) REFERENCES eligible_projects(project_id)
);

INSERT INTO eligible_projects (project_id, project_name, popularity_score, location,


cost)
VALUES
(1, 'Project1 - Affordable Housing', 20, 'Mumbai Central', 1000000.00),
(2, 'Project2 - Slum Redevelopment', 15, 'Pune East', 800000.00),
(3, 'Project3 - Low-Income Apartments', 25, 'Nagpur North', 1200000.00);

INSERT INTO applicants (applicant_id, name, category, income, is_eligible, project_id)


VALUES
(1, 'Applicant1', 'Economically Weaker Section', 50000.00, TRUE, 1),
(2, 'Applicant2', 'Backward Category', 30000.00, TRUE, 2),
(3, 'Applicant3', 'Slum Development', 20000.00, TRUE, 1),
(4, 'Applicant4', 'General', 70000.00, FALSE, NULL),
(5, 'Applicant5', 'Backward Category', 25000.00, TRUE, 2);

SELECT * FROM eligible_projects;

SELECT * FROM applicants;

Output:

+ + + +
+ +
| project_id | project_name | popularity_score | location
| cost |
+ + + +
+ +
| 1 | Project1 - Affordable Housing | 20 | Mumbai
Central | 1000000.00 |

Page|2
Department of Electronics Engineering

| 2 | Project2 - Slum Redevelopment | 15 | Pune


East | 800000.00 |
| 3 | Project3 - Low-Income Apartments | 25 | Nagpur
North | 1200000.00 |
+ + + +
+ +
+ + + + +
+ +
| applicant_id | name | category | income |
is_eligible | project_id |
+ + + + +
+ +
| 1 | Applicant1 | Economically Weaker Section | 50000.00 |
1 | 1 |
| 2 | Applicant2 | Backward Category | 30000.00 |
1 | 2 |
| 3 | Applicant3 | Slum Development | 20000.00 |
1 | 1 |
| 4 | Applicant4 | General | 70000.00 |
0 | NULL |
| 5 | Applicant5 | Backward Category | 25000.00 |
1 | 2 |
+ + + + +
+ +

SELECT *
FROM applicants
WHERE is_eligible = TRUE
AND category = 'Slum Development';
+ + + + +
+ +
| applicant_id | name | category | income | is_eligible |
project_id |
+ + + + +
+ +
| 3 | Applicant3 | Slum Development | 20000.00 | 1 |
1 |
+ + + + +
+ +

SELECT *
FROM applicants
WHERE category = 'Backward Category'
ORDER BY income ASC
LIMIT 1;

+ + + +
+ +

Page|3
Department of Electronics Engineering

| applicant_id | name | category | income | is_eligible


| project_id |
+ + + + +
+ +
| 5 | Applicant5 | Backward Category | 25000.00 | 1
| 2 |
+ + + + +
+ +

SELECT project_id, project_name, popularity_score


FROM eligible_projects
ORDER BY popularity_score DESC
LIMIT 1;

+ + + +
| project_id | project_name | popularity_score |
+ + + +
| 3 | Project3 - Low-Income Apartments | 25 |
+ + + +

SELECT *
FROM applicants
WHERE is_eligible = FALSE;

+ + + + + +
+
| applicant_id | name | category | income | is_eligible |
project_id |
+ + + + + +
+
| 4 | Applicant4 | General | 70000.00 | 0 |
NULL |
+ + + + + +

-- Assuming registration_fee is 100 (replace with your actual registration fee)


SELECT COUNT(*) * 10000 AS amount_generated
FROM applicants;

+ +
| amount_generated |
+ +
| 50000 |
+ +

Page|4
Department of Electronics Engineering

Conclusion The database schema is designed to manage information related to housing projects
and applicants, facilitating the allocation of flats in government schemes.Queries are
provided to extract valuable insights, such as identifying eligible applicants for specific
programs, evaluating the economic status of applicants, determining popular projects,
and calculating revenue generated through registration.

Page|5

You might also like