{"id":11870,"date":"2025-12-19T12:37:40","date_gmt":"2025-12-19T03:37:40","guid":{"rendered":"https:\/\/www.moonmile.net\/blog\/?p=11870"},"modified":"2025-12-30T15:30:20","modified_gmt":"2025-12-30T06:30:20","slug":"%e8%ab%96%e7%90%86%e5%89%8a%e9%99%a4%e3%81%a8%e7%89%a9%e7%90%86%e5%89%8a%e9%99%a4%e3%81%ae%e5%88%87%e3%82%8a%e5%88%86%e3%81%91%e3%82%92%e5%85%b7%e4%bd%93%e4%be%8b%e3%82%92%e7%a4%ba%e3%81%97%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/11870","title":{"rendered":"\u8ad6\u7406\u524a\u9664\u3068\u7269\u7406\u524a\u9664\u306e\u5207\u308a\u5206\u3051\u3092\u5177\u4f53\u4f8b\u3092\u793a\u3057\u3066\u601d\u8003\u5b9f\u9a13\u3059\u308b"},"content":{"rendered":"\n<p>\u304a\u305d\u3089\u304f\u3001\u904e\u53bb\u306b\u305f\u304f\u3055\u3093\u306e\u8a18\u4e8b\u304c\u66f8\u304b\u308c\u3066\u3044\u308b\u3057\u300c\u8ad6\u7406\u524a\u9664\u3068\u306f\uff1f\u300d\u3068\u304b\u3044\u3046\u30d6\u30ed\u30b0\u8a18\u4e8b\u3082\u65e2\u306b\u3042\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u306e\u65b9\u3092\u53c2\u8003\u306b\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001X\/Twitter \u3067\u305f\u3073\u305f\u3073\u708e\u4e0a\u3059\u308b\u306e\u3068\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u3082\u8b70\u8ad6\u304c\u5206\u304b\u308c\u308b\u3068\u3053\u308d\u306a\u306e\u3067\u3001\u79c1\u306a\u308a\u306e\u6307\u91dd\u3092\u793a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6700\u521d\u306b\u65ad\u3063\u3066\u304a\u304d\u307e\u3059\u304c\u3001\u57fa\u672c\u7684\u306b\u79c1\u306f &#8220;\u524a\u9664\u30d5\u30e9\u30b0\u3092\u4f5c\u3089\u306a\u3044&#8221; \u4eba\u3067\u3059\u3002\u53e4\u304f\u304b\u3089 DB \u3092\u8a2d\u8a08\u3057\u3066\u304d\u305f\u4eba\u306b\u3068\u3063\u3066\u5b89\u6613\u306a is_deleted \u30d5\u30e9\u30b0\u306e\u8ffd\u52a0\u306f\u7d50\u69cb\u306a\u9b3c\u9580\u3067\u3059\u3002\u3042\u3068\u300190 \u5e74\u4ee3\u304b\u3089\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u3055\u308f\u3063\u3066\u3044\u308b\u3068\u3001\u30c7\u30fc\u30bf\u91cf\u304c\u591a\u304f\u306a\u308b\u3068\u3044\u3046\u70b9\u3067 is_deleted \u30d5\u30e9\u30b0\u3092\u4f7f\u3044\u307e\u305b\u3093\u3002\u524a\u9664\u3067\u304d\u308b\u30c7\u30fc\u30bf\u306f\u524a\u9664\u3057\u3066\u3057\u307e\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5bb9\u91cf\u3092\u6e1b\u3089\u3059\u307b\u3046\u306b\u91cd\u304d\u3092\u7f6e\u304d\u307e\u3059\u3002<br>\u3057\u304b\u3057\u3001\u6628\u4eca\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u5bb9\u91cf\u306e\u591a\u3055\u3084\u3001\u30c7\u30fc\u30bf\u306e\u30a2\u30af\u30bb\u30b9\u6027\u80fd\u306e\u5411\u4e0a\u3001\u30b3\u30fc\u30c9\u30d5\u30a1\u30fc\u30b9\u30c8\/ORM \u3092\u5229\u7528\u3057\u305f\u958b\u767a\u30b9\u30bf\u30a4\u30eb\u306e\u666e\u53ca\u306b\u3088\u308a\u3001\u8ad6\u7406\u524a\u9664\u3092\u4f7f\u3046\u5834\u9762\u304c\u591a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3086\u3048\u306b\u3001\u73fe\u5728\u3067\u306f\u300c\u3042\u308b\u7a0b\u5ea6\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\/ORM \u3092\u4f7f\u3063\u305f\u958b\u767a\u30b9\u30bf\u30a4\u30eb\u3067\u3042\u308c\u3070\u3001\u8ad6\u7406\u524a\u9664\u3092\u4f7f\u3046\u3053\u3068\u3082\u826f\u3044\u300d\u3068\u8003\u3048\u76f4\u3057\u3066\u3044\u307e\u3059\u3002<br>\u3064\u307e\u308a\u3001\u5834\u5408\u306b\u3088\u308a\u3051\u308a\u3001\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u300c\u5834\u5408\u300d\u3068\u306f\u4e00\u4f53\u306a\u306e\u304b\uff1f\u3000\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u91cf\u306e\u591a\u3055\u3001\u5c11\u306a\u3055\u3001100\u4e07\u4ef6\u4ee5\u4e0a\u3001\u305d\u308c\u4ee5\u4e0b<\/li>\n\n\n\n<li>\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u53c2\u7167\u3055\u308c\u3084\u3059\u3044\u3001\u3055\u308c\u306a\u3044\u3001\u6df1\u3044\u3068\u3053\u308d\u3067\u53c2\u7167\u3055\u308c\u308b<\/li>\n\n\n\n<li>\u524a\u9664\u3055\u308c\u308b\u983b\u5ea6\u306f\u3001\u6975\u5c11\u3001\u306a\u3057\u3001\u983b\u7e41\u30011\/10 \u7a0b\u5ea6<\/li>\n\n\n\n<li>\u30c6\u30fc\u30d6\u30eb\u6570\u306f 100 \u500b\u3050\u3089\u3044\u300120 \u500b\u4ee5\u4e0a<\/li>\n\n\n\n<li>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306f\u3001\u5358\u4e00\u8a00\u8a9e\u3001\u8907\u6570\u7a2e\u985e\u3067\u591a\u8a00\u8a9e<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u306e\u6642\u9593\u6027\u306f\u3001\u3042\u308b\u3001\u306a\u3057<\/li>\n<\/ul>\n\n\n\n<p>\u3068\u3044\u3046\u8996\u70b9\u304c\u3042\u308a\u307e\u3059\u3002\u30c6\u30fc\u30d6\u30eb\u5358\u4f4d\u3067\u9010\u4e00\u8abf\u3079\u308b\u3001\u3042\u308b\u3044\u306f\u958b\u767a\u5358\u4f4d\u3084\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u57fa\u6e96\u306b\u3057\u3066\u8003\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u975e\u5e38\u306b\u9762\u5012\u3067\u3059\u3002\u3048\u3048\u3001\u9762\u5012\u306a\u3093\u3067\u3059\u3088&#8230;\u3053\u308c\u3002\u306a\u306e\u3067\u3001\u5358\u7d14\u306b\u300c\u8ad6\u7406\u524a\u9664\u3092\u3059\u3079\u304d\u304b\u3069\u3046\u304b\uff1f\u300d\u3068\u3044\u3046\u8a71\u3067\u306f\u306a\u3044\u3001\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3092\u5177\u4f53\u7684\u306b\u8003\u5bdf\u3059\u308b\u305f\u3081\u306b\u3001\u5177\u4f53\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u6700\u8fd1\u3067\u306f AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u30b3\u30fc\u30c9\u3092\u51fa\u529b\u3067\u304d\u308b\u306e\u3067\u7d50\u69cb\u77ed\u6642\u9593\u3067\u5b9f\u9a13\u304c\u3067\u304d\u307e\u3059\u3002\u3044\u304f\u3064\u304b\u624b\u5143\u306e AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u81ea\u5206\u306e\u4f7f\u3063\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u8a00\u8a9e\uff06\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u306f\u3001\u5b9f\u4f8b\u3068\u3057\u3066\u3001<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u691c\u7d22\u3001\u793e\u4f1a\u4fdd\u967a\u7b49<\/li>\n\n\n\n<li>\u65c5\u9928\u306e\u4e88\u7d04\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u5de5\u5834\u306e\u90e8\u54c1\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u56de\u8ee2\u5bff\u53f8\u306e\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u7a0e\u52d9\u95a2\u4fc2\u306e\u793e\u5185\u7d4c\u7406\u30b7\u30b9\u30c6\u30e0\u3001\u7d4c\u8cbb\u51e6\u7406<\/li>\n\n\n\n<li>\u793e\u5185\u306e\u30ca\u30ec\u30c3\u30b8\u7ba1\u7406\u3001\u9000\u8077\u8005\u306e\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u3092\u5177\u4f53\u7684\u306b\u8003\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30b3\u30fc\u30c9\u306e\u51fa\u529b\u306f\u4ee5\u4e0b\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP + Laravel + Eloquent ORM<\/li>\n\n\n\n<li>C# + LINQ + Entity Framework<\/li>\n\n\n\n<li>Java + Spring + Hibernate?\uff08\u6700\u8fd1 Java \u3092\u89e6\u308c\u3066\u3044\u306a\u3044\u306e\u3067&#8230;\uff09<\/li>\n\n\n\n<li>Ruby + ActiveRecord<\/li>\n\n\n\n<li>Python + SQLAlchemy ? \uff08\u3053\u308c\u3082\u3088\u304f\u77e5\u3089\u306a\u3044\u3002\u52c9\u5f37\u4e2d\uff09<\/li>\n\n\n\n<li>TypeScript + Node.js + Prisma ? \uff08\u3053\u308c\u3082\u3088\u304f\u77e5\u3089\u306a\u3044\u3002\u52c9\u5f37\u4e2d\uff09<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u307e\u305a\u306f\u524a\u9664\u306e\u624b\u6cd5<\/strong><\/h2>\n\n\n\n<p>\u6700\u521d\u306b\u30c7\u30fc\u30bf\u524a\u9664\u306e\u624b\u6cd5\u3060\u3051\u7d39\u4ecb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u57fa\u672c\u60c5\u5831\u51e6\u7406\u8a66\u9a13\u7684\u306b\u306f\u3001DELETE \u3057\u3066\u3057\u307e\u3046\u306e\u304c\u300c\u7269\u7406\u524a\u9664\u300d\u3001is_delete \u306e\u3088\u3046\u306a\u30d5\u30e9\u30b0\u3092\u4f7f\u3046\u306e\u304c\u300c\u8ad6\u7406\u524a\u9664\u300d\u3068\u8a00\u3044\u307e\u3059\u304c\u3002\u3053\u308c\u306f\u57fa\u672c\u7684\u306a\u77e5\u8b58\u3068\u3057\u3066\u899a\u3048\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7269\u7406\u524a\u9664<\/strong><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nDELETE FROM users WHERE user_id = 12345;\n<\/pre><\/div>\n\n\n<p>\u5358\u7d14\u306b\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u3066\u3057\u307e\u3046\u65b9\u6cd5\u3067\u3059\u3002\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u308b\u306e\u3067\u5f8c\u304b\u3089\u691c\u7d22\u3092\u3057\u305f\u308a\u3059\u308b\u3068\u304d\u306b\u3001\u5909\u306a\u30c7\u30fc\u30bf\u304c\u6b8b\u3063\u3066\u691c\u7d22\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u3055\u3089\u306b\u8a00\u3048\u3070\u3001\u4e07\u304c\u4e00\u30c7\u30fc\u30bf\u304c\u6f0f\u308c\u305f\u3068\u3057\u3066\u3082\u3001\u904e\u53bb\u306e\u30c7\u30fc\u30bf\u306f\u6d88\u3048\u53bb\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u6f0f\u6d29\u30ea\u30b9\u30af\u304c\u6e1b\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSELECT * FROM users ;\n<\/pre><\/div>\n\n\n<p>\u691c\u7d22\u3059\u308b\u3068\u304d\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u5f8c\u304b\u3089\u4f55\u304b\u3092\u5fa9\u6d3b\u3057\u3088\u3046\u3068\u3057\u305f\u308a\u3001\u904e\u53bb\u306e\u30c7\u30fc\u30bf\u3092\u9061\u3063\u3066\u8abf\u3079\u3088\u3046\u3068\u3057\u306a\u3044\u9650\u308a\u306f DELETE \u3092\u4f7f\u3063\u305f\u524a\u9664\u3067\u5341\u5206\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u30d5\u30e9\u30b0\u306b\u3088\u308b\u8ad6\u7406\u524a\u9664<\/strong><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nUPDATE users SET is_deleted = true WHERE user_id = 12345;\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nUPDATE users SET is_deleted = now() WHERE user_id = 12345;\n<\/pre><\/div>\n\n\n<p>is_deleted \u306e\u3088\u3046\u306a\u30d5\u30e9\u30b0\u3092\u4f7f\u3046\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u306d\u3002\u4e0a\u8a18\u306e\u3088\u3046\u306b boolean \u578b\u3067\u8a2d\u5b9a\u3059\u308b\u65b9\u6cd5\u3068\u3001\u524a\u9664\u3057\u305f\u65e5\u4ed8\u3092\u5165\u308c\u3066\u304a\u304f\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<br>is_deleted \u306e\u578b\u3092\u3069\u3046\u8a2d\u5b9a\u3059\u308b\u306e\u304b\u3001NULL \u3092\u8a31\u5bb9\u3059\u308b\u306e\u304b\u3001\u3057\u306a\u3044\u306e\u304b\u3001\u306e\u8a2d\u8a08\u306e\u9055\u3044\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSELECT * FROM users WHERE is_deleted is NULL ;\n<\/pre><\/div>\n\n\n<p>\u5f53\u7136\u691c\u7d22\u3059\u308b\u3068\u304d\u306b is_deleted \u306e\u30c1\u30a7\u30c3\u30af\u304c\u5fc5\u8981\u306a\u306e\u3067\u3072\u3068\u624b\u9593\u304b\u304b\u308a\u307e\u3059\u3002<br>\u3053\u3053\u3092\u5fd8\u308c\u308b\u306e\u304c\u958b\u767a\u4e0a\u306e\u30cd\u30c3\u30af\u306b\u306a\u308a\u307e\u3059\u3002<br>\u7279\u306b\u591a\u4eba\u6570\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u3068\u304d\u3084\u3001\u8907\u6570\u306e\u4f1a\u793e\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u3068\u304d\u306f\u3053\u306e is_deleted \u30c1\u30a7\u30c3\u30af\u3092\u5fd8\u308c\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057\u3001\u3060\u304b\u3089\u30c0\u30e1\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u306f ORM \u306b\u3088\u3063\u3066\u306f\u3001is_delete \u3092\u81ea\u52d5\u7684\u306b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u3001Laravel + Eloquent ORM \u3067\u306f\u3001Soft Delete \u3068\u3044\u3046\u6a5f\u80fd\u304c\u3042\u3063\u3066\u3001<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n$items = $table-&gt;items() ;\n<\/pre><\/div>\n\n\n<p>\u3068\u3044\u3046\u5f62\u3067\u3001\u5185\u90e8\u3067\u306f\u81ea\u52d5\u7684\u306b is_delete \u30c1\u30a7\u30c3\u30af\u304c\u50cd\u3044\u3066\u3044\u307e\u3059\u3002<br>\u307e\u305f\u3001\u96c6\u8a08\u95a2\u6570\u306a\u3069\u3067\u3082\u81ea\u52d5\u7684\u306b is_delete \u30c1\u30a7\u30c3\u30af\u304c\u50cd\u304d\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n$count = $table-&gt;total() ;\n<\/pre><\/div>\n\n\n<p>\u306a\u306e\u3067\u3001&#8221;\u5358\u4e00\u306e\u958b\u767a\u8a00\u8a9e\u3067\u540c\u4e00\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3063\u3066\u3044\u308b&#8221; \u5834\u5408\u9650\u308a\u3001 is_delete \u30d5\u30e9\u30b0\u3092\u4f7f\u3063\u305f\u8ad6\u7406\u524a\u9664\u306f\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002<br>\u9006\u306b\u8a00\u3048\u3070\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u8a00\u8a9e\u3084\u5225\u3005\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3044\u59cb\u3081\u305f\u3068\u304d\u306b\u306f\u3001is_delete \u30c1\u30a7\u30c3\u30af\u304c\u554f\u984c\u306b\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5225\u30c6\u30fc\u30d6\u30eb\u306b\u3088\u308b\u30c7\u30fc\u30bf\u9000\u907f<\/strong><\/h3>\n\n\n\n<p>\u304b\u3064\u3066\u306f\u3001\u5143\u30c7\u30fc\u30bf\u3092\u6b8b\u3057\u305f\u3044\u3068\u304d\u306b\u306f\u5225\u30c6\u30fc\u30d6\u30eb\u306b\u9000\u907f\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<br>\u305f\u3060\u3057\u3001\u3053\u308c\u306f\u524a\u9664\u30c8\u30ea\u30ac\u30fc\u3092\u4f7f\u3046\u3068\u304b\u3057\u306a\u3044\u3068\u7d50\u69cb\u9762\u5012\u304f\u3055\u3044\u306e\u3067\u3001\u524a\u9664\u304c\u3042\u307e\u308a\u767a\u751f\u3057\u306a\u3044\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3057\u3066\u3068\u3044\u3046\u9650\u5b9a\u624b\u6bb5\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<br>\u3042\u3068\u3001\u9000\u907f\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u3092\u5143\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u540c\u3058\u306b\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u3001\u30c6\u30fc\u30d6\u30eb\u8a2d\u8a08\u304c\u610f\u5916\u3068\u9762\u5012\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nBEGIN TRANSACTION;\nINSERT INTO users_deleted SELECT * FROM users WHERE user_id = 12345;\nDELETE FROM users WHERE id = 12345;\nCOMMIT;\n<\/pre><\/div>\n\n\n<p>2\u3064\u306e SQL \u6587\u304c\u5fc5\u305a\u52d5\u304f\u306e\u3067\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u304c\u5fc5\u9808\u3067\u3059\u3002<br>\u3053\u306e\u90e8\u5206\u306f\u3001DELETE \u30c8\u30ea\u30ac\u30fc\u3092\u4f7f\u3063\u305f\u3082\u69cb\u3044\u307e\u305b\u3093\u3002SQL \u3060\u3068\u3001\u3044\u3061\u3044\u3061\u9000\u907f\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u306e\u304c\u9762\u5012\u306a\u306e\u3067\u3001\u30c8\u30ea\u30ac\u30fc\u3092\u4f7f\u3063\u305f\u65b9\u304c\u697d\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u4e00\u6c17\u306b DELETE \u3059\u308b\u3068\u305d\u306e\u5206\u30c8\u30ea\u30ac\u30fc\u3082\u547c\u3073\u51fa\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u305d\u306e\u70b9\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3055\u3089\u306b\u8a00\u3048\u3070\u3001\u3053\u308c\u3067\u306f\u4e0d\u5341\u5206\u3067\u3001users \u30c6\u30fc\u30d6\u30eb\u3067\u306f user_id \u304c\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u4e8c\u91cd\u306b\u30c7\u30fc\u30bf\u3092\u9000\u907f\u3067\u304d\u307e\u305b\u3093\u3002\u4f8b\u3048\u3070\u3001id \u304c\u4e00\u610f\u3001user_id \u304c\u30e6\u30fc\u30b6\u30fc\u306b\u898b\u3048\u308b\u3088\u3046\u306a\u30ad\u30fc\u60c5\u5831\u3060\u3068\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nCREATE TABLE users (\n    id BIGINT PRIMARY KEY,\n    user_id VARCHAR(64) UNIQUE,\n    name VARCHAR(128),\n    ...\n);\n<\/pre><\/div>\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u3001\u9000\u907f\u30c6\u30fc\u30d6\u30eb users_deleted \u3092\u4e8c\u91cd\u306b\u9000\u907f\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u30c6\u30fc\u30d6\u30eb\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nCREATE TABLE users_deleted (\n    users_deleted_id BIGINT PRIMARY KEY,\n    deleted_at TIMESTAMP,\n    id BIGINT,\n    user_id VARCHAR(64),\n    name VARCHAR(128),\n    ...\n);\n<\/pre><\/div>\n\n\n<p>\u9000\u907f\u30c6\u30fc\u30d6\u30eb\u306b\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u3092\u7f6e\u304f\u304b\u3069\u3046\u304b\u3001\u3068\u3044\u3046\u8a2d\u8a08\u3082\u3042\u308a\uff08\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u304c\u306a\u3044\u3068 ORM \u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u591a\u3044\uff09\u3001\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u304c users \u3068 users_deleted \u3067\u7570\u306a\u308a\u307e\u3059\u3002<br>\u3053\u3053\u3082\u8a2d\u8a08\u30eb\u30fc\u30eb\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u306a\u304b\u306a\u304b\u7d71\u4e00\u6027\u3092\u4fdd\u3064\u306e\u306f\u96e3\u3057\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u88dc\u52a9\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3046<\/strong><\/h3>\n\n\n\n<p>\u5b9f\u306f is_deleted \u30d5\u30e9\u30b0\u81ea\u4f53\u306f\u3001\u4e3b\u4f53\u3068\u306a\u308b user \u60c5\u5831\u306e\u88dc\u52a9\u3067\u3042\u308b\u306e\u3067\u3001\u88dc\u52a9\u30c6\u30fc\u30d6\u30eb\u3068\u3057\u3066\u6b63\u898f\u5316\u3057\u3066\u3057\u307e\u3046\u306e\u3082\u3072\u3068\u3064\u306e\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nCREATE TABLE users (\n    id BIGINT PRIMARY KEY,\n    user_id VARCHAR(64) UNIQUE,\n    name VARCHAR(128),\n    ...\n);\nCREATE TABLE users_status (\n    user_id BIGINT PRIMARY KEY,\n    is_deleted BOOLEAN,\n    deleted_at TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES users(id)\n);\n<\/pre><\/div>\n\n\n<p>\u5e38\u306b users \u3068 users_status \u3092 JOIN \u3057\u3066\u4f7f\u308f\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u304c\u9762\u5012\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001users \u30c6\u30fc\u30d6\u30eb\u306e\u5185\u5bb9\u304c\u660e\u78ba\u306b\u306a\u308a\u307e\u3059\u3002\u3042\u308b\u610f\u5473\u3067\u3001\u4e00\u5ea6\u4f5c\u6210\u3057\u305f\u3089\u7d76\u5bfe\u306b\u6d88\u3048\u307e\u305b\u3093\u3002<br>\u3042\u3068\u3001\u672c\u6765\u306f\u30ab\u30fc\u30c9\u756a\u53f7\u3068\u304b\u4f4f\u6240\u3068\u304b\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u5206\u96e2\u3057\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u826f\u3044\u60c5\u5831\u3092\u3001users_status \u30c6\u30fc\u30d6\u30eb\u306b\u4fdd\u6301\u3057\u3066\u304a\u304f\u3068\u6f0f\u6d29\u306e\u30ea\u30b9\u30af\u304c\u6e1b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306f\u3001\u3042\u304f\u307e\u3067\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u624b\u6cd5\u3067\u3042\u3063\u305f\u308a\u3001\u30c7\u30fc\u30bf\u3092\u5fa9\u6d3b\u3059\u308b\u3088\u3046\u306a\u5834\u9762\u304c\u3042\u3063\u305f\u3089\u3069\u3046\u3059\u308b\u306e\u304b\uff1f\u3000\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u78ba\u4fdd\u3084\u958b\u767a\u6642\u306e\u30df\u30b9\u3092\u3069\u306e\u3088\u3046\u306b\u9632\u3050\u306e\u304b\uff1f\u3000\u3068\u3044\u3046\u90e8\u5206\u6700\u9069\u5316\u306e\u8a71\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u3001\u3072\u3068\u3064\u306e\u958b\u767a\u624b\u6cd5\u3068\u3057\u3066\u306f\u3001<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7269\u7406\u524a\u9664\u3059\u308b\u306a\u3089\u3070\u3001\u5168\u4f53\u3092\u7269\u7406\u524a\u9664\u3067\u7d71\u4e00\u3059\u308b<\/li>\n\n\n\n<li>is_deleted \u30d5\u30e9\u30b0\u3092\u4f7f\u3046\u8ad6\u7406\u524a\u9664\u306a\u3089\u3070\u3001\u5168\u4f53\u3092\u8ad6\u7406\u524a\u9664\u3067\u7d71\u4e00\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<p>\u306e\u304c\u3072\u3068\u3064\u306e\u624b\u6bb5\u3067\u3059\u3002<br>\u3053\u308c\u3060\u3068\u8a71\u304c\u7c21\u5358\u306a\u306e\u3067\u3059\u304c\u3001\u5f53\u7136\u3001\u305d\u308c\u305e\u308c\u306e\u5834\u9762\u304c\u3042\u308a\u30d1\u30fc\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3084\u958b\u767a\u30df\u30b9\u306a\u3069\u3092\u8003\u616e\u3059\u308b\u3068\u3001\u305d\u3046\u3067\u3082\u306a\u3044\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5177\u4f53\u4f8b\u3092\u3042\u3066\u306f\u3081\u3066\u307f\u308b<\/strong><\/h2>\n\n\n\n<p>\u3067\u306f\u3001\u6700\u521d\u306b\u793a\u3057\u305f\u3088\u3046\u306b\u5177\u4f53\u4f8b\u3092\u5f53\u3066\u306f\u3081\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u691c\u7d22\u3001\u793e\u4f1a\u4fdd\u967a\u7b49<\/li>\n\n\n\n<li>\u65c5\u9928\u306e\u4e88\u7d04\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u5de5\u5834\u306e\u90e8\u54c1\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u56de\u8ee2\u5bff\u53f8\u306e\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u7a0e\u52d9\u95a2\u4fc2\u306e\u793e\u5185\u7d4c\u7406\u30b7\u30b9\u30c6\u30e0\u3001\u7d4c\u8cbb\u51e6\u7406<\/li>\n\n\n\n<li>\u793e\u5185\u306e\u30ca\u30ec\u30c3\u30b8\u7ba1\u7406\u3001\u9000\u8077\u8005\u306e\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u30c7\u30fc\u30bf\u91cf\u3084\u6642\u9593\u8ef8\u306e\u6709\u7121\u306a\u3069\u3082\u95a2\u4fc2\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3053\u306f\u5177\u4f53\u4f8b\u3092\u307f\u305f\u307b\u3046\u304c\u30a4\u30e1\u30fc\u30b8\u3057\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br>SQL \u6587\u3084\u30a2\u30af\u30bb\u30b9\u306e\u305f\u3081\u306e ORM \u30b3\u30fc\u30c9\u3092 AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u66f8\u304d\u51fa\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u6614\u306f\u3001\u624b\u4f5c\u696d\u3067\u3061\u307e\u3061\u307e\u6574\u5408\u6027\u3092\u78ba\u8a8d\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4eca\u3060\u3068 OpenAPI.xml \u3092\u4f5c\u6210\u3057\u3066 MVC \u30de\u30c3\u30d4\u30f3\u30b0\u306e\u30b3\u30fc\u30c9\u3092\u51fa\u529b\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305d\u306e\u306a\u304b\u3067 ORM \u3084 SQL \u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u62bd\u51fa\u3092\u8a66\u3057\u3066\u307f\u308b\u3068\u3088\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001\u79c1\u306e\u90fd\u5408\u4e0a Laravel + Eloquent ORM \u306e\u4f8b\u3092\u793a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u691c\u7d22\u3001\u793e\u4f1a\u4fdd\u967a\u7b49<\/strong><\/h3>\n\n\n\n<p>\u5b9f\u306f\u81ea\u6cbb\u4f53\u306e\u30ac\u30d0\u30af\u30e9\u3067\u300c\u8ad6\u7406\u524a\u9664\u300d\u304c\u7d50\u69cb\u63c9\u3081\u3066\u3044\u305f\u6642\u671f\u304c\u3042\u308a\u307e\u3059\u3002\u6700\u7d42\u7684\u306b\u306f\u6c7a\u88c2\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3055\u3066\u3001\u305d\u308c\u304b\u3089\u3069\u3046\u306a\u3063\u305f\u306e\u304b\u306f\u79c1\u306f\u77e5\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u8981\u306f\u3001\u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u60c5\u5831\u306f\u300c\u8abf\u3079\u305f\u3068\u304d\u306e\u305d\u306e\u6642\u306e\u60c5\u5831\u300d\u306b\u306a\u308a\u307e\u3059\u3002\u904e\u53bb\u306e\u9061\u3063\u3066\u8ee2\u51fa\u3057\u3066\u3057\u307e\u3063\u305f\u4f4f\u6c11\u306e\u60c5\u5831\u3092\u8abf\u3079\u308b\u3053\u3068\u306f&#8230;\u3067\u304d\u306a\u304f\u3082\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3089\u3092 Web API \u3067\u63d0\u4f9b\u3059\u308b\u304b\u3069\u3046\u304b\u3068\u3044\u3046\u8a71\u306b\u306a\u308a\u307e\u3059\u3002\u30ac\u30d0\u30af\u30e9\u3067\u3001\u305d\u306e API \u4ed5\u69d8\u304c\u3042\u3063\u305f\u306e\u304c\u305d\u306e\u3042\u305f\u308a\u306e\u96e3\u70b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u6cbb\u4f53\u3067\u306e\u4f4f\u6c11\u60c5\u5831\u306e\u7ba1\u7406<\/li>\n\n\n\n<li>\u4f4f\u6c11\u306e\u5165\u9000\u51fa\u306e\u60c5\u5831<\/li>\n\n\n\n<li>\u793e\u4f1a\u4fdd\u967a\u306e\u52a0\u5165\u3001\u8131\u9000\u306e\u60c5\u5831<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u60c5\u5831\u30b9\u30ad\u30fc\u30de\u4f8b\nCREATE TABLE residents (    -- \u4f4f\u6c11\u57fa\u672c\u53f0\u5e33\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    resident_id VARCHAR(64) UNIQUE NOT NULL,\n    name VARCHAR(128) NOT NULL,\n    address VARCHAR(255) NOT NULL,\n    birth_date DATE NOT NULL,\n    status ENUM(&#039;active&#039;, &#039;moved_out&#039;, &#039;deceased&#039;) DEFAULT &#039;active&#039;,\n    registered_at TIMESTAMP NOT NULL,\n    status_changed_at TIMESTAMP NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    deleted_at TIMESTAMP NULL\n);\n\nCREATE TABLE resident_histories ( -- \u4f4f\u6c11\u306e\u5165\u9000\u51fa\u5c65\u6b74\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    resident_id BIGINT NOT NULL,\n    event_type ENUM(&#039;registration&#039;, &#039;move_in&#039;, &#039;move_out&#039;, &#039;status_change&#039;) NOT NULL,\n    address VARCHAR(255) NULL,\n    event_date TIMESTAMP NOT NULL,\n    remarks TEXT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (resident_id) REFERENCES residents(id)\n);\n\nCREATE TABLE insurance_records ( -- \u793e\u4f1a\u4fdd\u967a\u52a0\u5165\u5c65\u6b74\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    resident_id BIGINT NOT NULL,\n    insurance_type VARCHAR(64) NOT NULL,\n    status ENUM(&#039;enrolled&#039;, &#039;withdrawn&#039;) DEFAULT &#039;enrolled&#039;,\n    enrolled_date DATE NOT NULL,\n    withdrawn_date DATE NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (resident_id) REFERENCES residents(id)\n);\n<\/pre><\/div>\n\n\n<p>residents \u4f4f\u6c11\u57fa\u672c\u53f0\u5e33\u306b\u306f deleted_at \u30ab\u30e9\u30e0\u3092\u8a2d\u3051\u3066\u8ad6\u7406\u524a\u9664\u3092\u53ef\u80fd\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f\u30b9\u30c6\u30fc\u30bf\u30b9 status \u30ab\u30e9\u30e0\u3067\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u3067\u306f\u3001\u4f4f\u6c11\u304c\u81ea\u6cbb\u4f53\u306b\u3044\u308b\u3068\u304d\u306f\u300cactive\u300d\u306b\u306a\u308b\u306e\u3067\u3001\u5fc5\u305a where status = &#8216;active&#8217; \u306e\u691c\u7d22\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u3001\u4f4f\u6c11\u304c 30 \u4e07\u4eba\u7a0b\u5ea6\u3060\u3068\u3057\u3066\u3082\u3001\u8ee2\u51fa\u3084\u8ee2\u5165\u3001\u6b7b\u4ea1\u306a\u3069\u3082\u542b\u3081\u308c\u3070\u6bce\u5e74\u7d50\u69cb\u306a\u91cf\u306b\u306a\u308a\u307e\u3059\u3088\u306d\u3002\u5927\u62b5\u306f active \u306a\u7b48\u3067\u3059\u304c\u3001\u9577\u5e74\u4f7f\u3063\u3066\u3044\u308b\u3068 active \u4ee5\u5916\u304c\u591a\u304f\u306a\u308a\u305d\u3046\u306a\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u500b\u4eba\u306e\u4e00\u610f\u6027\u306f\u3001residents.resident_id \u3067\u7279\u5b9a\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u4ed6\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3046\u3053\u3068\u3082\u53ef\u80fd\u306a\u306e\u3067\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u5f85\u3063\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u500b\u4eba\u304c\u3001\u540c\u3058\u81ea\u6cbb\u4f53\u306b\u8ee2\u51fa\u2192\u8ee2\u5165\u3092\u3057\u305f\u3068\u304d\u306f\u3069\u3046\u306a\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<br>\u3072\u3068\u308a\u306e\u500b\u4eba\u306b\u5bfe\u3057\u3066\u3001\u3075\u305f\u3064\u4ee5\u4e0a\u306e resident_id \u306b\u306a\u308a\u307e\u3059\u3002<br>\u306a\u306e\u3067\u3001\u5c65\u6b74\u81ea\u4f53\u3092 resident_histories \u3084 insurance_records \u30c6\u30fc\u30d6\u30eb\u3067\u4fdd\u6301\u3067\u304d\u308b\u3088\u3046\u306b\u7ba1\u7406\u3057\u3066\u3044\u3066\u300c\u3072\u3068\u308a\u306e\u500b\u4eba\u306e\u904e\u53bb\u306e\u5c65\u6b74\u3092\u53d6\u3063\u3066\u304f\u308b\u300d\u3053\u3068\u304c\u4e00\u898b\u3067\u304d\u305d\u3046\u306a\u611f\u3058\u304c\u3057\u3066\u3044\u3066\u3001\u5b9f\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- residents.resident_id \u3092\u6307\u5b9a\u3057\u3066\u3001\u4f4f\u6c11\u306e\u5165\u9000\u51fa\u5c65\u6b74\u3068\u793e\u4f1a\u4fdd\u967a\u52a0\u5165\u5c65\u6b74\u3092\u53d6\u5f97\u3059\u308b\u4f8b\nSELECT rh.*, ir.*\nFROM residents r\nLEFT JOIN resident_histories rh ON r.id = rh.resident_id\nLEFT JOIN insurance_records ir ON r.id = ir.resident_id\nWHERE r.resident_id in ( &#039;some_resident_id&#039;, &#039;another_resident_id&#039; )\n  AND r.status = &#039;active&#039;;\n<\/pre><\/div>\n\n\n<p>\u3053\u306e\u5834\u5408\u3001residents.is_deleted \u30c1\u30a7\u30c3\u30af\u306f\u3001\u4f55\u3092\u610f\u5473\u3059\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<br>\u65e2\u306b\u3001\u4f4f\u6c11\u3067\u3042\u308b\u304b\u5426\u304b\u306f status \u30ab\u30e9\u30e0\u3068\u3057\u3066\u7528\u610f\u3057\u3066\u3042\u308b\u306e\u3067\u3001is_delete \u306f\u4f4f\u6c11\u306e\u6709\u7121\u3092\u3057\u3081\u3057\u307e\u305b\u3093\u3002<br>\u5229\u7528\u30d1\u30bf\u30fc\u30f3\u3068\u3057\u3066\u306f\u3001\u300c\u4e00\u6642\u7684\u306b\u8ee2\u5165\u60c5\u5831\u3092\u500b\u4eba\u3068\u3057\u3066\u5165\u308c\u3066\u304a\u3044\u305f\u304c\u3001\u5b9f\u306f\u30c7\u30fc\u30bf\u306e\u9593\u9055\u3044\u304c\u767a\u751f\u3057\u305f\u306e\u3092\u524a\u9664\u3057\u3088\u3046\u3068\u3057\u305f\u300d\u3050\u3089\u3044\u3068\u601d\u308f\u308c\u307e\u3059\u3002<br>\u3064\u307e\u308a\u3001\u3053\u306e is_delete \u30d5\u30e9\u30b0\u306f\u3001\u4f4f\u6c11\u57fa\u672c\u53f0\u5e33\u306e\u30c7\u30fc\u30bf\u3068\u3057\u3066\u306f\u304b\u306a\u308a\u88dc\u52a9\u7684\u306a\u5f79\u5272\u3092\u793a\u3057\u3066\u3044\u308b\u3068\u8003\u3048\u3089\u308c\u3001status \u7684\u306a\u610f\u5473\u3068\u306f\u7570\u306a\u308a\u307e\u3059\u3002\u66f4\u306b\u8a00\u3048\u3070\u3001\u5f8c\u304b\u3089\u623b\u3059\u3053\u3068\u3082\u8003\u3048\u3089\u308c\u307e\u305b\u3093\u3002\u8ee2\u51fa\u3057\u305f\u3068\u304d\u306e\u30c7\u30fc\u30bf\u306f status \u3067\u7ba1\u7406\u3059\u308b\u306e\u3067\u3059\u304b\u3089\u3001\u4f4f\u6c11\u57fa\u672c\u53f0\u5e33\u3067\u3042\u308b residents \u30c6\u30fc\u30d6\u30eb\u306f &#8220;\u6d88\u3055\u308c\u308b\u3053\u3068\u304c\u306a\u3044&#8221; \u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br>\u30c7\u30fc\u30bf\u3068\u3057\u3066\u5897\u52a0\u3057\u7d9a\u3051\u308b\u306e\u306f\u5bb9\u91cf\u7684\u306b\u554f\u984c\u3060\u3068\u306f\u601d\u3044\u307e\u3059\u304c\u3001\u305f\u304b\u3060\u304b 30 \u4e07\u4eba\uff0810\u5e74\u5f8c\u3060\u3063\u305f\u3068\u3057\u3066\u3082 300 \u4e07\u4eba\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u306f\u306a\u3089\u306a\u3044\u3067\u3057\u3087\u3046\uff09\u3050\u3089\u3044\u306a\u3089\u3070\u3001\u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u5341\u5206\u306b\u3068\u3063\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3046\u3044\u3046\u8a66\u7b97\u3092\u3057\u305f\u3046\u3048\u3067\u3001residents.is_deleted \u30d5\u30e9\u30b0\u306f\u4e0d\u8981\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u81ea\u6cbb\u4f53\u306e\u4f4f\u6c11\u60c5\u5831\u30b9\u30ad\u30fc\u30de\u4f8b\nCREATE TABLE residents (    -- \u4f4f\u6c11\u57fa\u672c\u53f0\u5e33\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    resident_id VARCHAR(64) UNIQUE NOT NULL,\n    name VARCHAR(128) NOT NULL,\n    address VARCHAR(255) NOT NULL,\n    birth_date DATE NOT NULL,\n    status ENUM(&#039;active&#039;, &#039;moved_out&#039;, &#039;deceased&#039;) DEFAULT &#039;active&#039;,\n    registered_at TIMESTAMP NOT NULL,\n    status_changed_at TIMESTAMP NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n<\/pre><\/div>\n\n\n<p>\u3055\u3089\u306b\u3001\u81ea\u6cbb\u4f53\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u306f\u3001\u5358\u4e00\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304b\u3089\u3060\u3051\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002\u5c06\u6765\u7684\u306b\u3055\u307e\u3056\u307e\u306a\u696d\u8005\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u3053\u3068\u306b\u306a\u308b\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001is_delete \u30d5\u30e9\u30b0\u306e\u5229\u7528\u6709\u7121\u3092\u8003\u3048\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u65c5\u9928\u306e\u4e88\u7d04\u30b7\u30b9\u30c6\u30e0<\/strong><\/h3>\n\n\n\n<p>\u4eca\u5ea6\u306f\u3001\u65c5\u9928\u306e\u4e88\u7d04\u30b7\u30b9\u30c6\u30e0\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002WEB \u30b5\u30a4\u30c8\u304b\u3089\u65c5\u9928\u3092\u4e88\u7d04\u3057\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u90e8\u5c4b\u306e\u7a7a\u304d\u304c\u3042\u308b\u3068\u3053\u308d\u3092\u9078\u3093\u3067\u4e88\u7d04\u3057\u307e\u3059\u3002\u5f53\u7136\u3001\u30e6\u30fc\u30b6\u30fc\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981\u306b\u306a\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u3088\u308b\u30ad\u30e3\u30f3\u30bb\u30eb\u3082\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u65c5\u9928\u306e\u90e8\u5c4b\u60c5\u5831<\/li>\n\n\n\n<li>\u90e8\u5c4b\u306e\u7a7a\u304d\/\u4e88\u7d04\u60c5\u5831<\/li>\n\n\n\n<li>\u4e88\u7d04\u30ab\u30ec\u30f3\u30c0\u30fc<\/li>\n\n\n\n<li>\u30e6\u30fc\u30b6\u30fc\u60c5\u5831<\/li>\n\n\n\n<li>\u30e6\u30fc\u30b6\u30fc\u306e\u4e88\u7d04\u5c65\u6b74<\/li>\n\n\n\n<li>\u30e6\u30fc\u30b6\u30fc\u306e\u30ad\u30e3\u30f3\u30bb\u30eb\u5c65\u6b74\uff08\u3084\u3063\u3071\u308a\u4e88\u7d04\u3057\u305f\u3044\u3068\u304b\uff09<\/li>\n<\/ul>\n\n\n\n<p>AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u3001DDL \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u3001\u65c5\u9928\u306e\u90e8\u5c4b\u306e\u4fa1\u683c\u304c\u671f\u9593\u306b\u3088\u3063\u3066\u7570\u306a\u308b\u306e\u3067\u3053\u308c\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u65c5\u9928\u306e\u90e8\u5c4b\u60c5\u5831\nCREATE TABLE rooms (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    room_number VARCHAR(64) UNIQUE NOT NULL,\n    room_type VARCHAR(64) NOT NULL,\n    capacity INT NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n\nCREATE TABLE room_pricing (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    room_id BIGINT NOT NULL,\n    season_start_date DATE NOT NULL,\n    season_end_date DATE NOT NULL,\n    price DECIMAL(10, 2) NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (room_id) REFERENCES rooms(id),\n    UNIQUE KEY unique_pricing (room_id, season_start_date, season_end_date)\n);\n\n-- \u4e88\u7d04\u60c5\u5831\nCREATE TABLE reservations (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    user_id BIGINT NOT NULL,\n    room_id BIGINT NOT NULL,\n    check_in_date DATE NOT NULL,\n    check_out_date DATE NOT NULL,\n    status ENUM(&#039;confirmed&#039;, &#039;cancelled&#039;, &#039;completed&#039;) DEFAULT &#039;confirmed&#039;,\n    reserved_at TIMESTAMP NOT NULL,\n    cancelled_at TIMESTAMP NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES users(id),\n    FOREIGN KEY (room_id) REFERENCES rooms(id),\n    UNIQUE KEY unique_reservation (room_id, check_in_date, check_out_date)\n);\n\n-- \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\nCREATE TABLE users (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    username VARCHAR(128) UNIQUE NOT NULL,\n    email VARCHAR(255) UNIQUE NOT NULL,\n    name VARCHAR(128) NOT NULL,\n    phone VARCHAR(20) NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n\n-- \u30ad\u30e3\u30f3\u30bb\u30eb\u5c65\u6b74\nCREATE TABLE cancellation_history (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    reservation_id BIGINT NOT NULL,\n    cancelled_at TIMESTAMP NOT NULL,\n    reason TEXT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    FOREIGN KEY (reservation_id) REFERENCES reservations(id)\n);\n<\/pre><\/div>\n\n\n<p>\u3053\u3053\u3067\u3001\u90e8\u5c4b rooms \u3068\u90e8\u5c4b\u306e\u4fa1\u683c room_pricing \u306f\u3001\u57fa\u672c\u7684\u306b\u524a\u9664\u3055\u308c\u306a\u3044\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u3044\u3084\u3001\u305d\u3093\u306a\u3053\u3068\u306f\u306a\u3044\u3067\u3059\u3088\u306d\u3002\u90e8\u5c4b\u304c\u8001\u673d\u5316\u3057\u3066\u4f7f\u3048\u306a\u304f\u306a\u3063\u305f\u308a\u3001\u65c5\u9928\u81ea\u4f53\u304c\u9589\u9396\u3055\u308c\u305f\u308a\u3059\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u3046\u3044\u3046\u5834\u5408\u306f\u3001rooms \u30c6\u30fc\u30d6\u30eb\u304b\u3089\u524a\u9664\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002\u3057\u304b\u3057\u3001\u524a\u9664\u3057\u3066\u3057\u307e\u3046\u3068\u904e\u53bb\u306e\u90e8\u5c4b\u306e\u4e88\u7d04\u5c65\u6b74\u304c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002id \u306e\u30ea\u30f3\u30af\u304c\u5916\u308c\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3059\u3002<br>\u3053\u306e\u5834\u5408\u3001rooms.id \u3092\u6b8b\u3057\u3064\u3064\u3001\u540c\u3058 room_number \u3092\u518d\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3002<br>\u3053\u3053\u3067\u3001is_deleted \u30d5\u30e9\u30b0\u3092\u4f7f\u3046\u306e\u304b\u3001\u5225\u30c6\u30fc\u30d6\u30eb\u306b\u9000\u907f\u3059\u308b\u306e\u304b\u3068\u3044\u3046\u8a2d\u8a08\u306e\u9078\u629e\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<br>rooms \u306e\u4e00\u610f\u6027\u3092\u78ba\u4fdd\u3057\u305f\u3044\u5834\u5408\u306b\u306f\u3001\u5225\u30c6\u30fc\u30d6\u30eb\u306b\u9000\u907f\u3057\u3066\u3001\u904e\u53bb\u306e\u7d4c\u7406\u60c5\u5831\u3092\u8abf\u3079\u308b\u3068\u304d\u306b\u306f\u9000\u907f\u30c6\u30fc\u30d6\u30eb\u306e\u307b\u3046\u3082\u53c2\u7167\u3059\u308b\u3001\u3068\u3044\u3046\u8a2d\u8a08\u306b\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br>\u305f\u3060\u3057\u3001rooms \u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u6570\u306f\u975e\u5e38\u306b\u5c11\u306a\u3044\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002\u3055\u3089\u306b\u8a00\u3048\u3070\u3001\u983b\u7e41\u306b\u5909\u308f\u308b\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3092\u8003\u616e\u3057\u305f\u3046\u3048\u3067 rooms \u30c6\u30fc\u30d6\u30eb\u306b is_deleted \u30d5\u30e9\u30b0\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u3087\u3046\uff08\u3082\u3061\u308d\u3093\u3001\u9006\u306b is_deleted \u30d5\u30e9\u30b0\u3092\u8ffd\u52a0\u3057\u306a\u3044\u8a2d\u8a08\u3082\u3042\u308a\u3048\u307e\u3059\uff09\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u65c5\u9928\u306e\u90e8\u5c4b\u60c5\u5831\uff08\u524a\u9664\u3092\u8003\u616e\uff09\nCREATE TABLE rooms (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    room_number VARCHAR(64) NOT NULL,\n    room_type VARCHAR(64) NOT NULL,\n    capacity INT NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    deleted_at TIMESTAMP NULL\n);\n<\/pre><\/div>\n\n\n<p>room_number \u304c\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u306b\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br>\u305f\u3060\u3057\u3001\u904e\u53bb\u3082\u542b\u3081\u3066 room_number \u3060\u3051\u3067\u691c\u7d22\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u904e\u53bb\u306e\u5e74\u9593\u306e\u4e88\u7d04\u72b6\u6cc1\u3092\u8abf\u3079\u308b\u3068\u304d\u306b\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n--\u3000\u904e\u53bb\u306e\u90e8\u5c4b\u306e\u4e88\u7d04\u72b6\u6cc1\u3092\u8abf\u3079\u308b\u4f8b\nSELECT r.room_number, res.check_in_date, res.check_out_date, res.status\nFROM rooms r\nLEFT JOIN reservations res ON r.id = res.room_id\nWHERE r.room_number = &#039;101&#039;\nAND res.status = &#039;completed&#039;  -- \u5b8c\u4e86\u3057\u305f\u4e88\u7d04\u306e\u307f\nAND res.check_in_date between &#039;2023-01-01&#039; AND &#039;2023-12-31&#039;\nORDER BY res.check_in_date DESC;\n<\/pre><\/div>\n\n\n<p>\u904e\u53bb\u306e\u5834\u5408\u306f is_delete \u306e\u30c1\u30a7\u30c3\u30af\u3092\u5916\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u9006\u306b\u8a00\u3048\u3070\u3001\u73fe\u5728\u5229\u7528\u3067\u304d\u308b rooms \u306e\u30ea\u30b9\u30c8\u3067\u306f is_deleted \u30c1\u30a7\u30c3\u30af\u304c\u5fc5\u9808\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u73fe\u5728\u5229\u7528\u53ef\u80fd\u306a\u90e8\u5c4b\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u4f8b\nSELECT *\nFROM rooms\nWHERE deleted_at IS NULL;\n<\/pre><\/div>\n\n\n<p>\u3053\u308c\u306f\u3001\u3069\u3061\u3089\u3092\u4e3b\u8981\u306b\u4f7f\u3046\u304b\u3067\u3059\u306d\u3002<br>\u4e3b\u306b\u7d4c\u7406\u7cfb\u3084\u904e\u53bb\u306e\u53d6\u5f15\u5c65\u6b74\u306a\u3069\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u5834\u5408\u306f\u3001is_deleted \u30d5\u30e9\u30b0\u3092\u4f7f\u3063\u305f\u307b\u3046\u304c\u4fbf\u5229\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5de5\u5834\u306e\u90e8\u54c1\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/strong><\/h3>\n\n\n\n<p>\u904e\u53bb\u306e\u30c7\u30fc\u30bf\u3092\u9061\u3089\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u306f\u3001\u304a\u305d\u3089\u304f\u5de5\u5834\u306e BOM \u95a2\u4fc2\u306e\u30b7\u30b9\u30c6\u30e0\u3067\u3059\u3002<br>\u90e8\u54c1\u81ea\u4f53\u306f BOM \u60c5\u5831\u3068\u3057\u3066\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304c\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u904e\u53bb\u306e\u53d7\u6ce8\u72b6\u614b\u3092\u9867\u5ba2\u304b\u3089\u8abf\u3079\u308b\u3068\u304d\u306b\u306f BOM \u8868\u306b\u306a\u3044\u30c7\u30fc\u30bf\u3082\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u306f\u3001\u751f\u7523\u7d42\u4e86\u3057\u305f\u3082\u306e\u3082\u542b\u3081\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u3001\u3053\u3053\u3082 BOM \u30c6\u30fc\u30d6\u30eb\u306b\u6b8b\u3055\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<br>\u3053\u308c\u3082\u3001\u73fe\u5728\u6301\u3063\u3066\u3044\u308b\u90e8\u54c1\u3068\u3001\u751f\u7523\u4e2d\u6b62\u3057\u305f\u90e8\u54c1\u3092\u5225\u30c6\u30fc\u30d6\u30eb\u306b\u6301\u3064\u3053\u3068\u3082\u53ef\u80fd\u306a\u306e\u3067\u3059\u304c\u3001\u304b\u306a\u308a\u7169\u96d1\u3067\u3059\u3002\u90e8\u54c1\u306b\u95a2\u9023\u3059\u308b\u60c5\u5831\u304c\u5e38\u306b\u88dc\u52a9\u30c6\u30fc\u30d6\u30eb\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u90e8\u54c1\u30de\u30b9\u30bf\u30fc<\/li>\n\n\n\n<li>\u90e8\u54c1\u88dc\u52a9\u60c5\u5831<\/li>\n\n\n\n<li>\u90e8\u54c1\u306e\u8abf\u9054\u5148<\/li>\n\n\n\n<li>\u53d7\u6ce8\u60c5\u5831<\/li>\n\n\n\n<li>\u90e8\u54c1\u751f\u7523\u7ba1\u7406<\/li>\n\n\n\n<li>\u90e8\u54c1\u306e\u7d44\u307f\u5408\u308f\u305b\u30c6\u30fc\u30d6\u30eb<\/li>\n\n\n\n<li>\u53d7\u6ce8\u7d44\u307f\u3042\u308f\u305b\u756a\u53f7\u7ba1\u7406<\/li>\n\n\n\n<li> \u9867\u5ba2\u767a\u6ce8\u5c65\u6b74<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3067 AI \u306b\u4f5c\u6210\u3057\u3066\u8cb0\u3044\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- \u90e8\u54c1\u30de\u30b9\u30bf\u30fc\nCREATE TABLE parts (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    part_number VARCHAR(64) UNIQUE NOT NULL,\n    part_name VARCHAR(255) NOT NULL,\n    description TEXT NULL,\n    unit_price DECIMAL(10, 2) NOT NULL,\n    lead_time_days INT DEFAULT 0,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    deleted_at TIMESTAMP NULL\n);\n\n-- \u90e8\u54c1\u88dc\u52a9\u60c5\u5831\nCREATE TABLE part_details (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    part_id BIGINT NOT NULL,\n    weight DECIMAL(10, 4) NULL,\n    dimensions VARCHAR(255) NULL,\n    material VARCHAR(128) NULL,\n    storage_location VARCHAR(128) NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (part_id) REFERENCES parts(id)\n);\n\n-- \u90e8\u54c1\u306e\u8abf\u9054\u5148\nCREATE TABLE part_suppliers (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    part_id BIGINT NOT NULL,\n    supplier_id BIGINT NOT NULL,\n    supplier_part_number VARCHAR(64) NULL,\n    supplier_price DECIMAL(10, 2) NOT NULL,\n    lead_time_days INT DEFAULT 0,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (part_id) REFERENCES parts(id),\n    FOREIGN KEY (supplier_id) REFERENCES suppliers(id)\n);\n\n-- \u53d7\u6ce8\u60c5\u5831\nCREATE TABLE purchase_orders (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    po_number VARCHAR(64) UNIQUE NOT NULL,\n    supplier_id BIGINT NOT NULL,\n    order_date DATE NOT NULL,\n    expected_delivery_date DATE NOT NULL,\n    actual_delivery_date DATE NULL,\n    status ENUM(&#039;pending&#039;, &#039;ordered&#039;, &#039;received&#039;, &#039;cancelled&#039;) DEFAULT &#039;pending&#039;,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (supplier_id) REFERENCES suppliers(id)\n);\n\n-- \u90e8\u54c1\u751f\u7523\u7ba1\u7406\nCREATE TABLE part_production (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    part_id BIGINT NOT NULL,\n    production_date DATE NOT NULL,\n    quantity_produced INT NOT NULL,\n    quality_status ENUM(&#039;pass&#039;, &#039;fail&#039;, &#039;rework&#039;) DEFAULT &#039;pass&#039;,\n    notes TEXT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (part_id) REFERENCES parts(id)\n);\n\n-- \u90e8\u54c1\u306e\u7d44\u307f\u5408\u308f\u305b\u30c6\u30fc\u30d6\u30eb\uff08BOM\uff09\nCREATE TABLE bom_items (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    bom_id BIGINT NOT NULL,\n    part_id BIGINT NOT NULL,\n    quantity INT NOT NULL,\n    sequence INT NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (bom_id) REFERENCES bom(id),\n    FOREIGN KEY (part_id) REFERENCES parts(id),\n    UNIQUE KEY unique_bom_part (bom_id, part_id)\n);\n\n-- BOM \u30de\u30b9\u30bf\u30fc\nCREATE TABLE bom (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    product_number VARCHAR(64) UNIQUE NOT NULL,\n    product_name VARCHAR(255) NOT NULL,\n    version INT DEFAULT 1,\n    effective_date DATE NOT NULL,\n    status ENUM(&#039;active&#039;, &#039;obsolete&#039;) DEFAULT &#039;active&#039;,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    deleted_at TIMESTAMP NULL\n);\n\n-- \u53d7\u6ce8\u7d44\u307f\u5408\u308f\u305b\u756a\u53f7\u7ba1\u7406\nCREATE TABLE customer_orders (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    order_number VARCHAR(64) UNIQUE NOT NULL,\n    customer_id BIGINT NOT NULL,\n    bom_id BIGINT NOT NULL,\n    order_date DATE NOT NULL,\n    delivery_date DATE NOT NULL,\n    quantity INT NOT NULL,\n    status ENUM(&#039;pending&#039;, &#039;in_production&#039;, &#039;completed&#039;, &#039;cancelled&#039;) DEFAULT &#039;pending&#039;,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    FOREIGN KEY (customer_id) REFERENCES customers(id),\n    FOREIGN KEY (bom_id) REFERENCES bom(id)\n);\n\n-- \u9867\u5ba2\u767a\u6ce8\u5c65\u6b74\nCREATE TABLE order_history (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    customer_order_id BIGINT NOT NULL,\n    status_changed_to VARCHAR(64) NOT NULL,\n    changed_at TIMESTAMP NOT NULL,\n    notes TEXT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    FOREIGN KEY (customer_order_id) REFERENCES customer_orders(id)\n);\n\n-- \u9867\u5ba2\u30de\u30b9\u30bf\u30fc\nCREATE TABLE customers (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    customer_code VARCHAR(64) UNIQUE NOT NULL,\n    customer_name VARCHAR(255) NOT NULL,\n    contact_person VARCHAR(128) NULL,\n    phone VARCHAR(20) NULL,\n    email VARCHAR(255) NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n\n-- \u30b5\u30d7\u30e9\u30a4\u30e4\u30fc\u30de\u30b9\u30bf\u30fc\nCREATE TABLE suppliers (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    supplier_code VARCHAR(64) UNIQUE NOT NULL,\n    supplier_name VARCHAR(255) NOT NULL,\n    contact_person VARCHAR(128) NULL,\n    phone VARCHAR(20) NULL,\n    email VARCHAR(255) NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"483\" src=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-1024x483.png\" alt=\"\" class=\"wp-image-11874\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-1024x483.png 1024w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-300x141.png 300w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-768x362.png 768w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-1536x724.png 1536w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2025\/12\/image-53-2048x966.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>\u3053\u306e\u72b6\u614b\u3067 deleted_at \u304c\u4ed8\u3044\u3066\u3044\u308b\u306e\u306f\u3001<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>parts \u30c6\u30fc\u30d6\u30eb<\/li>\n\n\n\n<li>bom \u30c6\u30fc\u30d6\u30eb<\/li>\n<\/ul>\n\n\n\n<p>\u306e 2 \u3064\u3067\u3059\u3002\u90e8\u54c1 parts \u30c6\u30fc\u30d6\u30eb\u306f\u3001\u904e\u53bb\u306e\u53d7\u6ce8\u5c65\u6b74\u3092\u8abf\u3079\u308b\u3068\u304d\u306b\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002BOM \u30c6\u30fc\u30d6\u30eb\u3082\u540c\u69d8\u3067\u3059\u3002\u751f\u7523\u7ba1\u7406\u306e\u90e8\u54c1\u8abf\u9054\u306f\u3001\u4ed6\u793e\u306e\u30b3\u30fc\u30c9\u3068\u81ea\u793e\u306e\u30b3\u30fc\u30c9\u304c\u6df7\u5728\u3057\u307e\u3059\u3002\u66f4\u306b\u3001\u73fe\u5728\u751f\u7523\u53ef\u80fd\u306a\u3082\u306e\u8abf\u9054\u53ef\u80fd\u306a\u3082\u306e\u3001\u8abf\u9054\u4e0d\u53ef\u80fd\u306a\u3082\u306e\u304c\u6df7\u5728\u3059\u308b\u308f\u3051\u3067\u3059\u3002\u3053\u308c\u3092\u671f\u9593\u3067\u7ba1\u7406\u3059\u308b\u5fc5\u8981\u3082\u3042\u308a\u3001\u8abf\u9054\u4e0d\u53ef\u80fd\u306a\u5834\u5408\u306b\u306f\u307b\u304b\u306e\u4f1a\u793e\u306b\u5207\u308a\u66ff\u3048\u308b\u5fc5\u8981\u304c\u3067\u3066\u304f\u308b\u306e\u3067\u3001\u3053\u3053\u3082\u8abf\u7bc0\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u3092\u904e\u53bb\u306e\u60c5\u5831\u3082\u542b\u3081\u3066\u3001\u9867\u5ba2\u304b\u3089\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\uff08\u904e\u53bb\u306e\u8abf\u9054\u306e\u7d44\u307f\u5408\u308f\u305b\u3084\u5c65\u6b74\u3092\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\uff09\u306e\u3067\u3001\u30c6\u30fc\u30d6\u30eb\u6570\u304c\u81a8\u5927\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u30b5\u30f3\u30d7\u30eb\u306a\u306e\u3067\u3053\u306e\u7a0b\u5ea6\u306a\u306e\u3067\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f 100 \u30c6\u30fc\u30d6\u30eb\u3092\u8d85\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3093\u306a\u4e2d\u3067\u3001\u7d71\u4e00\u7684\u306b is_deleted \u306b\u3059\u308b\u306e\u304b\u3001\u7269\u7406\u524a\u9664\u306b\u3059\u308b\u306e\u304b\u3001\u3068\u3044\u3046\u306e\u306f\u304b\u306a\u308a\u4e0d\u53ef\u80fd\u306b\u8fd1\u3044\u3067\u3059\u3002\u96c6\u8a08\u30af\u30a8\u30ea\u306e\u5bfe\u8c61\u306b\u306a\u308a\u3084\u3059\u3044\u3068\u304b\u3001\u904e\u53bb\u3092\u53c2\u7167\u305b\u305a\u306b\u3001\u7269\u7406\u524a\u9664\u3067\u5341\u5206\u3067\u3042\u308b\u3068\u304b\u3001\u305d\u306e\u3088\u3046\u306a\u8003\u616e\u3092\u3044\u308c\u3066\u305d\u308c\u305e\u308c\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u8a2d\u8a08\u3092\u884c\u308f\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u3044\u3063\u305f\u3093\u3053\u3053\u3067\u533a\u5207\u308a<\/strong><\/h2>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3001\u7d50\u69cb\u9577\u304f\u306a\u308a\u305d\u3046\u306a\u306e\u3067\u3001\u3044\u3063\u305f\u3093\u3053\u3053\u3067\u533a\u5207\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u56de\u8ee2\u5bff\u53f8\u306e\u53d7\u6ce8\u30b7\u30b9\u30c6\u30e0<\/li>\n\n\n\n<li>\u7a0e\u52d9\u95a2\u4fc2\u306e\u793e\u5185\u7d4c\u7406\u30b7\u30b9\u30c6\u30e0\u3001\u7d4c\u8cbb\u51e6\u7406<\/li>\n\n\n\n<li>\u793e\u5185\u306e\u30ca\u30ec\u30c3\u30b8\u7ba1\u7406\u3001\u9000\u8077\u8005\u306e\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u306b\u3064\u3044\u3066\u306f\u6b21\u56de\u3067\u3002<\/p>\n\n\n\n<p>\u5358\u306a\u308b\u300c\u8ad6\u7406\u524a\u9664\/\u7269\u7406\u524a\u9664\u3068\u306f\uff1f\u300d\u3068\u3044\u3046\u5358\u7d14\u306a\u8a71\u3067\u306f\u306a\u304f\u3066\u3001\u5177\u4f53\u7684\u306b\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3092\u51fa\u3057\u3066\u8003\u3048\u308b\u3068\u3088\u3044\u3067\u3059\u3002\u5148\u306b\u3082\u66f8\u304d\u307e\u3057\u305f\u304c AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u4f7f\u3046\u3068 SQL \u3068\u304b ORM \u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u51fa\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u5b9f\u9a13\u304c\u3057\u3084\u3059\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4eee\u8aac\u3092\u7acb\u3066\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u691c\u8a3c\u304c\u3084\u308a\u3084\u3059\u304f\u306a\u3063\u305f\u306e\u3067\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d9a\u304d 2025\/12\/22<\/h2>\n\n\n\n<p>\u8ad6\u7406\u524a\u9664\u3068\u7269\u7406\u524a\u9664\u306e\u7d9a\u304d <a href=\"https:\/\/www.moonmile.net\/blog\/archives\/11878\">https:\/\/www.moonmile.net\/blog\/archives\/11878<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u304a\u305d\u3089\u304f\u3001\u904e\u53bb\u306b\u305f\u304f\u3055\u3093\u306e\u8a18\u4e8b\u304c\u66f8\u304b\u308c\u3066\u3044\u308b\u3057\u300c\u8ad6\u7406\u524a\u9664\u3068\u306f\uff1f\u300d\u3068\u304b\u3044\u3046\u30d6\u30ed\u30b0\u8a18\u4e8b\u3082\u65e2\u306b\u3042\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u306e\u65b9\u3092\u53c2\u8003\u306b\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001X\/Twitter \u3067\u305f\u3073\u305f\u3073\u708e\u4e0a\u3059\u308b\u306e\u3068\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u3082\u8b70\u8ad6\u304c\u5206\u304b\u308c\u308b\u3068\u3053\u308d\u306a &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/11870\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,39],"tags":[],"class_list":["post-11870","post","type-post","status-publish","format-standard","hentry","category-dev","category-39"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/11870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=11870"}],"version-history":[{"count":7,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/11870\/revisions"}],"predecessor-version":[{"id":11886,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/11870\/revisions\/11886"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=11870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=11870"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=11870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}