Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    61

    Unanswered: 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

  2. #2
    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

  3. #3
    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

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •