If you have a many to many relationship between book and category you can map it to object oriented model as shown below based on How to design many-to-many relationships in an object database?
Book {
Collection<Category> categories
}
Category {
Collection<Books> books
}
To define a collection in a table in ORDBMS you have to use a nested table. (Example taken from oracle website Sample Application Using Object-Relational Features)
CREATE TABLE PurchaseOrder_objtab OF PurchaseOrder_objtyp ( /* Line 1 */
PRIMARY KEY (PONo), /* Line 2 */
FOREIGN KEY (Cust_ref) REFERENCES Customer_objtab) /* Line 3 */
OBJECT IDENTIFIER IS PRIMARY KEY /* Line 4 */
NESTED TABLE LineItemList_ntab STORE AS PoLine_ntab ( /* Line 5 */
(PRIMARY KEY(NESTED_TABLE_ID, LineItemNo)) /* Line 6 */
ORGANIZATION INDEX COMPRESS) /* Line 7 */
RETURN AS LOCATOR /* Line 8 */
However it is best to keep a collection of references rather than keeping the objects itself.
According to the this answer Nested table primary and foreign key in Oracle it is not possible to add a foreign key to to a nested table.
1) So what is the best way to map a many to many relationship in object relational database (Oracle)?
2) If the answer is keeping two collections in the two objects as shown above, how to store it as a reference collection without directly storing it as the object?