Database Plan

Results 1 to 8 of 8

Thread: Database Plan

  1. #1
    Join Date
    Dec 1969
    Posts
    666

    Default Database Plan

    Hi There.<BR><BR>First of it all I would like to thank you for the last time you guys helped me. I can&#039;t find the thread so I&#039;m doing it here.<BR><BR>Last time, Bill mentioned that a lot of programmer don&#039;t plan their database deisgn right so I though I&#039;ll give you my plan and it&#039;ll be great i you can give me a feedback or two.<BR><BR>I have a few tables:<BR>useres_table<BR> id<BR> full name<BR> age<BR> username<BR> password<BR> date & time<BR> ip address<BR><BR>posts_table<BR> id<BR> user_id<BR> subject<BR> city<BR> date<BR> comments<BR> price<BR><BR>cities_table<BR> id<BR> city<BR><BR>How does it sound?<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969
    Posts
    18,177

    Default Well, it's a database.

    What are you trying to solve with your database design?<BR><BR>What type of data do you need to store?

  3. #3
    Join Date
    Dec 1969
    Posts
    96,118

    Default Why city in the posts table???

    Isn&#039;t the city associated with the user, instead of with the post??? And why a PRICE in a posts_table??<BR><BR>One thing I would change: Use the SAME NAME for the PK/FK fields in multiple tables. So I&#039;d do<BR> users_table<BR> user_id : PK<BR><BR> posts_table<BR> post_id : PK<BR> ...<BR> city_id : FK<BR><BR> cities_table<BR> city_id : PK<BR><BR>If you do this, then Access (and other DB tools) will help you create your queries, by *assuming* that like-named fields describe a PK/FK relationship.

  4. #4
    Join Date
    Dec 1969
    Posts
    11,247

    Default RE: Database Plan

    Id also change the Age field to Date_of_Birth too!<BR><BR>ohhh remember password, datetime, date are all reserved words when making your column names


  5. #5
    Join Date
    Dec 1969
    Posts
    666

    Default RE: Well, it's a database.

    It&#039;s suppose to be some kind of a date application for certain people. Users can can post an ad and ask who wanna get togeather and when.<BR><BR>I&#039;m going to store text only. That&#039;s what you meant?

  6. #6
    Join Date
    Dec 1969
    Posts
    666

    Default RE: Why city in the posts table???

    The city is associated with the user but maybe I&#039;m living in a certain city but I don&#039;t mind to meet YOU in a different one. <BR><BR>The city on the post is the city where one would like to meet.<BR><BR>The price is there &#039;cause some people would like to charge (kind of a teaching thing) a certain amount for their time.<BR><BR>What is FK?

  7. #7
    Join Date
    Dec 1969
    Posts
    666

    Default RE: Database Plan

    Got it, Thanks!

  8. #8
    Join Date
    Dec 1969
    Posts
    96,118

    Default FK=Foreign Key

    PK=Primary Key<BR><BR>Normally, you enforce relationship constraints via PK/FK joins, etc. (But you *can* JOIN in SQL on fields other than the PK/FK ones.)<BR><BR>

Posting Permissions

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