0% found this document useful (0 votes)
7 views32 pages

Parking project

Uploaded by

ffop69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views32 pages

Parking project

Uploaded by

ffop69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Parking Management

System
By- Atharva Jagtap
Class- XII A
PM Shri Kendriya Vidyalaya INS Hamla

• NAME – Atharva Jagtap


• CLASS – 12th A
• ROLL NO –
• SUBJECT – Computer Science
• TOPIC – Parking Management
CERTIFICATE
 This is to certify that Atharva Jagtap of class XII-A from KENDRIYA
VIDYALAYA INS HAMLA has done his project on PARKING
MANAGEMENT under my supervision. He has taken interest and has
shown at most sincerity in completion of this project. I certify this project
up to my expectation & as per guidelines issued by CBSE, NEW DELHI.

______________ _______________
Subject Teacher Internal Examiner
ACKNOWLEDGEMENT
It is with pleasure that I acknowledge my sincere gratitude to our teacher,
MRS. Savita Sharma(PGT Computer Science) who taught and undertook
the responsibility of teaching the subject computer science. I have been
greatly benefited from her classes.
I am especially indebted to our Principal MRS. Madhulika Mishra who has
always been a source of encouragement and support and without whose
inspiration this project would not have been a successful .I would like to
place on record heartfelt thanks to her.
Finally, I would like to express my sincere appreciation for all the other
students for my batch their friendship & the fine time that we all shared
together.
INDEX
 Basics of SQL
 Database design
 Source Code
 Output
 Bibliography
BASICS OF SQL
 DATA BASE :-
 A database is an organized collection of structured information, or data,
typically stored electronically in a computer system. It is designed to
efficiently store, manage, retrieve, and manipulate data for various
purposes.
 Key Characteristics:
Organization: Databases are structured to allow for easy access and
management. This structure is usually defined by a database schema,
which outlines how data is stored and related to each other.
Accessibility: Databases provide mechanisms for users to access and
query data. This is often achieved through a Database Management
System (DBMS) that serves as an interface between users and the data
Efficiency: Databases are designed to handle large amounts of
data efficiently. They use indexing, querying, and transaction
processing to ensure that data operations are performed
quickly and reliably.
Consistency: Databases maintain data consistency and
integrity through the use of constraints and transactions,
ensuring that data remains accurate and reliable.
Security: Databases include security measures to protect data
from unauthorized access and breaches. This can include user
authentication, access controls, and encryption.
 Components of a Database:
Tables: Organized structures that store data in rows and
columns.
Queries: Tools to retrieve specific data by searching the
database.
Forms: User interfaces for data entry and modification.
Reports: Tools to generate structured outputs from the data.
Schemas: Blueprints that define the structure of the
database, including tables, fields, and relationships.

Databases are used in a wide variety of applications, from


simple data storage solutions to complex systems that power
e-commerce platforms, social networks, and enterprise
management systems.
A
 Relational Database Management System (RDBMS)

A Relational Database Management System (RDBMS) is a type


of database management system that stores data in the form of
related tables. These tables consist of rows and columns, where
each row represents a record and each column represents an
attribute of the data.
 Key Characteristics:
Structured Data Storage: Data is organized into tables,
which allows for a high level of organization and ease of
access. Each table consists of rows (tuples) and columns
(attributes).
Relationships: Tables in an RDBMS can be related to each
other through keys. A primary key uniquely identifies each
record in a table, while a foreign key creates a relationship
between two tables. A
SQL (Structured Query Language): RDBMSs use SQL as
the standard language to interact with the database. SQL
commands are used for querying, updating, and managing
the data
Data Integrity and Accuracy: RDBMSs enforce integrity
constraints to ensure the accuracy and consistency of data.
Common constraints include primary key, foreign key,
unique, not null, and check constraints.
 Advantages:
 Data Integrity: Ensures accurate and consistent data.
 Flexibility: Easy to add new data and tables without
disrupting existing system.
 Security: Offers robust security features to protect data.
 Scalability: Can handle large amounts of data and
numerous users simultaneously.

A
 Examples of RDBMS:
Oracle Database
MySQL
Microsoft SQL Server
PostgreSQL

These systems are widely used in various applications, from


small-scale operations to large enterprise solutions, due to their
reliability, efficiency, and scalability. A
 Structured Query Language (SQL)

SQL is a standardized programming language used for


managing and manipulating relational databases. It is essential
for various operations like querying data, updating records, and
managing database structures. SQL is widely used in both
industry and academia due to its ease of use and powerful
capabilities.
 Key Concepts of SQL:
 Database: A database is a collection of organized data that
can be easily accessed, managed, and updated. Relational
databases store data in tables, which are collections of related
data entries.
Table: A table is a collection of rows and columns in which

a
data is stored. Each row represents a record, and each column
represents a field in that record.
Query: A query is a request for data or information from a
database table or combination of tables. SQL queries are used
DATABASE DESIGN
1.First we have to create a
database.

4. Parking slots table.


2. We have to use the
database.

3. Creating table parking slots.

 ;;
5. Create Transaction
table.

6. Transaction
table.
7. Creating Feedback
table

8. Feedback table
SOURCE CODE
import mysql.connector
from datetime import datetime

def connect_to_db():
return mysql.connector.connect(
host="localhost",
user="root",
password="2404",
database="parking_management"
)

def create_tables():
db = connect_to_db()
cursor = db.cursor()

cursor.execute("""
CREATE TABLE IF NOT EXISTS ParkingSlots (
slot_id INT AUTO_INCREMENT PRIMARY KEY,
vehicle_number VARCHAR(20) UNIQUE,
vehicle_type VARCHAR(20),
is_parked BOOLEAN DEFAULT FALSE,
entry_time DATETIME,
exit_time DATETIME
);
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS Transactions (
transaction_id INT AUTO_INCREMENT PRIMARY KEY,
vehicle_number VARCHAR(20),
vehicle_type VARCHAR(20),
entry_time DATETIME,
exit_time DATETIME,
amount DECIMAL(10, 2),
FOREIGN KEY (vehicle_number) REFERENCES ParkingSlots(vehicle_number)
);
""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS Feedback (
feedback_id INT AUTO_INCREMENT PRIMARY KEY,
vehicle_number VARCHAR(20),
feedback_text TEXT,
submitted_at DATETIME,
FOREIGN KEY (vehicle_number) REFERENCES ParkingSlots(vehicle_number)
);
""")

db.commit()
cursor.close()
db.close()
def greet_user():
print("\nWelcome to the Parking Management System!")
print("How can we assist you today?\n")

def show_rate_chart():
print("\n--- Rate Chart ---")
print("Day Parking:")
print("Two Wheelers: Rs 5/hour")
print("Car/Van/Mini Bus: Rs 10/hour")
print("Bus/Lorry: Rs 20/hour")
print("\nNight Parking:")
print("Two Wheelers: Rs 10/hour")
print("Car/Van/Mini Bus: Rs 30/hour")
print("Bus/Lorry: Rs 60/hour")
print("------------------\n")

def calculate_parking_fee(vehicle_type, entry_time, exit_time):


entry_hour = entry_time.hour
exit_hour = exit_time.hour
is_day_time = 6 <= entry_hour < 18

if is_day_time:
rates = {
“Two Wheeler”:5,
“Car/van/Mini Bus”:10,
“Bus/Lorry”:20
}
else:
rates = {
"Two Wheeler": 10,
"Car/Van/Mini Bus": 30,
"Bus/Lorry": 60
}

time_spent = (exit_time - entry_time).total_seconds() / 3600


rate_per_hour = rates.get(vehicle_type, 0)
return round(time_spent * rate_per_hour, 2)

def reserve_slot(vehicle_number, vehicle_type):


db = connect_to_db()
cursor = db.cursor()

cursor.execute("SELECT is_parked FROM ParkingSlots WHERE vehicle_number = %s", (vehicle_number,))


result = cursor.fetchone()

if result and result[0]:


print("Vehicle is already parked.")
else:
entry_time = datetime.now().replace(second=0, microsecond=0)
if not result:
cursor.execute("INSERT INTO ParkingSlots (vehicle_number, vehicle_type, is_parked, entry_time) VALUES (%s, %s, %s, %s)",
(vehicle_number, vehicle_type, True, entry_time))
else:
cursor.execute("UPDATE ParkingSlots SET is_parked = %s, entry_time = %s WHERE vehicle_number = %s",
(True, entry_time, vehicle_number))
db.commit()
print(f"Slot reserved for vehicle {vehicle_number} at {entry_time}.")
cursor.close()
db.close()

def release_slot(vehicle_number):
db = connect_to_db()
cursor = db.cursor()

cursor.execute("SELECT entry_time, vehicle_type FROM ParkingSlots WHERE vehicle_number = %s AND is_parked = %s",
(vehicle_number, True))
result = cursor.fetchone()

if not result:
print("No vehicle found or vehicle is not currently parked.")
else:
entry_time, vehicle_type = result
exit_time = datetime.now().replace(second=0, microsecond=0)
amount = calculate_parking_fee(vehicle_type, entry_time, exit_time)

cursor.execute("UPDATE ParkingSlots SET is_parked = %s, exit_time = %s WHERE vehicle_number = %s",


(False, exit_time, vehicle_number))
cursor.execute("INSERT INTO Transactions (vehicle_number, vehicle_type, entry_time, exit_time, amount) VALUES (%s, %s, %s, %s,
%s)",
(vehicle_number, vehicle_type, entry_time, exit_time, amount))

db.commit()
print(f"Vehicle {vehicle_number} released. Amount due: Rs {amount}.\n")
print_receipt(vehicle_number, vehicle_type, entry_time, exit_time, amount)

cursor.close()
db.close()
def print_receipt(vehicle_number, vehicle_type, entry_time, exit_time, amount):
print("\n--- Parking Receipt ---")
print(f"| Vehicle Number: {vehicle_number:<15} |")
print(f"| Vehicle Type: {vehicle_type:<15} |")
print(f"| Entry Time: {entry_time:<15} |")
print(f"| Exit Time: {exit_time:<15} |")
print(f"| Total Amount: Rs {amount:<15} |")
print("-------------------------")
print("Thank you for using our service! Have a great day!\n")

def view_transactions():
db = connect_to_db()
cursor = db.cursor()

cursor.execute("SELECT * FROM Transactions")


transactions = cursor.fetchall()

print("\n--- Transaction History ---")


for transaction in transactions:
print(f"Transaction ID: {transaction[0]}, Vehicle: {transaction[1]}, Type: {transaction[2]}, Entry: {transaction[3]}, Exit: {transaction[4]},
Amount: Rs {transaction[5]}")

cursor.close()
db.close()
def collect_feedback(vehicle_number):
feedback = input("Please provide your feedback: ")
submitted_at = datetime.now().replace(second=0, microsecond=0)

db = connect_to_db()
cursor = db.cursor()

cursor.execute("INSERT INTO Feedback (vehicle_number, feedback_text, submitted_at) VALUES (%s, %s, %s)",
(vehicle_number, feedback, submitted_at))
db.commit()
cursor.close()
db.close()

print("Thank you for your feedback!")

def view_feedback():
db = connect_to_db()
cursor = db.cursor()

cursor.execute("SELECT * FROM Feedback")


feedbacks = cursor.fetchall()

print("\n--- User Feedback ---")


for feedback in feedbacks:
print(f"Feedback ID: {feedback[0]}, Vehicle: {feedback[1]}, Feedback: {feedback[2]}, Submitted At: {feedback[3]}")

cursor.close()
db.close()
def collect_feedback(vehicle_number):
feedback = input("Please provide your feedback: ")
submitted_at = datetime.now().replace(second=0, microsecond=0)

db = connect_to_db()
cursor = db.cursor()

cursor.execute("INSERT INTO Feedback (vehicle_number, feedback_text, submitted_at) VALUES (%s, %s, %s)",
(vehicle_number, feedback, submitted_at))
db.commit()
cursor.close()
db.close()

print("Thank you for your feedback!")

def view_feedback():
db = connect_to_db()
cursor = db.cursor()

cursor.execute("SELECT * FROM Feedback")


feedbacks = cursor.fetchall()

print("\n--- User Feedback ---")


for feedback in feedbacks:
print(f"Feedback ID: {feedback[0]}, Vehicle: {feedback[1]}, Feedback: {feedback[2]}, Submitted At: {feedback[3]}")

cursor.close()
db.close()
def main():
create_tables()
greet_user()

while True:
print("1. Reserve Parking Slot")
print("2. Release Parking Slot")
print("3. View Transactions")
print("4. Provide Feedback")
print("5. View Feedback")
print("6. Exit")

choice = input("Enter your choice: ")

if choice == "1":
vehicle_number = input("Enter vehicle number: ")
vehicle_type = input("Enter vehicle type (Two Wheeler/Car/Van/Mini Bus/Bus/Lorry): ")
reserve_slot(vehicle_number, vehicle_type)
elif choice == "2":
vehicle_number = input("Enter vehicle number: ")
release_slot(vehicle_number)
elif choice == "3":
view_transactions()
elif choice == "4":
vehicle_number = input("Enter your vehicle number: ")
collect_feedback(vehicle_number)
elif choice == "5":
view_feedback()
elif choice == "6":
print("Thank you for using the Parking Mangement system. Goodbye!")
break
else:
print("Invalid choice. Please try again")
OUTPUT
Main Menu To park vehicle
To unpark vehicle
To view transaction
To give feedback
To view feedback
Exit
BIBLIOGRAPHY
 Python (Sumita Arora Class XII)
 MySQL
THANK YOU

You might also like