3

I have to keep duplicate data in my database so my question is...Is it preferable to keep the duplicate data in the same table and just add a column to identify the original data or I have to create another table to hold the copied data?

10
  • 2
    By the way, what's the purpose of having duplicate data? Just curious. Commented Aug 6, 2016 at 13:03
  • 1
    i believe he stores money in the db Commented Aug 6, 2016 at 13:04
  • Could you expand a bit on what you're trying to save and why you need the duplicates? The question is a tad too broad to give a useful answer. Commented Aug 6, 2016 at 13:04
  • 1
    Then I guess it might be the fastest way to become rich overnight :p @DombiSzabolcs Commented Aug 6, 2016 at 13:06
  • Consider reading about database normalization and one to many mapping Commented Aug 6, 2016 at 13:08

2 Answers 2

3

I suggest to save the duplicate data in a different table or even a different schema so it won't be confusing to keep working with this table.

Imagine yourself in six months form now trying to guess what are all this duplicate rows for.

In addition those duplicate rows does not reflect the business purpose of this table. It will be nicer to store them in a table named [table_name]_dup or a schema named [schema_name]_dup

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

Comments

0

To create a backup you should read this

To duplicate a website with it's content. Bad solution but you still have to make a backup and restore it in a different database.

Duplicate a table in mysql:

CREATE TABLE newtable LIKE oldtable; 
INSERT newtable SELECT * FROM oldtable;

Comments

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.