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 8384559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:26:00+00:00 2026-06-09T17:26:00+00:00

I have to implement the tasks below: Task: At present, the database knows two

  • 0

I have to implement the tasks below:
Task:
At present, the database knows two types of messages:

  • Messages that a user posts and that are public for anyone and everyone to read
  • Messages that a user posts and that are non-public. These messages can only be read by users that the posting user has marked as friends.

In this step, you should add a third type of message. This third type of message should be readable by specified recipients only.
This means the database needs to provide the following:

  • A way of distinguishing between the three types of messages. This involves a change to the Message table.
  • A way of specifying who the recipients of a particular message are. This will probably require an additional table.

All this must again be achieved with minimal amount of storage, i.e., you must choose the appropriate data types from the MySQL manual. You may assume that the total number of messages that are added over time may reach 1,000,000,000.
Your job is to implement the necessary changes and additional table for this purpose and any keys and foreign key relationships required.

Here are my two tables first : User

CREATE TABLE IF NOT EXISTS `User` (
`user_id` int(10) unsigned NOT NULL auto_increment,
`given_name` varchar(60) default NULL,
`surname` varchar(60) default NULL,
`address` varchar(255) default NULL,
`city_id` int(10) unsigned NOT NULL,
`date_of_birth` datetime default NULL,
`email` varchar(80) default NULL,
PRIMARY KEY (`user_id`),
KEY `ix_user_surname` (`surname`),
KEY `ix_user_given_name` (`given_name`),
KEY `ix_user_name` (`given_name`,`surname`),
KEY `ix_user_date_of_birth` (`date_of_birth`),
KEY `ix_user_email` (`email`),
KEY `ix_user_city_id` (`city_id`)
) ENGINE=InnoDB

2nd table :Message

CREATE TABLE IF NOT EXISTS `Message` (
`message_id` int(10) unsigned NOT NULL auto_increment,
`owner_id` int(10) unsigned default NULL,
`subject` varchar(255) default NULL,
`body` text,
`posted` datetime default NULL,
`is_public` tinyint(4) default '0',
PRIMARY KEY (`message_id`),
KEY `ix_message_owner_id` (`owner_id`)
) ENGINE=InnoDB

MY SOLUTION: I was thinking of creating a new table called ‘Message_level’ and have columns ‘message_level_id'(will refer to 1,2,3 as 1=public, 2=private, 3=specific) & ‘message_level'(where it would state public,private and specific next to level). Then I can use the ‘Message_level’ as a foreign key into the ‘Message’ table and replace the ‘is_public’ column with ‘message_level_id’.

Is my approach to this question right? is there another way I can do this to make it more efficient?

and how would I approach the second task of specifying who the recipients of a particular message are?

  • 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-09T17:26:01+00:00Added an answer on June 9, 2026 at 5:26 pm

    I would go like this:

    User: user_id, given_name, ...
    
    Message: message_id, owner_id (fk User), subject, body, posted, message_type_id (fk Message_type)...
    
    Message_recipients: user_id (fk User), message_id (fk Message)
    
    Message_type: message_type_id, description (1:public, 2:friends, 3:specific_recipients)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this custom JSP tag that implements tree table(every task can have sub-tasks):
I'd like to have one interface for all my grid related tasks.The tasks implement
I have implement a scenario which involves two way communication between child and parent
I have to implement a sparse matrix (a matrix that has predominantly zeroes, so
I have to implement a iphone application which will record user's voice as you
I have to implement a progressbar that show the progress of a report generation,
Long story: I'm working on a system that will have Tasks and Handlers .
I have my own ITrigger . Basically, it looks like the below: public interface
I'm looking for some advice on the best way to implement the task below
Below I have a thread that updates a 'clock' label once per second. Once

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.