Reputation: 19
I'm developing a website that has some audio courses, each course can have multiple lessons. I want to display each course in its own table containing its different lessons.
What kind of a database should I make?
Example as a static website:
<p><span class="heading1">Course 1 - Speaker 1</span> </p>
<p><span class="date">Posted in <a href="Audio.html">TAG 1</a>, december 12, 2010</span></p>
<class id="text">
<p>Info: blablabla</p>
<p> </p>
<table border: none cellpadding="1" cellspacing="1">
<tr>
<th scope="col">Nr.</th>
<th scope="col">Lesson</th>
<th scope="col">Date </th>
<th scope="col">Download</th>
</tr>
<tr>
<td scope="row">1</td>
<td>blablabla</td>
<td>22/12/2010</td>
<td><a href="">MP3</a></td>
</tr>
<tr>
<td bgcolor="#D6D6D6" scope="row">2</td>
<td>blablabla</td>
<td>22/12/2010</td>
<td><a href="">MP3</a></td>
</tr>
</table>
Course 2 - Speaker 2
<p><span class="date">Posted in <a href="audio.html">TAG 2</a>, december 12, 2010</span></p>
<class id="text">
<p>Info: blablabla</p>
<table border: none cellpadding="1" cellspacing="1">
<tr>
<th scope="col">Nr.</th>
<th scope="col">Lesson</th>
<th scope="col">Date</th>
<th scope="col">Download</th>
</tr>
<tr>
<td scope="row">1</td>
<td>blablabla</td>
<td>06/12/2010</td>
<td><a href="01.mp3">MP3</a></td>
</tr>
<tr>
<td scope="row">2</td>
<td>blablabla</td>
<td>13/12/2010</td>
<td><a href="02.mp3">MP3</a></td>
</tr>
</table>
Upvotes: 0
Views: 382
Reputation: 21466
Table: courses
id
title
Table: lessons
id
cid (course id)
title
date
file
Sample SQL:
SELECT
lessons.*,
courses.title AS course
FROM
lessons
INNER JOIN
courses
ON
courses.id = lessons.cid
GROUP BY
lessons.id
ORDER BY
lessons.date
I figure you could easily just use an auto-incrementing variable for the lesson number, as you output the table. However, if there are actually specific lesson numbers, you may want to add it as a field to the database.
You may also want to add additional order by arguments.
Upvotes: 2