Database schema:
CREATE TABLE Students (
  student_id NUMBER PRIMARY KEY,
  bio_data TEXT,
  student_details TEXT
);
CREATE TABLE Transcripts (
  transcript_id NUMBER PRIMARY KEY,
  student_id NUMBER,
  date_of_transcript TIME,
  transcript_details TEXT,
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Behaviour_Monitoring (
  behaviour_monitoring_id NUMBER PRIMARY KEY,
  student_id NUMBER,
  behaviour_monitoring_details TEXT,
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Addresses (
  address_id NUMBER PRIMARY KEY,
  address_details TEXT
);
CREATE TABLE Ref_Event_Types (
  event_type_code TEXT PRIMARY KEY,
  event_type_description TEXT
);
CREATE TABLE Ref_Achievement_Type (
  achievement_type_code TEXT PRIMARY KEY,
  achievement_type_description TEXT
);
CREATE TABLE Ref_Address_Types (
  address_type_code TEXT PRIMARY KEY,
  address_type_description TEXT
);
CREATE TABLE Ref_Detention_Type (
  detention_type_code TEXT PRIMARY KEY,
  detention_type_description TEXT
);
CREATE TABLE Student_Events (
  event_id NUMBER PRIMARY KEY,
  event_type_code TEXT,
  student_id NUMBER,
  event_date TIME,
  other_details TEXT,
  FOREIGN KEY (event_type_code) REFERENCES Ref_Event_Types(event_type_code),
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Teachers (
  teacher_id NUMBER PRIMARY KEY,
  teacher_details TEXT
);
CREATE TABLE Student_Loans (
  student_loan_id NUMBER PRIMARY KEY,
  student_id NUMBER,
  date_of_loan TIME,
  amount_of_loan NUMBER,
  other_details TEXT,
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Classes (
  class_id NUMBER PRIMARY KEY,
  student_id NUMBER,
  teacher_id NUMBER,
  class_details TEXT,
  FOREIGN KEY (teacher_id) REFERENCES Teachers(teacher_id),
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Students_Addresses (
  student_address_id NUMBER PRIMARY KEY,
  address_id NUMBER,
  address_type_code TEXT,
  student_id NUMBER,
  date_from TIME,
  date_to TIME,
  FOREIGN KEY (address_type_code) REFERENCES Ref_Address_Types(address_type_code),
  FOREIGN KEY (address_id) REFERENCES Addresses(address_id),
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Detention (
  detention_id NUMBER PRIMARY KEY,
  detention_type_code TEXT,
  student_id NUMBER,
  datetime_detention_start TIME,
  datetime_detention_end TIME,
  detention_summary TEXT,
  other_details TEXT,
  FOREIGN KEY (detention_type_code) REFERENCES Ref_Detention_Type(detention_type_code),
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
CREATE TABLE Achievements (
  achievement_id NUMBER PRIMARY KEY,
  achievement_type_code TEXT,
  student_id NUMBER,
  date_achievement TIME,
  achievement_details TEXT,
  other_details TEXT,
  FOREIGN KEY (achievement_type_code) REFERENCES Ref_Achievement_Type(achievement_type_code),
  FOREIGN KEY (student_id) REFERENCES Students(student_id)
);

Question: List the biographical data and student id for the students who take 2 or more classes and the students who have less than 2 detentions.
SQL: SELECT T1.bio_data ,  T1.student_id FROM Students AS T1 JOIN Classes AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING count(*)  >=  2 UNION SELECT T1.bio_data ,  T1.student_id FROM Students AS T1 JOIN Detention AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING count(*)  <  2

Question: Which students never had a detention or student loan ? Find their biographical data .
SQL: select bio_data from students where student_id not in (select t1.student_id from students as t1 join detention as t2 on t1.student_id  =  t2.student_id union select t1.student_id from students as t1 join student_loans as t2 on t1.student_id  =  t2.student_id)

Question: List the start time and the end time of the students' addresses for the students who have 2 transcripts.
SQL: SELECT date_from ,  date_to FROM Students_Addresses WHERE student_id IN ( SELECT student_id FROM Transcripts GROUP BY student_id HAVING count(*)  =  2 )

Question: Which students have gone through any event? List the students' biographical data and event date.
SQL: SELECT T1.bio_data ,  T2.event_date FROM Students AS T1 JOIN Student_Events AS T2 ON T1.student_id  =  T2.student_id

Question: List the biographical data of the students who never had a detention or student loan .
SQL: select bio_data from students where student_id not in (select t1.student_id from students as t1 join detention as t2 on t1.student_id  =  t2.student_id union select t1.student_id from students as t1 join student_loans as t2 on t1.student_id  =  t2.student_id)

Question: What are the biographical data and student id of the students who either took two or more classes and or have less than two detentions?
SQL: SELECT T1.bio_data ,  T1.student_id FROM Students AS T1 JOIN Classes AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING count(*)  >=  2 UNION SELECT T1.bio_data ,  T1.student_id FROM Students AS T1 JOIN Detention AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING count(*)  <  2

Question: How many students got the most common result in the behavioral monitoring details? Also list the result details.
SQL: SELECT count(DISTINCT student_id) ,  behaviour_monitoring_details FROM Behaviour_Monitoring GROUP BY behaviour_monitoring_details ORDER BY count(*) DESC LIMIT 1

Question: Give me the detention start date for all the detention records.
SQL: SELECT datetime_detention_start FROM Detention

Question: When did all the detentions start?
SQL: SELECT datetime_detention_start FROM Detention

Question: For those students who have gone through an event, who do not have a student loan? List the students' biographical data
SQL: SELECT T1.bio_data FROM Students AS T1 JOIN Student_Events AS T2 WHERE T1.student_id  =  T2.student_id EXCEPT SELECT T1.bio_data FROM Students AS T1 JOIN Student_Loans AS T2 WHERE T1.student_id  =  T2.student_id

Question: List the date of the transcripts and the transcript details.
SQL: SELECT date_of_transcript ,  transcript_details FROM Transcripts

Question: Count the number of teachers who have taught students who have never won an achievement.
SQL: SELECT count(DISTINCT T1.teacher_id) FROM Teachers AS T1 JOIN Classes AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T2.student_id NOT IN ( SELECT student_id FROM Achievements )

Question: Which teachers teach a class that has the substring 'data' in its detail but do not teach a class that has prefix 'net' in its detail? Give me the teacher details.
SQL: SELECT T1.teacher_details FROM Teachers AS T1 JOIN Classes AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T2.class_details LIKE '%data%' EXCEPT SELECT T1.teacher_details FROM Teachers AS T1 JOIN Classes AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T2.class_details LIKE 'net%'

Question: For each student, find the student id and the total amount of loan he or she has.
SQL: SELECT student_id ,  sum(amount_of_loan) FROM Student_Loans GROUP BY student_id

Question: List the personal details and the address type descriptions of all the students.
SQL: SELECT DISTINCT T1.student_details ,  T3.address_type_description FROM Students AS T1 JOIN Students_Addresses AS T2 ON T1.student_id  =  T2.student_id JOIN Ref_Address_Types AS T3 ON T2.address_type_code  =  T3.address_type_code

Question: What are the distinct descriptions of all the detentions which have ever happened?
SQL: SELECT distinct(T1.detention_type_description) FROM Ref_Detention_Type AS T1 JOIN Detention AS T2 ON T1.detention_type_code  =  T2.detention_type_code

Question: List the achievement type code, achievement details and the date of the achievements.
SQL: SELECT achievement_type_code ,  achievement_details ,  date_achievement FROM Achievements