Re: many to many relational database
Posted by:
Nick Roper
Date: April 29, 2005 10:20AM
Hi Simion,
You could use 1 database with 2 tables: categ, and subcateg:
CREATE TABLE categ (
catid INT NOT NULL PRIMARY KEY,
description VARCHAR(30)
)
CREATE TABLE subcateg (
catid INT NOT NULL,
subid INT NOT NULL,
description VARCHAR(30),
PRIMARY KEY (catid, subid)
)
then you can store the main category names is the categories table, e.g:
id | description
1 | 'Categ 1'
2 |'Categ 2'
..........
9, Category9
and the subcategories:
1 | 1 | 'subcateg 1.1'
1 | 2 | 'subcateg 1.2'
...........
1 | 9 | 'subcateg 1.9'
2 | 1 | 'subcateg 2.1'
2 | 2 | 'subcateg 2.2'
...........
2| 9 | 'subcateg 2.9'
You would therefore be able to add as many categories & sub categories as necessary and relate the two tables using (categ.cateid = subcateg.catid) If you need to cross-tabulate the data into a matrix then you could do this with arrays in PHP.
Is this the kind of thing you need ?
Regards,
Nick
--
Nick Roper
Subject
Written By
Posted
Re: many to many relational database
April 29, 2005 10:20AM
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.