Re: N-to-N Model: Table Size vs Complexity
Posted by: Rick James
Date: May 14, 2009 10:27PM

CREATE TABLE `db`.`friends` (
   `a` varchar(10) NOT NULL COMMENT 'SELECT a FROM friends WHERE b = person UNION SELECT b FROM friends WHERE a = person',
   `b` varchar(10) NOT NULL,
   PRIMARY KEY `friend` (a, b),
   KEY (b, a)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='mapping relationships between people';
VARCHAR -- unless all your friends have exactly 10 letters?
InnoDB works better with a PRIMARY KEY.

These changes are only a start -- When you get some more fields and some more SELECTs, you may need more hints.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.