T
T
turbo_exe2010-10-19 22:20:32
MySQL
turbo_exe, 2010-10-19 22:20:32

What is the best way to design a database?

I'm making a small site for several groups at the university. a page with a schedule, a file archive, and other joys. There was a question about the daily schedule. on the page of each group will hang its schedule for tomorrow (if desired - for any day). at the moment, there are two tables, but they are not related to each other in any way:

subjects (list of subjects)
subjId (unique number of the subject)
subjName (full name of the subject)

groups (list of groups)
groupId (unique number of the subject)
subjName (group name )

it is necessary to match each individual group with a list of items for Monday\Tuesday\etc...
knowledge of php and mysql - at the initial level. therefore, I wanted to ask the guru how to design the database more successfully.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexey Zhurbitsky, 2010-10-19
@turbo_exe

well, nothing complicated, the table will be something like this:
timetable{
subjId int
groupId int
day int
startTime time
}
daily schedule for the group:
select * from timetable,subjects where timetable.subjId=subjects.subjId and groupId= and day= order by startTime ;

K
keatis, 2010-10-19
@keatis

What about even/odd weeks? Well, not right now - then they will appear.
What about the audience number? And the full name of the teacher ... After all, this add. there is already enough information to get a 4 on the exam in the subject. :)

P
phasma, 2010-10-19
@phasma

do one-to-many in a table with groups.

K
keatis, 2010-10-20
@keatis

Google about the ER-model (entity-relationship model), just your case. You can read more about normalization if you master the terms from the first run ...
You can google something more specific, for example, this (there, however, is an access, but you can look at pictures with the model).

A
Anton, 2010-10-20
@conturov

We don't touch groups. A group can have multiple items. Let's make a table:
id (unique number)
id_group (group)
id_subjects (subject)
id_day (day of the week)
There may be other fields like lower/upper week.
To add an item to a group, add the necessary data to the table. The selection is simple, we select everything for the desired date for the desired group. Or we select everything by the desired date and make a schedule for all groups for this day of the week.

A
afiskon, 2014-03-13
@afiskon

Better late than never :) eax.me/database-design

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question