0
  1. In my database there is one table 't_object' and one table 't_search_object'. These two tables are quite similar to each other.

    Both tables have one column called 'properties' where the properties are stored separated with commas, e.g.: "1,4,8".

    That's why there is an additional table called 't_object_properties' with two columns(id, name) and data records like: (1, propertie1) ...

    The problem with having one column 'properties' and one additional table, is that I have several values in just one column.

    So I want to know if this is a good way of designing a database..?

  2. I am thinking if it wouldn't be better to have columns like 'is_propertie1', 'is_propertie2', and so on in both tables 't_object' and 't_search_object'? The problem would be to update two tables if another propertie would be added.

So what would you advise? 1) or 2) or is there another way to solve this issue?

1 Answer 1

2

It's always wise to have an extra table rather than a comma-separated list of values in MySQL (and all RDBMS systems) to represent one-to-many relationships like object-property. Relational data management is designed around this very concept. Read about "normalization."

Comma separated lists of values, and long lists of columns, both give rise to real peformance and usability problems, especially when your data base gets larger.

Go with your first choice, get rid of the properties column containing lists of values like '1,4,8', and don't look back.

Sign up to request clarification or add additional context in comments.

1 Comment

So you say that I should add all the propertie-columns to both tables? And when I need to add another propertie I have to do this on both tables. A propertie columen would be calles "is_propertie1" and would have a boolean type, meaning '1' or '0'. Is that what you meant?

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.