Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:49:35+00:00 2026-06-07T00:49:35+00:00

My system uses a table of users with several elements including their online status.

  • 0

My system uses a table of users with several elements including their online status. Now I would like to add a feature so each user can add a contact i.e an existing user from the database into their list of friends or contacts showing their name and online status. However I need any changes in the online status to updated on the contact list as they happen so creating a new table wouldn’t help.

I have been looking into views for this but don’t have too much experience with databases to I would like to know if this is the correct way of going about it and a bit more detail on how to do it.

Here are the steps I was thinking of:

  1. When users registers, create a view i.e view_name = username_view.
  2. To add a contact select data from main users table and add to user’s view
  3. To delete a contact delete selected data from view.

I am not sure if this is possible with views so if it isn’t can some please help me out.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:49:37+00:00Added an answer on June 7, 2026 at 12:49 am

    ER databases = Entites and Relations databases handle that by have one table whit the entites “users”, and one table for the relationship “friends” that connect a user to another user.

    a query for that can be:

    SELECT users.* 
    FROM friends 
    LEFT JOIN users ON (users.user_id = friends.friend_id) 
    WHERE friends.user_id = :user
    

    Exemple:

    a user table, for the entity user

    CREATE TABLE user (user_id SERIAL, name TINYTEXT NOT NULL);
    

    exemple users

    user_id | name
          1 | Anna
          2 | Bertil
          3 | Carl
          4 | David
          5 | Erik
    

    a friends tabel, for relations between two users, (not one per user, just one)

    CREATE TABLE friends (
      user_id BIGINT UNSIGNED NOT NULL,
      friend_id BIGINT UNSIGNED NOT NULL,
      PRIMARY KEY (user_id, friend_id)
    );
    

    if Anna adds Beril and Carl as friends, and Carl adds David and Erik as friends, the content of the table going to be:

    user_id | friend_id
          1 |         2
          1 |         3
          3 |         4
          3 |         5
    

    if we want to list the names of Annas friends, and we allredy know that Annas user_id = 1, then we can use this query (like the one above)

    SELECT users.name 
    FROM friends 
    LEFT JOIN users ON (users.user_id = friends.friend_id) 
    WHERE friends.user_id = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have content management system application that uses a polymorphic tree table as the
I'm using this table structure for a 'toxi' like TAGs system table TAGS +--------+-------------------+
I have a simple messaging system that up till now uses file based storage.
I am building a friendship system in CakePHP that uses two tables: Users and
I just discovered ASP.net uses its own profile system to register users and there
Our system uses an Entity Framework based data layer. For the recent months, we've
Our system uses a lot of large Bitmaps (System.Drawing.Bitmap) and sometimes we run out
I've built a system that uses underscore-js to render templates, and it works fine
Can I combine code that uses System.Drawing.Bitmap together with other code in a program
I am coding a fairly complex system that uses a lot of metadata to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.