简体   繁体   English

有没有办法将链接列表存储在数据库中的单个列中,这样当从 db 获取它时,它仍然有它的节点

[英]Is there any way to store an linked list in database in a single column such that when getting it from db it has still its nodes in it

Is there any way to store an linked list in database in a single column such that when getting it from db it has still its nodes in it such like the head, the tail and each node data.有没有办法将链接列表存储在数据库中的单个列中,这样当从 db 获取它时,它仍然有它的节点,比如头部、尾部和每个节点数据。

You must read up on "serialization" ( MS Documentation to get you started ).您必须阅读“序列化”( MS 文档以帮助您入门)。

Before building decide...在建造之前决定...

(1) Whether you need to treat the whole linked list as a single object " single column on one row " (1) 是否需要将整个链表视为单个 object “单列单行
or或者
(2) Whether you can treat each entry in the list as a distinct object " several rows, one column " (I strongly recommend this option because it is seldom possible to know that your design-time maximum conceivable list length and object size will not be exceeded in future.) (2) 是否可以将列表中的每个条目视为不同的 object“几行,一列”(我强烈推荐此选项,因为很少可能知道您的设计时最大可想象的列表长度和 object 大小不会将来会超过。)
and
(3) What you will serialize to (binary - and presumably Base64 encoding, XML, JSON or some other custom string format). (3) 您将序列化的内容(二进制 - 大概是 Base64 编码、XML、JSON 或其他一些自定义字符串格式)。

Then you serialize either the entire list (option 1) or its contents (option 2)然后序列化整个列表(选项 1)或其内容(选项 2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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