Karlovsky120
Karlovsky120

Reputation: 6352

Multidimensional data types

So I was thinking... Imagine you have to write a program that would represent a schedule of a whole college.

That schedule has several dimensions (e.g.):

You would have to be able to display the schedule from several standpoints:

How would you save such data, and yet keep the ability to view it from different angles?

Only way I could think of was to save it in every form you might need it:

E.g. you have folder "students" and in it each student has a file and it contains when and why and where he has to be. However, you also have a folder "locations" and each location has a file which contains who and why and when has to be there. The more angles you have, the more size-per-info ratio increases.

But that seems highly inefficinet, spacewise.

Is there any other way?

My knowledge of Javascript is 0, but I wonder if such things would be possible with it, even in this space inefficient form.

If not that, I wonder if it would work in any other standard (C++, C#, Java, etc.) language, primarily in Java...

EDIT: Could this be done by using MySQL database?

Upvotes: 1

Views: 70

Answers (1)

armel
armel

Reputation: 2580

Basically, you are trying to first store data and then present it under different views.

SQL databases were made exactly for that: from one side you build a schema and instantiate it in a database to store your data (the language is called Data Definition Language, DDL), then you make requests on it with the query language (SQL), what you call "views". There are even "views" objects in SQL databases to build these views Inside the database (rather than having to the code of the request in the user code).

MySQL can do that for sure, note that it is possible to compile some SQL engine for Javascript (SQLite for example) and use local web store to store the data.

There is another aspect to your question: optimization of the queries. While SQL can do most of the request job for your views. It is sometimes preferred to create actual copies of the requests results in so called "datamarts" (this is called de-normalizing a request), so that the hard work of selecting or computing aggregate/groups functions and so on is done once per period of time (imagine that a specific view changes only on Monday), then requesters just have to read these results. It is important in this case to separate at least semantically what is primary data from what is secondary data (and for performance/user rights reasons, physical separation is often a good idea).

Note that as you cited MySQL, I wrote about SQL but mostly any database technology could do that what you searched to do (hierarchical, object oriented, XML...) as long as the particular implementation that you use is flexible enough for your data and requests.

So in short:

  • I would use a SQL database to store the data
  • make appropriate views / requests
  • if I need huge request performance, make appropriate de-normalized data available
  • the language is not important there, any will do

Upvotes: 2

Related Questions