When issuing a NF-e it is possible to insert up to 990 products / items per document . Since each product has several attributes. What would be the best way to store and link each product, and its respective attributes, to an NF-e?
I currently have the following structure:
Table nfe
:
'id' int(11) NOT NULL AUTO_INCREMENT,
'id_nfe' int(11) DEFAULT NULL,
'id_emitente' varchar(255) DEFAULT NULL,
...
Table tributos_prod
:
'id' int(11) NOT NULL AUTO_INCREMENT,
'id_nfe' int(11) NOT NULL,
'codigo' varchar(255) DEFAULT NULL,
...,
KEY 'fk_nfe' ('id_nfe'),
CONSTRAINT 'fk_nfe' FOREIGN KEY ('id_nfe') REFERENCES 'nfe' ('id')
Problem : As each product / item will have a unique ID, the "infinite" growth of the tributos_prod
table would occur, making it unmanageable because Authorize the issue of an NF-e can remove all products linked to this, or even by the simple action of removing a single item.