问题
I am creating a database and I need to construct a form-based entry method of adding data into my tables, whilst maintaining what I believe is a many-to-many relationship.
Say Project X can have Parts X, Y and Z - and Parts X, Y and Z can be used on more than one project.
What is the best way of allocating a list of 'parts' to a project through a form, without have a huge array of tickboxes, and how do I construct my tables to accommodate this?
Much appreciated.
回答1:
Many-to-Many relationship requires 3 tables minimum. Table for Projects, table for Parts, and junction table ProjectParts. Each record in ProjectParts will be a unique project and part pair. Options for data entry form:
one form bound to ProjectParts with comboboxes to select project and part
main form bound to Projects and subform bound to ProjectParts with combobox to select part
main form bound to Parts and subform bound to ProjectParts with combobox to select project.
This is really very basic database design.
来源:https://stackoverflow.com/questions/43536938/many-to-many-relation-ship-with-form-based-multi-selection