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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:15:14+00:00 2026-05-25T03:15:14+00:00

For my table I’ve defined a unique index on activity_id – actor_id – end_date

  • 0

For my table I’ve defined a unique index on activity_id–actor_id–end_date;

mysql> show keys from sg_activity_property;
+----------------------+------------+-------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+
| Table                | Non_unique | Key_name    | Seq_in_index | Column_name          | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------------+------------+-------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+
| sg_activity_property |          0 | PRIMARY     |            1 | activity_property_id | A         |         506 |     NULL | NULL   |      | BTREE      |         |
| sg_activity_property |          0 | activity_id |            1 | activity_id          | A         |        NULL |     NULL | NULL   |      | BTREE      |         |
| sg_activity_property |          0 | activity_id |            2 | actor_id             | A         |        NULL |     NULL | NULL   |      | BTREE      |         |
| sg_activity_property |          0 | activity_id |            3 | end_date             | A         |        NULL |     NULL | NULL   | YES  | BTREE      |         |
+----------------------+------------+-------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+
4 rows in set (0.00 sec)

So, how can this data exist??

mysql> SELECT activity_property_id, activity_id, actor_id, start_date, end_date FROM  `sg_activity_property` WHERE  `activity_id` =250;
+----------------------+-------------+----------+---------------------+----------+
| activity_property_id | activity_id | actor_id | start_date          | end_date |
+----------------------+-------------+----------+---------------------+----------+
|                  509 |         250 |        8 | 2011-09-02 11:10:50 | NULL     |
|                  510 |         250 |        8 | 2011-09-02 11:10:50 | NULL     |
+----------------------+-------------+----------+---------------------+----------+
2 rows in set (0.00 sec)

Edit: here’s the output of SHOW CREATE TABLE sg_activity_property:

mysql> SHOW CREATE TABLE sg_activity_property;
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table                | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sg_activity_property | CREATE TABLE `sg_activity_property` (
  `activity_property_id` int(10) unsigned NOT NULL auto_increment,
  `activity_id` int(10) unsigned NOT NULL,
  `actor_id` int(10) unsigned NOT NULL,
  `importance` enum('very low','low','normal','high','very high') NOT NULL default 'normal',
  `urgency` enum('!','!!') default NULL,
  `completed` tinyint(1) NOT NULL,
  `start_date` datetime NOT NULL,
  `end_date` datetime default NULL,
  `review_frequency` int(11) NOT NULL default '1',
  `review_frequency_unit` enum('day','week','month','quarter','year') NOT NULL default 'week',
  PRIMARY KEY  (`activity_property_id`),
  UNIQUE KEY `activity_id` (`activity_id`,`actor_id`,`end_date`)
) ENGINE=MyISAM AUTO_INCREMENT=511 DEFAULT CHARSET=latin1 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.19 sec)
  • 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-05-25T03:15:15+00:00Added an answer on May 25, 2026 at 3:15 am

    because of the NULL on end_date,
    technically NULL <> EMPTY, or any value, is just a placeholder where value is missing

    so, change it to NOT NULL should fix

    PS: when you doing alter

    alter table sg_activity_property 
    modify column end_date datetime not null
    default '0000-00-00 00:00:00';
    

    this will fail, because mysql will attempt to convert the NULL to 0000-00-00 00:00:00,
    in order to fix this, you can either assign some random value to it first,
    or just simply remove one of the duplicate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table has about 8 million rows. There is a non-unique index for X. Showing
Table with Unique Clustered Index and an Indexed View are stored in same way.
table: postid|userid|post|replyto post sql SELECT * FROM table WHERE postid=12 total replies sql SELECT
Table has surrogate primary key generated from sequence. Unfortunately, this sequence is used for
Table#Appointments: ID, Name, LocationID, Created Currently I have: SELECT * FROM Appointments WHERE Created
Table: UserId, Value, Date. I want to get the UserId, Value for the max(Date)
table data of 2 columns category and subcategory i want to get a collection
table { id: long name: string } 1235 Fred 1902 Trever 5123 George 6467
**Table A** 1 2 3 4 5 6 **Table B** 2 3 5 How
Table like datetime a1 b1 x2 ... 07-01-2009 13:10 8 9 10 07-01-2009 13:11

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.