Hello,

I don't have technical problem. I was just thinking the difference between arrays and SQL. I am currently learning OOP in java and C# but my employment history is based on SQL Server. So I was thinking about this subject in my head and I don't see why bother with arrays when their is SQL. So I have these questions and I was wondering if someone could be kind enough to answer them...

1) What is the difference in handling data, between arrays and SQL.
2) Am I right to believe anything arrays can do, SQL can do. And SQL is more time
efficient rather than messing around with arrays regardless what software language is used.
3) Why would a company build projects based on arrays when these days it is standard practice for a company to use SQL Server or Oracle or whatever.

Cheers.

1) What is the difference in handling data, between arrays and SQL.

First of all, there is no concept of arrays in SQL (Server). The closest thing I know of that can simulate an array in SQL is a varchar string that's been tokenized and delimited by a character(s). That, or I can use a table and treat that as an array.

Assuming you're *not* using a set-based language like SQL - with an array, you usually iterate through it, via some sort of loop, to get the values. You can't do a select statement with arrays. In SQL, you could use a cursor, but a select statement is more efficient. Also, arrays natively have an index and table data does not. Arrays also have the capability of being very efficient for its simplicity - you have the index and data that can store a value or a pointer/reference to some other object. In SQL Server, a table has multiple columns with different types, constraints, indexes, default values, triggers, etc. - that handle and support more complex business requirements.

2) Am I right to believe anything arrays can do, SQL can do. And SQL is more time efficient rather than messing around with arrays regardless what software language is used.

You can simulate an array data structure, yes, but it's not the most efficient way. There may be times where you'll have to iterate through via triggers to emulate the array's mannerism.

3) Why would a company build projects based on arrays when these days it is standard practice for a company to use SQL Server or Oracle or whatever.

Depending on what language you're talking about, arrays are usually meant to handle simple data structures, within the application's memory scope, for example, an array of characters in a string; an array of pointers to objects. In SQL Server, first of all, it's not part of the application's memory scope - the data lies in a SQL Server's data store. Your application would have to connect to SQL Server every time to use SQL on data, which would totally be inefficient.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.