Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stuter12's avatar

Database design question

I'm building an application where something can be purchased without having to create an account (just enter payment details through stripe). Among the required fields are name and email. Should I store this info in the user table or a separate customer table? They aren't really users in a log in sense, but they could be in the future if they decide to create an account. If I do that, what would happen if one day John Doe decides to register but he's already in the user table because I added him when he made a transaction?

Just trying to avoid getting myself into a bad design :)

Thanks!

0 likes
2 replies
Snapey's avatar

Personally, I would keep them out of the Users table. Save that for authentication.

Create a customers or clients table and add the purchaser there. If they later want to register, its a simple step to link to the Customer model that has the same email address.

More of interest is what happens when the customer buys for a second time. Are you going to create another record for this new transaction or use the one you already have?

What happens when the user registers and then wants to purchase? Do you still create a customer ? I can see it getting messy unless you have clear objectives.

stuter12's avatar

@SNAPEY - My plan was to have an Order table as well. If they don't exist in customer table, add them and relate the order to that id. If they do exist, don't add to customers but use the found id to relate to the order.

My other thought is would it just be easier to make them register first before they can purchase.

Please or to participate in this conversation.