Reputation: 976
I want to create MySQL table to manage registration of students.
the name of the table its the course name and inside of it there is the first column : student_id
and after that i want column for each date in the semester that course takes place.
so for example if course takes place every sunday and monday between 1st to 9th of March than i will have column's like this: |01/03/2016|02/03/2016|08/03/2016|09/03/2016
i'm taking first steps with MySQL and got to hear about PROCEDURE
but not sure if that's what i need or there's a better way to achieve that
Upvotes: 0
Views: 63
Reputation: 7808
This does not sound like a good way to structure your database...
The "best" way to represent your data in a relational database depends on your specific use-cases (as well as potential future use-cases), but the structure you describe, while technically feasible, would probably not be a good foundation. Also, I don't see how PROCEDURE is related (it's used for creating stored procedures which is a pretty advanced topic in itself).
I recommend that you read some general tutorial on SQL and on relational data modeling.
One structure I can suggest, without knowing a lot about your requirements, but that would be more in line with SQL best practices is:
TABLE: student
COLUMNS: id, name
TABLE: course
COLUMNS: id, name
TABLE: course_date
COLUMNS: id, course_id, date
TABLE: course_student
COLUMNS: id, course_id, student_id
You can then use SQL join queries to get whatever data you need from that structure.
Upvotes: 1