Please,help to set the relational notations in database table.Would much appreceate the help. database.png

Recommended Answers

All 4 Replies

Member Avatar

Providing you with answers to homework (if that's what it is), will not help you. Helping you understand relationships may.

For example:


One-to-one may be useful if you had some sort of optional profile table separate from a your user table. That is, the user can only have ONE profile and eaach rofile can only be attributed to ONE user.

USERS: id | username | pw | email
PROFILES: id | uid | firstname | surname | gender | ...

One-to-many could be where a single user has a number of entries in a related table, such as forum posts. So each user could have MANY posts, but each post could only have ONE user:

POSTS: id | uid | title | body | ...

Many-to-many could be where a number of users could have a number of different classes that they attend. Here you'd need some sort of link table to link both tables. So each user could take MANY classes, and each class could have MANY users.

CLASSES: id | classname | description

USER_CLASSES: uid | cid

This link table does not really need to have a separate PK. If you wanted, you could make a composite PK out of both "foreign keys" (uid and cid). In some instances a separate PK may be useful, but not as a general rule.

commented: +1 good answer +13

First,it is not a home work.
Second i started to learn php and need help to show me by someone ,how it works.
Third ,if it was a home work i would not ask sucha questions on a forum and researched myself.
And finaly the answer is to mean and flawed.And it is not helpull at
all ,as for beginner. I asked for help,not for beeing smart,with comments,like home work.Once again it is for myself,for learning.If you so mean,why does this forum exists at all.Very bad comments. -1 for you.

Lighten up. diafol did not out-and-out accuse you of asking us to do your homework. What he did do was take the time to provide information on table relationships, something which you would find useful considering that you do not seem to understand them.

On a related note, having a table with the fields


is not going to be much use unless you can relate them to other tables. In any case, you are probably better off storing those values diirectly in whatever table they are to be associated with unless those values relate to creation/modification date/times of entire tables rather than individual records in which case you should have another column which will identify the table.

Member Avatar

First,it is not a home work...

I'm very sorry you feel this way PS. I mentioned the "homework" thing as from your OP, it sounded like a "gimme" post, as in: "I want somebody to do this for me". Although this is a help forum, we are not here at your beck and call to provide answers to your "demands". We are all volunteers and provide support in the best way that we see fit. In my case, as an ex-teacher of 20 years, I have found that students learn best if they do the work themselves rather than be given everything on a plate, hence my explanation, which took longer to provide than it would have to do the work for you.

I will note your username and ensure that I don't upset you further by trying to help you with your posts in future. I will leave you in the very capable hands of other contributors to this thread. Best wishes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.