Advertisement
Guest User

Untitled

a guest
May 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. CREATE TABLE Testing_Laboratory
  2. (
  3. lab_code INT NOT NULL,
  4. lab_details VARCHAR(20) NOT NULL,
  5. PRIMARY KEY (lab_code)
  6. );
  7.  
  8. CREATE TABLE Paternity_Test
  9. (
  10. test_id INT NOT NULL,
  11. test_details VARCHAR(20) NOT NULL,
  12. lab_code INT NOT NULL,
  13. PRIMARY KEY (test_id),
  14. FOREIGN KEY (lab_code) REFERENCES Testing_Laboratory(lab_code)
  15. );
  16.  
  17. CREATE TABLE Address
  18. (
  19. address_id INT NOT NULL,
  20. street_number INT NOT NULL,
  21. street_name VARCHAR(20) NOT NULL,
  22. suburb VARCHAR(20) NOT NULL,
  23. postcode INT NOT NULL,
  24. PRIMARY KEY (address_id)
  25. );
  26.  
  27. CREATE TABLE Mental_Illness
  28. (
  29. mental_illness_code INT NOT NULL,
  30. mental_illness_description VARCHAR(20) NOT NULL,
  31. PRIMARY KEY (mental_illness_code)
  32. );
  33.  
  34. CREATE TABLE Government_Certifier
  35. (
  36. certifier_id INT NOT NULL,
  37. certifier_details VARCHAR(20) NOT NULL,
  38. PRIMARY KEY (certifier_id)
  39. );
  40.  
  41. CREATE TABLE Accreditation
  42. (
  43. accredation_name VARCHAR(20) NOT NULL,
  44. accredation_id INT NOT NULL,
  45. PRIMARY KEY (accredation_id)
  46. );
  47.  
  48. CREATE TABLE Results
  49. (
  50. result_id INT NOT NULL,
  51. lab_code INT NOT NULL,
  52. PRIMARY KEY (result_id),
  53. FOREIGN KEY (lab_code) REFERENCES Testing_Laboratory(lab_code)
  54. );
  55.  
  56. CREATE TABLE Client
  57. (
  58. client_id INT NOT NULL,
  59. first_name VARCHAR(20) NOT NULL,
  60. last_name VARCHAR(20) NOT NULL,
  61. address_id INT NOT NULL,
  62. test_id INT NOT NULL,
  63. PRIMARY KEY (client_id),
  64. FOREIGN KEY (address_id) REFERENCES Address(address_id),
  65. FOREIGN KEY (test_id) REFERENCES Paternity_Test(test_id)
  66. );
  67.  
  68. CREATE TABLE Treatment
  69. (
  70. treatment_code INT NOT NULL,
  71. treatment_detail VARCHAR(20) NOT NULL,
  72. client_id INT NOT NULL,
  73. certifier_id INT NOT NULL,
  74. PRIMARY KEY (treatment_code),
  75. FOREIGN KEY (client_id) REFERENCES Client(client_id),
  76. FOREIGN KEY (certifier_id) REFERENCES Government_Certifier(certifier_id)
  77. );
  78.  
  79. CREATE TABLE Affects
  80. (
  81. client_id INT NOT NULL,
  82. mental_illness_code INT NOT NULL,
  83. FOREIGN KEY (client_id) REFERENCES Client(client_id),
  84. FOREIGN KEY (mental_illness_code) REFERENCES Mental_Illness(mental_illness_code)
  85. );
  86.  
  87. CREATE TABLE Professional
  88. (
  89. professional_id INT NOT NULL,
  90. professional_parent_id INT NOT NULL,
  91. professional_details VARCHAR(20) NOT NULL,
  92. accredation_id INT NOT NULL,
  93. PRIMARY KEY (professional_id),
  94. FOREIGN KEY (professional_parent_id) REFERENCES Professional(professional_id),
  95. FOREIGN KEY (accredation_id) REFERENCES Accreditation(accredation_id)
  96. );
  97.  
  98. CREATE TABLE Meets
  99. (
  100. client_id INT NOT NULL,
  101. professional_id INT NOT NULL,
  102. FOREIGN KEY (client_id) REFERENCES Client(client_id),
  103. FOREIGN KEY (professional_id) REFERENCES Professional(professional_id)
  104. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement