If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > database design and security help - beginner...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-23-03, 17:29
noamkrief noamkrief is offline
Registered User
 
Join Date: Dec 2003
Posts: 61
database design and security help - beginner...

i'm trying to create a website (as a learning experience) that a user can record his contacts, friedns, family, phone numbers etc...

I have some question on the tables and how this will work.

my MAIN table will have the following fields:

entry_id (primary key, auto numbering)
person_id (foregin key to the PERSON TABLE)
ConactFullName
ContactPhone
ContactEmail


Then i will have another table called PERSON

person_id (primary key, auto numbering)
username
password


1) how do i link the person_id fields in both tables in mysql or myphpadmin?

2) This mysql database will include every user's data. How do i make it so that a user can only see entries that have his person_id in the MAIN table?

3) How do I make it so when a user adds his/her own entry, it automatically adds his/her own person_id number to the person_id field?

Thanks very much in advance
Noam
Reply With Quote
  #2 (permalink)  
Old 12-23-03, 20:28
pearl2 pearl2 is offline
Registered User
 
Join Date: Nov 2003
Location: Sinapore
Posts: 187
1) how do i link the person_id fields in both tables in mysql or myphpadmin?

something like:

SELECT * FROM MAIN, PERSON WHERE MAIN.person_id=PERSON.person_id

2) How do i make it so that a user can only see entries that have his person_id in the MAIN table?

(assuming the person's id is 23)

SELECT * FROM MAIN WHERE person_id=23


I'm a new to MySQL so I'm not qualified to give advice But I thought I would just try it anyany
Reply With Quote
  #3 (permalink)  
Old 12-23-03, 23:20
noamkrief noamkrief is offline
Registered User
 
Join Date: Dec 2003
Posts: 61
so if understand correctly, to make a relation between tables, i do it trough queries?

That's not like MS access where you creat relationships even before you create a query.

Noam
Reply With Quote
  #4 (permalink)  
Old 12-24-03, 00:58
pearl2 pearl2 is offline
Registered User
 
Join Date: Nov 2003
Location: Sinapore
Posts: 187
[quote
MAIN
entry_id (primary key, auto numbering)
person_id (foregin key to the PERSON TABLE)
ConactFullName
ContactPhone
ContactEmail


PERSON
person_id (primary key, auto numbering)
username
password
[/code]
You're already establishing a relationship between MAIN and PERSON by linking the two up with person_id i.e. in your database tables above, persion_id is primary key in PERSON and a foriegn key in MAIN. As a result, the two tables are related via person_id. A possible query as a result of that relation is:

SELECT username, ContactEmail FROM MAIN, PERSON WHERE MAIN.person_id=PERSON.person_id

May the expects here can correct me
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On