September 22, 201313 yr Hi All, I am creating an application that allows the user to add an item and then sub items with different types of data like photos, lists etc I am not too sure how to sure how to structure this. At the moment, I have: items: id user_id name And I was thinking to have for my objects that belong to the item id item_id type I am not 100% sure how now to add the different types of data in this table depending on the type selected?
September 22, 201313 yr Could you not create one table with all the data in for each id/user_id, Then use an array to bring the data to the front end? or do you need to have this data seperate?
September 24, 201313 yr Author Could you not create one table with all the data in for each id/user_id, Then use an array to bring the data to the front end? or do you need to have this data seperate? Thanks for the reply, Im quite new to doing something like this but ideally I need to get out each type of object related to the item. Im not too sure how it would work using arrays of data, would this just be an array of images for example
September 24, 201313 yr What you have at the moment looks ok but you may need to add a "value" column to the object table so if the type is an image you can output a url. You can use a SQL inner join to select all the data you want in one go an example would be SELECT * FROM items INNER JOIN objects ON (items.id = objects.item_id) WHERE items.id = 1
Create an account or sign in to comment