处理数据库中的大量表的最有效方法是什么?

发布于 2024-11-03 07:00:38 字数 266 浏览 1 评论 0原文

我是数据库编程新手,正在使用 sqlite 和 python。举个例子,假设我有一个名为 Animals.db 的数据库,我用它打开并在 python 中获取光标。现在,如果我想按物种区分动物,每个物种都会有一个不同的表,因为它可以变得更加具体,所以我可能需要比物种表更具体的东西。

我对如何将正确的数据分配到数据库的正确区域以及如何分离感到有点困惑。有桌子桌子吗?

如果我想说为每种陆地动物准备一张桌子,为每种海洋动物准备一张桌子,但每张桌子都需要进一步的规范(智人等),我该怎么做?

I am new to database programming and am using sqlite and python. As an example lets say I have a database named Animals.db which I open with and get the cursor for in python. Now if I wanted to separate the animals by species I would have a different table per species and since it can get even more specific I would likely need something more specific than just a table of species.

I am a bit confused on how one allocates the correct data to the correct area of a database, how is it separated. Are there tables of tables?

if I wanted to lets say have a table for every land animal and another for every animal of the sea, but each table would need further specification(homo sapiens, etc), how can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-11-10 07:00:38

现在如果我想分开
按物种划分的动物我会有一个
每个物种不同的表

。也许不是。您可能会使用如下所示的表格。这完全取决于“按物种区分动物”的含义。这是一种合理的解释。

Animal_name      Sex  Species
------
Jack             M    Leopardus pardalis
Susie            F    Leopardus pardalis
Kimmie           M    Leopardus pardalis
Susie            F    Stenella clymene
Ginger           F    Stenella clymene
Mary Ann         F    Stenella clymene

要查找所有克莱门海豚,您可以使用类似以下的查询。

select Animal_name
from animals
where species = 'Stenella clymene'
order by Animal_name

Animal_name
--
Ginger
Mary Ann
Susie

从收集数据开始。您的目标是收集一组具有代表性的样本数据。 样本数据,因为全部人口太大而无法处理。 代表性,因为理想情况下它代表了您可能会遇到的所有问题。如果“动物名称”对您来说并不意味着“杰克”或“金杰”,而是“豹猫”和“克莱门海豚”,代表性样本数据将清楚地表明这一点。

Now if I wanted to separate the
animals by species I would have a
different table per species

Maybe. Maybe not. You might use a table that looked like this. It depends entirely on what you mean by "separate the animals by species". Here's one reasonable interpretation.

Animal_name      Sex  Species
------
Jack             M    Leopardus pardalis
Susie            F    Leopardus pardalis
Kimmie           M    Leopardus pardalis
Susie            F    Stenella clymene
Ginger           F    Stenella clymene
Mary Ann         F    Stenella clymene

To find all the Clymene dolphins, you might use a query along these lines.

select Animal_name
from animals
where species = 'Stenella clymene'
order by Animal_name

Animal_name
--
Ginger
Mary Ann
Susie

Start by collecting data. Your goal is to collect a set of representative sample data. Sample data, because the full population is too big to handle. Representative, because ideally it represents all the problems you're likely to run into with the full population. If "animal name" to you doesn't mean "Jack" or "Ginger", but "ocelot" and "Clymene dolphin", representative sample data will make that clear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文