我是新来访问并尝试为我的公司创建数据库的人。我想创建的表之一是显示每台计算机的计算机程序需求的表。我有一个 Excel 表,其中行是计算机,列是程序。如果计算机拥有该程序,则有一个“x”(用于简单程序)或该程序的当前版本(例如 2.0.0.0)。我可以在访问中复制这张表,但我觉得我走错了路。有没有更好的方法来显示拥有多个程序的计算机?我需要能够创建有关软件版本的报告。将此类数据制成表格的最佳方法是什么?
问问题
89 次
1 回答
0
You actually need four tables:
computer
: include details for each computer on its own (no programs), including primary keycomputer_id
program
: include details for each program on its own (no computers), including primary keyprogram_id
, but don't include the version number hereprogram_version
: this table has three columns: primary keyversion_id
, foreign keyprogram_id
from tableprogram
, and version numbercomputer_program
: this table has two columns: foreign keycomputer_id
fromcomputer
, and foreign keyversion_id
from tableprogram_version
To pull the data you'd need for your report, your query would probably look something like:
SELECT computer.make, program.vendor, program_version.version_num /* add other columns as needed */
FROM computer_program cp
INNER JOIN computer c ON cp.computer_id = c.computer_id
INNER JOIN program_version pv ON cp.version_id = pv.version_id
INNER JOIN program p ON pv.program_id = p.program_id
WHERE c.make = 'Dell' OR pv.version_num = 4 OR p.vendor = 'Microsoft'
于 2013-10-10T14:50:35.243 回答