create table Rows ( Id int primary key, Name text(255) not null ) create table Cols ( Id int primary key, Name text(255) not null )
create table Data ( RowId int not null foreign key references Rows(Id), ColId int not null foreign key references Cols(Id), Data ) On 8 апр, 02:32, Bill Freeman <ke1g...@gmail.com> wrote: > You need one matrix table, having a row for each matrix. > > You need one matrix_row table, having a row for each row of any matrix, mostly > containing a foreign key on the matrix table, showing of which matrix the row > is > part, plus it's row number in that table. > > And you need one matrix_row_values table, having a foreign key on the > matrix_row, > indicating of which row it is a part, plus it's column number, and the value. > > There is no run time table creation involved, and this can all be done > with direct > django models, and on any database the ORM supports (maybe not NoSQL > databases, I'll have to think about that). The access syntax wouldn't look > like > 2D array access, but you could fix that with a wrapper. > > > > On Wed, Apr 7, 2010 at 4:20 PM, zimberlman <zimberl...@rambler.ru> wrote: > > No, no. > > I need to store the matrix and dual array is ideal for this would come > > up. > > The problem is that the matrix will grow in size, thousands of entries > > only on i, and where that same number of j. > > create table is not an option. > > > only if the matrix transform and drive the table. and my question is, > > if you can not define arrays in the model, how can I convert a > > matrix. > > example is the matrix > > a b c d e > > 1 2 3 4 5 > > 11 22 33 44 55 > > converted into > > a 1 > > a 11 > > b 2 > > b 22 > > c 3 > > c 33 > > d 4 > > d 44 > > e 5 > > e 55 > > > this is for example, how do I implement this in the model? course in > > the class will have to use functions, but is it possible? > > > On 8 апр, 01:28, pmains <peter.ma...@gmail.com> wrote: > >> If there is no Django model field for this, then one option would be > >> to create your own model field (http://docs.djangoproject.com/en/dev/ > >> howto/custom-model-fields/). Of course, it would not be compatible > >> with most SQL Database types. > > >> Of course, it may be easier to just rethink your data model. Would it > >> be possible to create one or more additional tables to avoid using an > >> unusual DB construct like a 2D array? > > >> Could you explain the problem in a little more detail? Saying that you > >> want a 2-dimensional array is very abstract, but if we understand what > >> problem you are trying to solve, what data you are attempting to > >> model, it will be easier to give you useful suggestions. > > > double array that I want to keep count, it is ideally suited for the > > incidence matrix of the graph. > > required to store the connection to the knowledge base of question- > > answering system. > > which will lie on j IDs leading questions, and i will lie on > > identifiers answers emerging from a set of leading questions. > > and a double array is an ideal way to store data. > > but I probably need to write your own model of the array for django in > > this case, it is the only big problem at this time. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.