简体   繁体   中英

How would this get stored in a database?

Ok so I have a name, a time/data, and an array...

so in my database I store in the table, the:

name, time/data, but the array?

This array doesn't have a fixed size... It is an array of tuples (x,y) <- even thats an array

I want to associate the name and time/date with this array. I heard its not good and impossible to store an array in a database, I'm using sqllite3..

How do I solve this problem? Do I just let the name and timedate table point to a newly constructed table for the array?

Just create a table with X, Y, timestamp and a foreignkey to an entry in an entry table.

Data table:

ID  | Index |  X  |  Y  |  EntryID
0   |   0   | 3.2 | 4.3 |   1
1   |   1   | 2.1 | 1.2 |   1
........
n-1 |   n-1 | xn  | yn  |   1

# The above is from array 1, below from another array

n   |   0   | 2.2 | 2.4 |   2
n+1 |   1   | 2.1 | 1.9 |   2
.........
n+m-1 | m-1 | xm  | ym  |   2

Entry table:

ID | Name          | DateTime
1  | user3043594   | 2013-..
2  | Steinar Lima  | 2012-..

You store all entries from all arrays in this table, and filter them based on entry id. Then you can do a join to get the user name from the user table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM