将XML存储在SQL数据库记录或XML文件中是否更有效?

时间:2022-10-17 14:32:00

Is it more efficient to store the XML file paths and reference them through the database or to just put the XML straight into it's own database record?

存储XML文件路径并通过数据库引用它们或仅将XML直接放入其自己的数据库记录中是否更有效?

Thanks in advance for the advice.

提前感谢您的建议。

Here's my scenario. I'm creating a CE Sql server database with code in a c# Windows Application. It's a Fantasy Football Application. When a user selects a player, it'll add a node containing the player_id and information to the Team's XML.

这是我的情景。我正在使用c #Windows应用程序中的代码创建一个CE Sql服务器数据库。这是一个梦幻足球应用程序。当用户选择播放器时,它会将包含player_id和信息的节点添加到团队的XML中。

The UserTeam table would look like this..

UserTeam表看起来像这样..

(UserTeam_ID, User_ID, xml_team_data)

(UserTeam_ID,User_ID,xml_team_data)

When I say efficient, I guess I mean what would be a better practice. Less code, better load time

当我说有效率时,我想我的意思是什么是更好的做法。代码更少,加载时间更短

1 个解决方案

#1


1  

SQL (at least SQL Server) will store the XML files as blobs, so in binary format. Aparently you can do operations on the XML stored there, look at the link in the comment.

SQL(至少SQL Server)将XML文件存储为blob,因此采用二进制格式。显然,您可以对存储在那里的XML进行操作,查看注释中的链接。

If you don't plan to access XML parts from inside the db, it is better to hold your files separately on the file system and just point to them from the DB. If you decide later to use a cloud based system like Azure, you will be charged by database size, and you don't want that to be too big.

如果您不打算从数据库内部访问XML部件,最好将文件单独保存在文件系统上,只需从数据库中指向它们即可。如果您稍后决定使用基于云的系统(如Azure),则将按数据库大小收费,并且您不希望它太大。

#1


1  

SQL (at least SQL Server) will store the XML files as blobs, so in binary format. Aparently you can do operations on the XML stored there, look at the link in the comment.

SQL(至少SQL Server)将XML文件存储为blob,因此采用二进制格式。显然,您可以对存储在那里的XML进行操作,查看注释中的链接。

If you don't plan to access XML parts from inside the db, it is better to hold your files separately on the file system and just point to them from the DB. If you decide later to use a cloud based system like Azure, you will be charged by database size, and you don't want that to be too big.

如果您不打算从数据库内部访问XML部件,最好将文件单独保存在文件系统上,只需从数据库中指向它们即可。如果您稍后决定使用基于云的系统(如Azure),则将按数据库大小收费,并且您不希望它太大。