I´m designing a MySQL database, and I have three tables: A, B and C. Table A depicts the design of specific rooms of a house and table B references different possibilities for the design of the room (possible scenarios). Table C contains specific elements for design that can be applicable to each possibility:
Table A
ID | Name | Description |
---|---|---|
kitchen | Kitchen | Kitchen design |
bathroom | Bathroom | Bathroom design |
Table B
ID | Description | Reference_to_A |
---|---|---|
kitchen_1 | wooden floor kitchen | kitchen |
kitchen_2 | marble floor kitchen | kitchen |
bathroom_1 | marble floor bathroom | bathroom |
Table C
ID | Description | Reference_to_A | Reference_to_B |
---|---|---|---|
floor_1 | marble floor | kitchen | kitchen_2 |
floor_2 | Wooden floor | kitchen, bathroom | kitchen_1, bathroom_1 |
I need advice on how to build this architecture on MySQL, with the following constraints:
- Each row of table C can only be associated to table B (by means of the Reference_to_B column) if table C.Reference_to_A = Table B.reference_to_A
- I want to know if its possible to have several references to another table in a column, which I can guess its not. If not, I would appreciate another option that is efficient in terms of size of the database.