Forum Moderators: coopster

Message Too Old, No Replies

linked mySQL tables

I have different sets of data that needs to be stored in multiple tables

         

amdorsey

4:38 am on Apr 6, 2004 (gmt 0)

10+ Year Member



I am putting together a Help Desk Automated System. I need to sore different sets of relative data to a user but retrievable based on there Session ID (there account number)
(e.g. user info, user posts, user contacts, etc)

So I am guessing I need 'linked' tables in mySQL. Not sure how to do that. I already have one table set up with login info, and user authentication, carrying the Session ID throughout each section. Instead of re-doing any work done (many hours) I would just like to add smaller tables from time to time, easily, but all accessed bu the 'user' based on there Session ID.

Any thoughts?
Please...I am on a tight deadline, and not sure what to do.

barn_de

7:56 am on Apr 6, 2004 (gmt 0)

10+ Year Member



Hi amdorsey,

i'm not sure, if i got your problem right, but i try to answer to what i understood.

you're talking about "linked mysql tables". i would guess, that you mean normalization. to normalize the db means to not have duplicate (unnecessary) informations stored.

for your example (user info and user posts) i would generate following tables:

1. table_user
here i would store all user related infos like user_id, email, pw, address

2. table_user_posts
columns like post_id, user_id, post_text, post_date
user_id in this table refers to the user_id in table_user.

i hope this is what your problem was about. otherwise just post a bit more infos.

barn

ukgimp

8:02 am on Apr 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I dont know how savvy you are with relational db theory. But it wont harm if you do a little background study.

[hk8.org...]
[onlamp.com...]

Think of the books and Authors situation. Think simply that, books can only have one author.

"BOOKS"
book_id (auto number) PK
book_name
book_description
author_id (FK)

"AUTHORS"
author_id (auto number) PK
author_name
author_address

PK = primary key
FK = foreign key

Now the FK links the tables. So now if you want all the books by a certain author (author No 30 for example) you can use a simple sql query

SELECT book_name
FROM books
WHERE author_id = 30

Anyhow that's how you relate simple tables.