多个引用一个外键

时间:2018-03-08 04:12:00

标签: mysql database database-design relational-database schema

在我的项目中,有收入和支出。我有很多业务和资产。每个企业和资产都有收入和支出。除此之外,我还有一些普通收入,如薪水,奖金等。所以最后我制作了6个表,

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="3.2" jmeter="3.2 r1790748">
  <hashTree>
    <TestPlan>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <intProp name="LoopController.loops">1</intProp>
        </elementProp>
      </ThreadGroup>
      <hashTree>
        <GenericController guiclass="LogicControllerGui" testname="17 /en/" enabled="true"/>
        <hashTree>
          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="17 /en/" enabled="true">
            <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
              <collectionProp name="Arguments.arguments"/>
            </elementProp>
            <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
            <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
            <stringProp name="HTTPSampler.domain">moulin.nl</stringProp>
            <stringProp name="HTTPSampler.method">GET</stringProp>
            <stringProp name="HTTPSampler.port">0</stringProp>
            <stringProp name="HTTPSampler.protocol">http</stringProp>
            <stringProp name="HTTPSampler.path">/en/</stringProp>
            <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp name="HeaderManager.headers">
                <elementProp name="Cache-Control" elementType="Header">
                  <stringProp name="Header.name">Cache-Control</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="Accept-Encoding" elementType="Header">
                  <stringProp name="Header.name">Accept-Encoding</stringProp>
                  <stringProp name="Header.value">gzip</stringProp>
                </elementProp>
                <elementProp name="Pragma" elementType="Header">
                  <stringProp name="Header.name">Pragma</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="User-Agent" elementType="Header">
                  <stringProp name="Header.name">User-Agent</stringProp>
                  <stringProp name="Header.value">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1</stringProp>
                </elementProp>
                <elementProp name="Accept" elementType="Header">
                  <stringProp name="Header.name">Accept</stringProp>
                  <stringProp name="Header.value">text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</stringProp>
                </elementProp>
              </collectionProp>
            </elementProp>
            <stringProp name="TestPlan.comments">Detected the start of a redirect chain</stringProp>
            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            <boolProp name="HTTPSampler.image_parser">true</boolProp>
          </HTTPSamplerProxy>
          <hashTree>
            <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp reference="../../../HTTPSamplerProxy/elementProp[2]/collectionProp"/>
            </HeaderManager>
            <hashTree/>
          </hashTree>
          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="18 /en/" enabled="false">
            <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
              <collectionProp name="Arguments.arguments"/>
            </elementProp>
            <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
            <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
            <stringProp name="HTTPSampler.domain">moulin.nl</stringProp>
            <stringProp name="HTTPSampler.method">GET</stringProp>
            <stringProp name="HTTPSampler.port">443</stringProp>
            <stringProp name="HTTPSampler.protocol">https</stringProp>
            <stringProp name="HTTPSampler.path">/en/</stringProp>
            <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp name="HeaderManager.headers">
                <elementProp name="Cache-Control" elementType="Header">
                  <stringProp name="Header.name">Cache-Control</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="Accept-Encoding" elementType="Header">
                  <stringProp name="Header.name">Accept-Encoding</stringProp>
                  <stringProp name="Header.value">gzip</stringProp>
                </elementProp>
                <elementProp name="Pragma" elementType="Header">
                  <stringProp name="Header.name">Pragma</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="User-Agent" elementType="Header">
                  <stringProp name="Header.name">User-Agent</stringProp>
                  <stringProp name="Header.value">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1</stringProp>
                </elementProp>
                <elementProp name="Accept" elementType="Header">
                  <stringProp name="Header.name">Accept</stringProp>
                  <stringProp name="Header.value">text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</stringProp>
                </elementProp>
              </collectionProp>
            </elementProp>
            <stringProp name="TestPlan.comments">Detected a redirect from the previous sample</stringProp>
            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            <boolProp name="HTTPSampler.image_parser">true</boolProp>
          </HTTPSamplerProxy>
          <hashTree>
            <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp reference="../../../HTTPSamplerProxy[2]/elementProp[2]/collectionProp"/>
            </HeaderManager>
            <hashTree/>
          </hashTree>
        </hashTree>
        <GenericController guiclass="LogicControllerGui" testname="19 /" enabled="true"/>
        <hashTree>
          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="19 /" enabled="true">
            <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
              <collectionProp name="Arguments.arguments"/>
            </elementProp>
            <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
            <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
            <stringProp name="HTTPSampler.domain">moulin.nl</stringProp>
            <stringProp name="HTTPSampler.method">GET</stringProp>
            <stringProp name="HTTPSampler.port">0</stringProp>
            <stringProp name="HTTPSampler.protocol">http</stringProp>
            <stringProp name="HTTPSampler.path">/</stringProp>
            <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp name="HeaderManager.headers">
                <elementProp name="Cache-Control" elementType="Header">
                  <stringProp name="Header.name">Cache-Control</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="Accept-Encoding" elementType="Header">
                  <stringProp name="Header.name">Accept-Encoding</stringProp>
                  <stringProp name="Header.value">gzip</stringProp>
                </elementProp>
                <elementProp name="Pragma" elementType="Header">
                  <stringProp name="Header.name">Pragma</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="User-Agent" elementType="Header">
                  <stringProp name="Header.name">User-Agent</stringProp>
                  <stringProp name="Header.value">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1</stringProp>
                </elementProp>
                <elementProp name="Accept" elementType="Header">
                  <stringProp name="Header.name">Accept</stringProp>
                  <stringProp name="Header.value">text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</stringProp>
                </elementProp>
              </collectionProp>
            </elementProp>
            <stringProp name="TestPlan.comments">Detected the start of a redirect chain</stringProp>
            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            <boolProp name="HTTPSampler.image_parser">true</boolProp>
          </HTTPSamplerProxy>
          <hashTree>
            <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp reference="../../../HTTPSamplerProxy/elementProp[2]/collectionProp"/>
            </HeaderManager>
            <hashTree/>
          </hashTree>
          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="20 /" enabled="false">
            <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
              <collectionProp name="Arguments.arguments"/>
            </elementProp>
            <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
            <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
            <stringProp name="HTTPSampler.domain">moulin.nl</stringProp>
            <stringProp name="HTTPSampler.method">GET</stringProp>
            <stringProp name="HTTPSampler.port">443</stringProp>
            <stringProp name="HTTPSampler.protocol">https</stringProp>
            <stringProp name="HTTPSampler.path">/</stringProp>
            <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp name="HeaderManager.headers">
                <elementProp name="Cache-Control" elementType="Header">
                  <stringProp name="Header.name">Cache-Control</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="Accept-Encoding" elementType="Header">
                  <stringProp name="Header.name">Accept-Encoding</stringProp>
                  <stringProp name="Header.value">gzip</stringProp>
                </elementProp>
                <elementProp name="Pragma" elementType="Header">
                  <stringProp name="Header.name">Pragma</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="User-Agent" elementType="Header">
                  <stringProp name="Header.name">User-Agent</stringProp>
                  <stringProp name="Header.value">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1</stringProp>
                </elementProp>
                <elementProp name="Accept" elementType="Header">
                  <stringProp name="Header.name">Accept</stringProp>
                  <stringProp name="Header.value">text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</stringProp>
                </elementProp>
              </collectionProp>
            </elementProp>
            <stringProp name="TestPlan.comments">Detected a redirect from the previous sample</stringProp>
            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            <boolProp name="HTTPSampler.image_parser">true</boolProp>
          </HTTPSamplerProxy>
          <hashTree>
            <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp reference="../../../HTTPSamplerProxy[2]/elementProp[2]/collectionProp"/>
            </HeaderManager>
            <hashTree/>
          </hashTree>
          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="21 /en/" enabled="false">
            <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
              <collectionProp name="Arguments.arguments"/>
            </elementProp>
            <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
            <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
            <stringProp name="HTTPSampler.domain">moulin.nl</stringProp>
            <stringProp name="HTTPSampler.method">GET</stringProp>
            <stringProp name="HTTPSampler.port">443</stringProp>
            <stringProp name="HTTPSampler.protocol">https</stringProp>
            <stringProp name="HTTPSampler.path">/en/</stringProp>
            <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp name="HeaderManager.headers">
                <elementProp name="Cache-Control" elementType="Header">
                  <stringProp name="Header.name">Cache-Control</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="Accept-Encoding" elementType="Header">
                  <stringProp name="Header.name">Accept-Encoding</stringProp>
                  <stringProp name="Header.value">gzip</stringProp>
                </elementProp>
                <elementProp name="Pragma" elementType="Header">
                  <stringProp name="Header.name">Pragma</stringProp>
                  <stringProp name="Header.value">no-cache</stringProp>
                </elementProp>
                <elementProp name="User-Agent" elementType="Header">
                  <stringProp name="Header.name">User-Agent</stringProp>
                  <stringProp name="Header.value">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1</stringProp>
                </elementProp>
                <elementProp name="Accept" elementType="Header">
                  <stringProp name="Header.name">Accept</stringProp>
                  <stringProp name="Header.value">text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</stringProp>
                </elementProp>
              </collectionProp>
            </elementProp>
            <stringProp name="TestPlan.comments">Detected a redirect from the previous sample</stringProp>
            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            <boolProp name="HTTPSampler.image_parser">true</boolProp>
          </HTTPSamplerProxy>
          <hashTree>
            <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
              <collectionProp reference="../../../HTTPSamplerProxy[3]/elementProp[2]/collectionProp"/>
            </HeaderManager>
            <hashTree/>
          </hashTree>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

金融交易可能来自任何一个企业,资产或一般企业,每个企业都有类别,或者可以从一个账户转账到另一个账户。如下所示

1. business, 2. assets, 3. catagory, 4. income, 5. expense, 6. accounts

+----------+---------+    +--------+---------+  +----------+---------+ +----------+---------+ 
| Business | Name    |    | Assets | Name    |  | catagory | Name    | | account  | Name    |
+----------+---------+    +--------+---------+  +----------+---------+ +----------+---------+
| 1        |Business1|    | 1      | Land1   |  | 1        | profit  | | 1        | Bank1   |
| 2        |Business2|    | 2      | Land2   |  | 2        | salary  | | 2        | Bank2   |
| 3        |Business3|    | 3      | Land3   |  | 3        | Rent    | | 3        | Cash    |   
+----------+---------+    +--------+---------+  +----------+---------+ +----------+---------+

等费用

+--------+---------+---------+---------+---------+                             
| Income | From    | Catagory| Account | Amount  |             
+--------+---------+---------+---------+---------+                         
| 1      |Business1|Profit   |Bank1    |  1000   |                 
| 2      |Land1    |Rent     |Bank2    |  500    |                 
| 3      |General  |Salary   |Cash     |  700    |
| 4      |Transfer |Null     |Bank2    |  500    |
+--------+---------+---------+---------+---------+   

这个设计有一些严重的问题,插入后我无法跟踪&#39;收入或支出表中的列。这个领域变得含糊不清。

我必须准备损益表,资产负债表,帐户摘要,业务和资产明智报告,我无法弄清楚如何处理这个数据库或如何修复这些表。

请提供任何建议或想法来修复这些表格结构,以准备我的损益表和资产负债表。

1 个答案:

答案 0 :(得分:1)

选项1(简单方法):创建 来自 {{1}}以区分资产和业务

Option 1

选项2(正确方法):创建 来自 {{1}}以区分资产和业务

Option 2

选项2的最终查询:

{{1}}