MySQL + SQL · Lesson 120

Student Marksheet Database Project

About

A Marksheet database stores students, subjects and their marks, then generates result reports.

Schema

CREATE TABLE students (roll_no INT PRIMARY KEY, name VARCHAR(50));
CREATE TABLE marks (roll_no INT, subject VARCHAR(20), score INT,
  PRIMARY KEY(roll_no, subject),
  FOREIGN KEY(roll_no) REFERENCES students(roll_no));

Result Query

SELECT s.name, SUM(m.score) AS total, ROUND(AVG(m.score),1) AS pct
FROM students s JOIN marks m ON s.roll_no=m.roll_no
GROUP BY s.name;

Summary

  • marks uses a composite key (roll_no + subject).
  • JOIN + GROUP BY produces each student's total and percentage.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp