0

I'm thinking of the most efficient way to store data , priority is retrieving of data fast.

I have a set of data. Let take it as for example a Pokemon Card

Imagine that in this world , each card has it own unique ID but there can be duplicate properties of each card.

I'm thinking of creating 2 table to store such data

1st Table

Properties of each card that exist in this world with a unique ID

2nd table

for each ID , it can contain multiple rows of Unique ID of all the card in the world.

In summary , i'm thinking of having 1 table to store properties , another table to store who own this card with that property.

is there any better method to store and retrieve data. Planning to use mysql. Let's just take it as there can only be at most 100 million unique cards

1 Answer 1

3

So you have cards. Cards have properties. Some cards have the same properties and I assume properties are complex entities, they have some properties too.

It would make the most sense to have 3 tables: one for cards and who owns them. One for all the unique properties and then a many-to-many table between cards and properties.

Your select queries have a double JOIN. If you add indexes to the primary keys of all the tables it should be super fast.

Cards
  id
  owner
  name

Properties
  id
  value
  foo
  bar

Cards2Properties
  card_id [fk]
  property_id [fk]
Sign up to request clarification or add additional context in comments.

1 Comment

Good thing about this suggestion is that you can also add new properties without changing the model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.