⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdo.das.rel.metadata.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Specifying the metadata</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sdo.das.rel.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="sdo.das.rel.examples.one-table.html">One-table examples</a></div> <div class="up"><a href="sdo.das.rel.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="sdo.das.rel.metadata" class="section">  <h2 class="title">Specifying the metadata</h2>  <p class="para">   This first long section describes in detail how the metadata describing    the database and the required SDO model is supplied to the    Relational DAS.  </p>  <p class="para">   When the constructor for the Relational DAS is invoked, it needs to be    passed several pieces of information. The bulk of the information,    passed as an associative array in the first argument to the constructor,    tells the Relational DAS what it needs to know about the relational    database. It describes the names of the tables, columns, primary keys    and foreign keys. It should be fairly easy to understand what is    required, and once written it can be placed in a php file and included    when needed. The remainder of the information, passed in the second    and third arguments to the constructor, tells the Relational DAS what    it needs to know about the relationships between objects and the shape    of the data graph; it ultimately determines how the data from the    database is to be normalised into a graph.  </p>  <div id="sdo.das.rel.metadata.database" class="section">   <h2 class="title">Database metadata</h2>   <p class="para">    The first argument to the constructor describes the target     relational database.   </p>   <p class="para">    Each table is described by an associative array with up to four keys.    <table class="informaltable">     <colgroup>      <thead valign="middle">       <tr valign="middle">        <th colspan="1">Key</th>        <th colspan="1">Value</th>       </tr>      </thead>      <tbody valign="middle" class="tbody">       <tr valign="middle">        <td colspan="1" rowspan="1" align="left">name</td>        <td colspan="1" rowspan="1" align="left">The name of the table.</td>       </tr>       <tr valign="middle">        <td colspan="1" rowspan="1" align="left">columns</td>        <td colspan="1" rowspan="1" align="left">         An array listing the names of the columns, in any order.        </td>       </tr>       <tr valign="middle">        <td colspan="1" rowspan="1" align="left">PK</td>        <td colspan="1" rowspan="1" align="left">The name of the column containing the primary key.</td>       </tr>       <tr valign="middle">        <td colspan="1" rowspan="1" align="left">FK</td>        <td colspan="1" rowspan="1" align="left">An array with two entries, &#039;from&#039; and &#039;to&#039;, which define          a column containing a foreign key, and a table to which the foreign         key points. If there are no foreign keys in the table then the          &#039;FK&#039; entry does not need to be specified. Only one foreign key          can be specified. Only a foreign key pointing to the primary key          of a table can be specified.        </td>       </tr>      </tbody>     </colgroup>    </table>   </p>   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*****************************************************************<br />*&nbsp;METADATA&nbsp;DEFINING&nbsp;THE&nbsp;DATABASE<br />******************************************************************/<br /></span><span style="color: #0000BB">$company_table&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'company'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'columns'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'name'</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #DD0000">'employee_of_the_month'</span><span style="color: #007700">),<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'PK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'FK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'from'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'employee_of_the_month'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'to'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'employee'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;);<br /></span><span style="color: #0000BB">$department_table&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'department'</span><span style="color: #007700">,&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'columns'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'name'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'location'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'number'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'co_id'</span><span style="color: #007700">),<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'PK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'FK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'from'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'co_id'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'to'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'company'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />&nbsp;&nbsp;);<br /></span><span style="color: #0000BB">$employee_table&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'employee'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'columns'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'name'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'SN'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'manager'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'dept_id'</span><span style="color: #007700">),<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'PK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'FK'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'from'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'dept_id'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'to'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'department'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />&nbsp;&nbsp;);<br /></span><span style="color: #0000BB">$database_metadata&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #0000BB">$company_table</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$department_table</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$employee_table</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>   </div>   <p class="para">    This metadata corresponds to a relational database that might have     been defined to MySQL as:   </p>   <div class="example-contents"><div class="cdata"><pre>create table company ( id integer auto_increment, name char(20), employee_of_the_month integer, primary key(id));create table department ( id integer auto_increment, name char(20), location char(10), number integer(3), co_id integer, primary key(id));create table employee ( id integer auto_increment, name char(20), SN char(4), manager tinyint(1), dept_id integer, primary key(id));</pre></div>   </div>   <p class="para">   or to DB2 as:   </p>   <div class="example-contents"><div class="cdata"><pre>create table company ( \  id integer not null generated by default as identity,  \  name varchar(20), \  employee_of_the_month integer, \  primary key(id) )create table department ( \  id integer not null generated by default as identity, \  name varchar(20), \  location varchar(10), \  number integer, \  co_id integer, \  primary key(id) )create table employee ( \  id integer not null generated by default as identity, \  name varchar(20), \  SN char(4), \  manager smallint, \  dept_id integer, \  primary key(id) )</pre></div>   </div>      <p class="para">    Note that although in this example there are no foreign keys specified     to the database and so the database is not expected to enforce     referential integrity, the intention behind the    <var class="varname">co_id</var>    column on the department table and the    <var class="varname">dept_id</var>    column on the employee table is they should contain the primary key     of their containing company or department record, respectively.    So these two columns are acting as foreign keys.   </p>                     <p class="para">    There is a third foreign key in this example, that from the    <var class="varname">employee_of_the_month</var>    column of the company record to a single row of the employee table.    Note the difference in intent between this foreign key and the other     two. The    <var class="varname">employee_of_the_month</var>    column represents a single-valued relationship: there can be only     one employee of the month for a given company.    The    <var class="varname">co_id</var>    and    <var class="varname">dept_id</var>    columns represent multi-valued relationships: a company can contain 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -