0

I received a list from a customer using bullet points, and then sub bullet points. What is the best way to store these in a Postgres database, if you could give me an example of this, that would be great.

Thanks!

Structure of it is something similar to this:

  • Defect1
    • possible instance of defect1
    • another possible instance of defect1
  • Defect2
    • possible instance of defect2
    • another possible instance of defect2...
Lilluda 5
  • 1,111
  • 3
  • 18
  • 38
  • You have a few options... One is to reformat it in a text editor to remove the bullet points. The second is to have an intern do it. – NotMe Oct 01 '13 at 01:09
  • I guess a third is to give us a little more to go on. Such as: do the different bullet points define separate records? Was this some emailed list that you need to process once or an ongoing problem? Is it all going into a single blob? Do you have an existing table structure this should go into? Have you tried anything at all? Do you have a snippet of the data and an example of what it is you want to do? In short: can you provide any relevant details up to, and including, the specific problem you have? – NotMe Oct 01 '13 at 01:13

1 Answers1

2

For indented lists you're basically talking about a tree structure. There are many ways to store hierarchies. See this answer for a comparison.

Design Relational Database - Use hierarchical datamodels or avoid them?

Depending on how you want to use the data, i.e., if you're just going to spit it back out as it came in, you may be able to skip the hierarchy aspect in this particular use case and just store each line in sequence with an indentation field. It won't do nearly what can be done with a tree, but it may be all that's needed in your particular case.

Community
  • 1
  • 1
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
  • So is this something similar to adding '\n' and '\t' in my text cause the appropriate display? – Lilluda 5 Oct 01 '13 at 01:23
  • @Lilluda5, no, storing all of the data in a single large text field with delimiters is different. That can also be appropriate depending on your end goal. The key issue is if each line is it's own distinct record or if the whole text is the record. Depends on how you're relating the data, how you're searching, and how you're displaying it. – Samuel Neff Oct 01 '13 at 01:26
  • I think to start with I just want to store the entire textfield as a whole. That would probably work best. – Lilluda 5 Oct 01 '13 at 01:27
  • @Lilluda5, you can always parse it and break it out later if you need. – Samuel Neff Oct 01 '13 at 01:48