List:General Discussion« Previous MessageNext Message »
From:Ezequiel Panepucci Date:September 17 2007 10:11am
Subject:Re: using column "comment" to store metadata
View as plain text  
> > I currently use MyISAM, but I just tried a simple
> > create(InnoDB)/show full columns from/  and
> > it actually does return the JSON strings I put in.
>
> Try it on columns with a foreign key constraint.

I did and it still works (maybe the behaviour is version
dependent?).

Here is what I did:

CREATE TABLE parent (
    id INT NOT NULL comment '{"com": "the primary key of the parent."}',
    PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE child (
    id INT comment '{"com": "the primary key"}',
    parent_id INT comment '{"com": "the foreing key"}',
    INDEX par_ind (parent_id),
    FOREIGN KEY (parent_id) REFERENCES parent(id)
        ON DELETE CASCADE
) ENGINE=INNODB;

mysql> show full columns from parent;
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
| Field | Type    | Collation | Null | Key | Default | Extra |
Privileges                      | Comment
     |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
| id    | int(11) | NULL      | NO   | PRI |         |       |
select,insert,update,references | {"com": "the primary key of the
parent."} |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> show full columns from child;
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
| Field     | Type    | Collation | Null | Key | Default | Extra |
Privileges                      | Comment                    |
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
| id        | int(11) | NULL      | YES  |     | NULL    |       |
select,insert,update,references | {"com": "the primary key"} |
| parent_id | int(11) | NULL      | YES  | MUL | NULL    |       |
select,insert,update,references | {"com": "the foreing key"} |
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
2 rows in set (0.00 sec)
Thread
using column "comment" to store metadataEzequiel Panepucci17 Sep
  • Re: using column "comment" to store metadataMartijn Tonies17 Sep
    • Re: using column "comment" to store metadataEzequiel Panepucci17 Sep
  • Re: using column "comment" to store metadataMartijn Tonies17 Sep
    • Re: using column "comment" to store metadataEzequiel Panepucci17 Sep
  • Re: using column "comment" to store metadataMartijn Tonies17 Sep