table design and relationship question
Posted: 2020-07-03 23:05
This question might be very basic, but I have watched some database design videos and still confused, so thought I would ask you guys for direction related to design.
Hypothetical example:
A database holding details of all the apartments in an apartment block, resident details and the food contents of each apartment.
To be able achieve various search results. For example:
What apartments have vegetables, what vegetables? and how many of each?
My initial thought path is to have the following tables:
Table: Apartment_block: Fields: ID, block_name
Table: Apartment_number: Fields: ID, apartment_number, name_of_resident
Table: Food_item: Fields: ID, product_category, product_name, qty
But am struggling in my head with the relationships.
For example: Would I be able to create a record by Adding an apartment and then in the same action, add what foods and quantity are in that apartment?
Or would I need to add the foods first, and then select the Apartment and add quantity of each food item in the Apartment?
Do I actually need more tables?
Hypothetical example:
A database holding details of all the apartments in an apartment block, resident details and the food contents of each apartment.
To be able achieve various search results. For example:
What apartments have vegetables, what vegetables? and how many of each?
My initial thought path is to have the following tables:
Table: Apartment_block: Fields: ID, block_name
Table: Apartment_number: Fields: ID, apartment_number, name_of_resident
Table: Food_item: Fields: ID, product_category, product_name, qty
But am struggling in my head with the relationships.
For example: Would I be able to create a record by Adding an apartment and then in the same action, add what foods and quantity are in that apartment?
Or would I need to add the foods first, and then select the Apartment and add quantity of each food item in the Apartment?
Do I actually need more tables?