I'm using MVC 5 Core on my Web API and I wanted to know what is the most optimal way of storing an Array into a database? Should I store Arrays, does it matter, or should I parse the array and input them individually into their own separate rows?

By optimally, I mean being able to have more control over the data and cutdown on load times. Should I be inputting Arrays into a database or parse them and put them in separate rows?

Database: MSSQL

This is my model code

    namespace backend.Models
    public class Portfolio
        public string ProjectName { get; set; }
        public string ProjectRole { get; set; }
        public string ProjectTech { get; set; }
        public string[] ProjectDescriptions { get; set; }
  • What do you mean by "optimal?" That is unanswerable unless you tell us what your specific criteria is. Commented Nov 13, 2016 at 19:54
  • Edited to be more accurate.
    – ARLCode
    Commented Nov 13, 2016 at 20:19
  • That's a classic 1:N data mapping. Any modern ORM can map that easily for you, even Linq2SQL.
    – Machado
    Commented Dec 14, 2016 at 19:23

2 Answers 2


(Assuming you have an RDB) You should create another table and put each array item in it as a row.

Don't try and reinvent the wheel with xml columns or string parsing. The RDB is designed to store and retrieve this kind of data as related tables.


Portfolio has a one to many relationship with ProjectDescriptions. That's the structured database way to look at this. You can hack around that in a multitude of ways but if you want to be friendly to a structured SQL database that's the deal.

There are other kinds of DB's that don't even have rows but MSSQL isn't one of them.

Load times aren't going to care about structure as much as amount of data. As for control, my watchword is readability.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.