nosql - Questions about FriendFeed's MySql SchemaLess Design -


Brett Taylor discussed schema les design in this blog post:

It seems that they Store different class objects in only one table. Then build more index tables.

My question is how to create an index on a class.

For example, the user's blog {id, userid, title, tan} A user tweet is {id, user-id, tweet}.

How can I do if I want to create an index for users' blogs?

It's very easy - maybe you are expected.

When you archive a blog unit, then you have the main institutions table of course. A blog goes like this:

  create table entities (id INT AUTO_INCREMENT primary key, entity_json text tap); Enter Entities (id, entity_jason) value (default, '{userid: 8675309, post_date: "2010-07-27", title: "MySQL is NoSQL", body: ...}');  

You are also included in a separate index table for each logical type of attribute. Using your example, UserID for a blog is not the same as the user id for a tweet. Since you have just added a blog, then you enter the index table for the blog attribute (s):

  create table blog (id INT not null primary key, UIDID Unsigned, Key (user id, id)); Include blog_urrid (id, user-id) values ​​(LAST_INSERT_ID (), 867530 9); Tablet Blog_date (id INT not original primary key, post_data datetime unaccessed, key (post_date, id)); Enter blog_data (id, post_data) values ​​(LAST_INSERT_ID (), '2010-07-27');  

Do not include any tweet index table, because you have created a blog, not a tweet.

You blog blog_userid , because you have put them in. So you can find a given user's blog:

  SELECT e * From the blog user idioms = e.id WHERE u.userid = 86765309;  

Redo your comment:

Yes, you can add genuine columns to the organization table for all the attributes that apply to all types of special types Are there. For example:

  create table entities (id INT AUTO_INCREMENT primary key, unit type is not INT, date of creation is not TIMESTAMP, NULL DEFAULT CURRENT_TIMESTAMP, entity_json TEXT NOT tap);  

The column for entity_type and creation_date will allow you to crawl the units in the chronological order (or reverse chronological order) and know how the index table is given by the unit type of the given row. Matches. / P>


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -