Java Reference
In-Depth Information
Figure 1-13. Many-to-many relationship between Book and Author
The sole purpose of the BookAuthor table is to provide a many-to-many relationship between Book
and Author.
Note As shown in Figure 1-13 , there is a one-to-many relationship between Book and BookAuthor,
and there is a one-to-many relationship between Author and BookAuthor. In fact, the sole purpose of the
BookAuthor table is to provide a many-to-many relationship between Book and Author—in other words, an
author can write many books, and a book can have many authors.
Because of the profusion of web applications across several domains, many relational and
nonrelational databases such as NoSQL 12 have emerged. In this topic, I'll use MySQL 13 because
it is the most widely used free database management system (DBMS). To install MySQL, go to
http://dev.mysql.com/downloads/ and click Download. You can download MySQL Server 5.5 or
newer. You can see the instructions for installing MySQL at
http://dev.mysql.com/doc/refman/5.5/en/installing.html .
To create the topics database, use the following command:
create database books;
You need to instruct MySQL to create tables in the topics database by using the following command:
use books;
Now you can create the tables using the statements illustrated in Listing 1-3.
Listing 1-3. Creating Tables for the Bookstore
CREATE TABLE CATEGORY (
ID INT NOT NULL AUTO_INCREMENT ,
CATEGORY_DESCRIPTION VARCHAR(20) NOT NULL ,
PRIMARY KEY (ID)
);
http://nosql-database.org/
12
www.mysql.com/
13
 
Search WWH ::




Custom Search