Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Database structure for different types

Featured Replies

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?

 

 

 

 

 

 

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?

  • 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

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
  • Author

Thanks D4Y0 :) I will give this a go

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.