{"id":593,"date":"2010-08-24T13:47:00","date_gmt":"2010-08-24T05:47:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=593"},"modified":"2023-11-04T13:48:04","modified_gmt":"2023-11-04T05:48:04","slug":"%e9%97%9c%e8%81%af%e6%a8%a1%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/593","title":{"rendered":"\u95dc\u806f\u6a21\u578b"},"content":{"rendered":"\n<p><strong>\u95dc\u806f\u5f0f\u6a21\u578b<\/strong><br>\u4ee5table(\u8cc7\u6599\u8868)\u7684\u65b9\u5f0f\u4f86\u5448\u73fe<br>\u6b64table\u5728\u95dc\u806f\u5f0f\u6a21\u578b\u4e2d\u7a31\u70ba<br>Relation(\u95dc\u806f)\u6216Entity(\u5be6\u9ad4)<br>ps:IBM Codd\u535a\u58eb\u65bc1970\u767c\u8868<\/p>\n\n\n\n<p><strong>Relational Schema(\u95dc\u806f\u7db1\u8981)<\/strong><br>\u662f\u7531\u6578\u500b\u95dc\u806f\u6240\u7d44\u6210\u7684\u4e00\u500b\u96c6\u5408<\/p>\n\n\n\n<p>\u95dc\u806f\u5f0f\u6a21\u578b\u7684\u5b8c\u6574\u6027\u9650\u5236<br><strong>Key Integrity Constraint(\u9375\u503c\u5b8c\u6574\u6027\u9650\u5236)<\/strong><br>\u9375\u503c\u4e0d\u53ef\u70baNull Value(\u7a7a\u503c)<strong><br>Domain Integrity Constraint(\u9818\u57df\u5b8c\u6574\u6027\u9650\u5236)<\/strong><br>\u5c0d\u65bc\u4e0d\u7b26\u5408\u4eba\u5011\u6240\u671f\u5f85\u7684\u5c6c\u6027\u503c\uff0c\u8981\u88ab\u88ab\u9650\u5236\u8f38\u5165\uff0c\u4ee5\u907f\u514d\u9020\u6210\u7121\u7528\u7684\u8cc7\u6599\u5132\u5b58\u5728\u8cc7\u6599\u5eab\u5167<br>ex:\u5b9a\u7fa9\u59d3\u5225\u53ea\u53ef\u6709\u7537\u6216\u5973\u53ef\u9078<br><strong>Entity Integrity Constraint(\u5be6\u9ad4\u5b8c\u6574\u6027\u9650\u5236)<\/strong><br>\u5728\u540c\u4e00\u95dc\u806f\u4e2d\uff0c\u9375\u503c\u5c6c\u6027\u4e0d\u53ef\u6709\u91cd\u8907\u503c<br><strong>Referential Integrity Constraint(\u53c3\u8003\u5b8c\u6574\u6027\u9650\u5236)<\/strong><br>\u7531\u5b50\u95dc\u806f\u7684FK(Foreign Key,\u5916\u4f86\u9375)\u53c3\u8003\u7236\u95dc\u806f\u7684PK(Primary Key,\u4e3b\u8981\u9375)\u6240\u5f62\u6210\u7684\u4e00\u500bRelationship(\u95dc\u806f\u6027)<br>User-Defined Integrity Constraint(\u4f7f\u7528\u8005\u81ea\u8a02\u7684\u5b8c\u6574\u6027\u9650\u5236)<br>\u4f9d\u64da\u4f7f\u7528\u8005\u7684\u9700\u6c42\uff0c\u984d\u5916\u65b0\u589e\u7684\u9650\u5236\u8cc7\u6599\u7684\u8f38\u5165\uff0c\u4ee5\u4fdd\u6301\u8cc7\u6599\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p><strong>\u95dc\u806f\u8f49\u63db<\/strong><br>ps:<br>E1\u70baentity1<br>A1\u70ba\u7b2c1\u500battribute<br>\u8868\u793a\u8a72attribute\u70baPK<br>.fk\u8868\u793a\u8a72attribute\u70ba\u5916\u4f86\u9375<br>E1.A1\u8868\u793aentity1\u7684\u7b2c\u4e00\u500battribute<\/p>\n\n\n\n<p><strong>1&lt; R&gt;1 \u3000\u8f49\u63db<\/strong><br>\u901a\u5e38\u6703\u5c07\u5169\u500b\u95dc\u806f\u76f4\u63a5\u5408\u4f75\u6210\u4e00\u500b\u95dc\u806f\uff0c\u5728\u5be6\u4f5c\u4e0a\u800c\u8a00\u6703\u589e\u52a0\u5be6\u4f5c\u4e0a\u7684\u6548\u7387\u548c\u7cfb\u7d71\u5be6\u969b\u5728\u904b\u4f5c\u4e0a\u7684\u901f\u5ea6<br>\u683c\u5f0f\u70ba:<br>[E1(A1,A2,&#8230;)] 1&lt; R&gt;1 [E2(E1.A1.fk&nbsp;, A1,&#8230;)]<\/p>\n\n\n\n<p><strong>1&lt; R&gt;n \/ m&lt; R&gt;1 \u8f49\u63db<\/strong><br>\u5c07\u57fa\u6578\u4ee3\u88681\u7684\u4e00\u65b9\uff0c\u5c07\u6b64\u65b9\u95dc\u806f\u4e2d\u7684\u4e3b\u8981\u9375\u5d4c\u5165\u4ee3\u8868\u591a\u7684\u4e00\u65b9\u7684\u95dc\u806f\uff0c\u6210\u70ba\u5916\u4f86\u9375<br>\u683c\u5f0f\u70ba:<br>[E1(A1,A2,&#8230;)] 1&lt; R&gt;n [E2(E1.A1.fk,A1,&#8230;)]<br>[E1(E2.A1.fk,A1,&#8230;)] m&lt; R&gt;1 [E2(A1,A2,&#8230;)]<\/p>\n\n\n\n<p><strong>m&lt; R&gt;n \u8f49\u63db<\/strong><br>\u9700\u8f49\u63db\u62101:M \u548c N:1\u7684\u95dc\u4fc2\uff0c\u4e2d\u9593\u6703\u5f62\u6210\u53e6\u4e00\u500b\u95dc\u806f<br>\u683c\u5f0f\u70ba:<br>[E1(A1,A2,&#8230;)] 1&lt; R&gt;n [E3(E1.A1.fk,E2.A1.fk,A1,&#8230;)] m&lt; R&gt;1 [E2(A1,A2,&#8230;)]<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p>\u95dc\u806f\u5f0f\u8cc7\u6599\u5eab\u8a2d\u8a08\u4e3b\u8981\u554f\u984c<br><strong>\u65b9\u4fbf\u67e5\u8a62<\/strong>:\u5e38\u898b\u7684\u7f3a\u9ede\u70ba\u7570\u52d5\u64cd\u4f5c\u6642\u6703\u51fa\u73fe\u4e0d\u540c\u7684\u7570\u5e38\u73fe\u8c61<br><strong>\u7570\u52d5\u64cd\u4f5c\u6b63\u5e38<\/strong>:\u95dc\u806f\u5207\u5272\u5f8c,\u5e38\u898b\u7684\u7f3a\u9ede\u662f\u67e5\u8a62\u4e0d\u65b9\u4fbf<br>ps:<br>\u7570\u52d5\u64cd\u4f5c\u7684\u7570\u5e38\u70ba:\u65b0\u589e\u7570\u5e38,\u522a\u9664\u7570\u5e38,\u4fee\u6539\u7570\u5e38<\/p>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u5f0f<br><strong>\u6b63\u898f\u5316<\/strong>:\u900f\u904e\u95dc\u806f\u5207\u5272\u89e3\u6c7a\u4e0d\u540c\u7570\u52d5\u7684\u7570\u5e38<br><strong>\u5408\u4f75\u7406\u8ad6<\/strong>:\u89e3\u6c7a\u56e0\u95dc\u806f\u5207\u5272\u5f8c\u9020\u6210\u7684\u67e5\u8a62\u4e0d\u65b9\u4fbf<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p>\u9375\u503c\u5c6c\u6027\u7a2e\u985e<br><strong>SK(super key,\u8d85\u7d1a\u9375)<\/strong><br>\u4e00\u500b\u6216\u591a\u500b\u5c6c\u6027\u82e5\u53ef\u505a\u552f\u4e00\u8b58\u5225\u7684\u96c6\u5408\u5c31\u662fsuper key<br>ex:<br>\u5b78\u865f+\u59d3\u540d+\u79d1\u7cfb ,\u4f7f\u75283\u500b\u5c6c\u6027\u505aSK<br>\u5b78\u865f+\u59d3\u540d ,\u4f7f\u75282\u500b\u5c6c\u6027\u505aSK<br>\u5b78\u865f ,\u4f7f\u75281\u500b\u5c6c\u6027\u505aSK<br><strong>CK(candidate key,\u5019\u9078\u9375)<\/strong><br>\u552f\u4e00\u8b58\u5225\u7684\u6700\u5c0f\u96c6\u5408<br>\u5177\u6709\u6210\u70baprimary key\u8cc7\u683c\u7684\u9375<br>ex:<br>\u5b78\u865f<br>\u8eab\u5206\u8b49\u5b57\u865f<br><strong>PK(primary key,\u4e3b\u9375)<\/strong><br>CK\u7684\u5176\u4e2d\u4e00\u500b<br>ex:\u5b78\u865f<strong><br>FK(forigen key,\u5916\u4f86\u9375)<\/strong><br>\u8a72\u95dc\u806f(\u5b50\u95dc\u806f)\u4e2d\u7684\u5c6c\u6027\u70ba\u53e6\u4e00\u500b\u95dc\u806f(\u7236\u95dc\u806f)\u7684PK\u5373\u70baFK<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95dc\u806f\u5f0f\u6a21\u578b\u4ee5table(\u8cc7\u6599\u8868)\u7684\u65b9\u5f0f\u4f86\u5448\u73fe\u6b64table\u5728\u95dc &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16],"tags":[],"class_list":["post-593","post","type-post","status-publish","format-standard","hentry","category-database"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=593"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}