Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devalienbrain/postgresql-university-database-management
https://github.com/devalienbrain/postgresql-university-database-management
postgresql
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/devalienbrain/postgresql-university-database-management
- Owner: devalienbrain
- Created: 2024-10-27T19:50:10.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-28T04:13:16.000Z (2 months ago)
- Last Synced: 2024-11-05T13:34:23.639Z (2 months ago)
- Topics: postgresql
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project (PostgreSQL)
**Project Description**
In this project, I worked with PostgreSQL, a powerful open-source relational database management system. My task involves creating 03 tables based on the provided sample data and then writing and executing queries to perform various database operations such as creating, reading, updating, and deleting data. Additionally, I explored the concepts like LIMIT and OFFSET, JOIN operations, GROUP BY, aggregation, and LIKE.---
**Guidelines:**
1. **Database Setup:**
- Install PostgreSQL on your system if not already installed.
- Create a fresh database titled "university_db" or any other appropriate name.2. **Table Creation:**
**Create a "students" table with the following fields:**
- `student_id (Primary Key)`: Integer, unique identifier for students.
- `student_name`: String, representing the student's name.
- `age`: Integer, indicating the student's age.
- `email`: String, storing the student's email address.
- `frontend_mark`: Integer, indicating the student's frontend assignment marks.
- `backend_mark`: Integer, indicating the student's backend assignment marks.
- `status`: String, storing the student's result status.**Create a "courses" table with the following fields:**
- `course_id (Primary Key)`: Integer, unique identifier for courses.
- `course_name`: String, indicating the course's name.
- `credits`: Integer, signifying the number of credits for the course.**Create an "enrollment" table with the following fields:**
- `enrollment_id (Primary Key)`: Integer, unique identifier for enrollments.
- `student_id (Foreign Key)`: Integer, referencing `student_id` in the "Students" table.
- `course_id (Foreign Key)`: Integer, referencing `course_id` in the "Courses" table.---
### Sample Data
**Insert the following sample data into the "students" table:**
| student_id | student_name | age | email | frontend_mark | backend_mark | status |
| ---------- | ------------ | --- | ------------------ | ------------- | ------------ | ------ |
| 1 | Sameer | 21 | [email protected] | 48 | 60 | NULL |
| 2 | Zoya | 23 | [email protected] | 52 | 58 | NULL |
| 3 | Nabil | 22 | [email protected] | 37 | 46 | NULL |
| 4 | Rafi | 24 | [email protected] | 41 | 40 | NULL |
| 5 | Sophia | 22 | [email protected] | 50 | 52 | NULL |
| 6 | Hasan | 23 | [email protected] | 43 | 39 | NULL |**Insert the following sample data into the "courses" table:**
| course_id | course_name | credits |
| --------- | ----------- | ------- |
| 1 | Next.js | 3 |
| 2 | React.js | 4 |
| 3 | Databases | 3 |
| 4 | Prisma | 3 |**Insert the following sample data into the "enrollment" table:**
| enrollment_id | student_id | course_id |
| ------------- | ---------- | --------- |
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 3 | 2 | 1 |
| 4 | 3 | 2 |---
### Run SQL queries to complete the following tasks:
#### Query 1:
Insert a new student record with the following details:
- Name: YourName
- Age: YourAge
- Email: YourEmail
- Frontend-Mark: YourMark
- Backend-Mark: YourMark
- Status: NULL**Note:** I choosed random values for the frontend_mark, backend_mark, and other fields (except NULL for the status).
#### Query 2:
Retrieve the names of all students who are enrolled in the course titled 'Next.js'.
**Sample Output:**
| student_name |
| ------------ |
| Sameer |
| Zoya |#### Query 3:
Update the status of the student with the highest total (`frontend_mark + backend_mark`) to 'Awarded'.
#### Query 4:
Delete all courses that have no students enrolled.
#### Query 5:
Retrieve the names of students using a limit of 2, starting from the 3rd student.
**Sample Output:**
| student_name |
| ------------ |
| Nabil |
| Rafi |#### Query 6:
Retrieve the course names and the number of students enrolled in each course.
**Sample Output:**
| course_name | students_enrolled |
| ----------- | ----------------- |
| Next.js | 2 |
| React.js | 2 |#### Query 7:
Calculate and display the average age of all students.
**Sample Output:**
| average_age |
| ----------- |
| 22.33 |#### Query 8:
Retrieve the names of students whose email addresses contain 'example.com'.
**Sample Output:**
| student_name |
| ------------ |
| Sameer |
| Zoya |
| Nabil |
| Rafi |
| Sophia |---
### Prepared the SQL code for table creation, sample data insertion, and the eight queries in a text document or my preferred format. Include comments explaining each query's purpose and functionality. Saved my document as "PostgreSQL_uni_db_manage.sql".
---