June 2010
Intermediate to advanced
328 pages
7h 51m
English
Of course, some people do go both ways.
Let’s allow users to make comments on bugs. A given bug may have many comments, but any given comment must pertain to a single bug. So, there’s a one-to-many relationship between Bugs and Comments. The entity-relationship diagram for this kind of simple association is shown in Figure 11, Simple association, and the following SQL shows how you would create this table:
| Polymorphic/intro/comments.sql | |
| | CREATE TABLE Comments ( |
| | comment_id SERIAL PRIMARY KEY, |
| | bug_id BIGINT UNSIGNED NOT NULL, |
| | author_id BIGINT UNSIGNED NOT NULL, |
| | comment_date DATETIME NOT NULL, |
| | comment TEXT NOT NULL, |
| | FOREIGN KEY (author_id) ... |
Read now
Unlock full access