我有一個書籍和作者的數據集,有多對多的關係。Python中的多對多數據結構
約有10^6本書和10^5位作者,每本書平均有10位作者。
我需要對數據集執行一系列操作,例如統計每位作者的書數,或者刪除某個作者的所有書籍。
什麼是一個好的數據結構,將允許快速處理?
我希望對一些現成的模塊,它可以提供的線沿線的方法:
obj.books.add(book1)
# linking
obj.books[n].author = author1
obj.authors[m].author = book1
# deleting
obj.remove(author1) # should automatically remove all links to the books by author1, but not the linked books
我要澄清,我不喜歡使用這個數據庫,但要做到這一切在內存。
感謝
把信息放在數據庫中? – obelix 2010-08-21 17:28:53
將其放入內存而不是磁盤的數據庫中。 – carl 2010-08-21 17:32:12