我相信标题是不言自明的.如何在PostgreSQL中创建表结构以建立多对多关系.
我的例子:
Product(name, price);
Bill(name, date, Products);
Run Code Online (Sandbox Code Playgroud) 我有一个 XML 文档需要存储在 SQL 数据库 (Postgres) 中。我已经了解了这是如何完成的,但我有一个问题:我是否只创建一个带有 xml 字段的表并将整个文档放在那里?这是一个关于电影等(电影、演员......)的文档,其中包含稍后检索的信息。
我从来没有在数据库中使用过 XML,所以我有点困惑。
这是我的 XML 的示例:
<?xml version="1.0" encoding="UTF-8"?>
<cinema xmlns="movies"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="movies file:/C:/Users/Fabio/git/LAPD/movies.xsd">
<persons>
<person id="P1">
<name>Samuel L. Jackson</name>
<birth>1948-12-21</birth>
</person>
<person id="P2">
<name>Leonardo Di Caprio</name>
<birth>1974-11-11</birth>
</person>
<person id="P3">
<name>Quentin Tarantino</name>
<birth>1963-03-27</birth>
</person>
</persons>
<movies>
<movie id="M1">
<title>Pulp Fiction</title>
<length>154</length>
<year>1994</year>
<description>The lives of two mob hit men,
a boxer, a gangster's wife, and a pair
of diner bandits intertwine in four tales of violence and redemption</description>
<crew>
<director ref="P3"/> …Run Code Online (Sandbox Code Playgroud)