MySQL + SQL · Lesson 116

School Database Case Study

इस Project के बारे में

students, classes और fees के साथ एक पूरा School database case study — इस tutorial में इस्तेमाल होने वाला running example।

Database Schema

CREATE TABLE classes (class_id INT PRIMARY KEY, class_name VARCHAR(20));
CREATE TABLE students (roll_no INT PRIMARY KEY, name VARCHAR(50), class_id INT, marks INT,
  FOREIGN KEY(class_id) REFERENCES classes(class_id));
CREATE TABLE fees (fee_id INT PRIMARY KEY, roll_no INT, amount DECIMAL(8,2), paid_on DATE,
  FOREIGN KEY(roll_no) REFERENCES students(roll_no));

उपयोगी Queries

-- हर class का topper
SELECT class_id, name, marks FROM students s1
WHERE marks = (SELECT MAX(marks) FROM students s2 WHERE s2.class_id=s1.class_id);

-- हर class में collect हुई कुल fee
SELECT c.class_name, SUM(f.amount) AS collected
FROM fees f JOIN students s ON f.roll_no=s.roll_no
           JOIN classes c ON s.class_id=c.class_id
GROUP BY c.class_name;

सारांश

  • यह project एक real, exam-ready database design working queries के साथ दिखाता है।
  • Tables बनाएं, sample data डालें, और हर query चलाकर करके सीखें।
🔗

Share this topic with a friend

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

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

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

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.