Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. array or new table for every user , which one ?

array or new table for every user , which one ?

Scheduled Pinned Locked Moved Database
questiondatabasesysadmindata-structureshelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kozmikadam
    wrote on last edited by
    #1

    Hi everybody. I have a problem. I am trying to make a little social network. Users can add other users to own people list. So what should i do ? Should i create a new table for every user? ( for example 2000 table for 2000 users ) or should i create an array for every user ? After i can save the array to the database. or any other way ? whick way is the best ? İf array is the best , how can i do it ? first user have 2 friends , second user have 19 friend. array size is different. So what should i do ?

    W 1 Reply Last reply
    0
    • K kozmikadam

      Hi everybody. I have a problem. I am trying to make a little social network. Users can add other users to own people list. So what should i do ? Should i create a new table for every user? ( for example 2000 table for 2000 users ) or should i create an array for every user ? After i can save the array to the database. or any other way ? whick way is the best ? İf array is the best , how can i do it ? first user have 2 friends , second user have 19 friend. array size is different. So what should i do ?

      W Offline
      W Offline
      Wayne Gaylard
      wrote on last edited by
      #2

      This is a classic case of a Many to Many relationship and what you need to do is create a linking table. You have the original Users table with each user having a unique id UserID. Then you have another table call it Friends with only 2 fields UserID and FriendID. Each time a user adds a friend, you just add a row to the linking table, using the UserID of the Friend as the FriendID in the friends table, and if they remove the friend, you just drop the row. Hope this makes sense.

      When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

      K 1 Reply Last reply
      0
      • W Wayne Gaylard

        This is a classic case of a Many to Many relationship and what you need to do is create a linking table. You have the original Users table with each user having a unique id UserID. Then you have another table call it Friends with only 2 fields UserID and FriendID. Each time a user adds a friend, you just add a row to the linking table, using the UserID of the Friend as the FriendID in the friends table, and if they remove the friend, you just drop the row. Hope this makes sense.

        When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

        K Offline
        K Offline
        kozmikadam
        wrote on last edited by
        #3

        this could work ! Thank you !

        W L 2 Replies Last reply
        0
        • K kozmikadam

          this could work ! Thank you !

          W Offline
          W Offline
          Wayne Gaylard
          wrote on last edited by
          #4

          Glad to help :thumbsup:

          When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

          1 Reply Last reply
          0
          • K kozmikadam

            this could work ! Thank you !

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            chuckcan08 wrote:

            this could will work

            FTFY :-)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups