Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. CREATE TABLE sample_types
  2. (
  3. sample_type_id INT IDENTITY
  4. CONSTRAINT sample_type_pk
  5. PRIMARY KEY NONCLUSTERED,
  6. sample_type_name NVARCHAR(50) NOT NULL,
  7. is_active BIT DEFAULT 1 NOT NULL,
  8. modified_on DATETIME2 NOT NULL
  9. )
  10. GO
  11.  
  12. EXEC sp_addextendedproperty 'MS_Description', 'Sample Type Table', 'SCHEMA', 'dbo', 'TABLE', 'sample_types'
  13. GO
  14.  
  15. CREATE UNIQUE INDEX samples_sample_type_id_uindex
  16. ON sample_types (sample_type_id )
  17. GO
  18.  
  19. CREATE TABLE container_types
  20. (
  21. container_type_id INT IDENTITY
  22. CONSTRAINT container_type_pk
  23. PRIMARY KEY NONCLUSTERED,
  24. container_type_name NVARCHAR(50) NOT NULL,
  25. is_active BIT DEFAULT 1 NOT NULL,
  26. modified_on DATETIME2 NOT NULL
  27. )
  28. GO
  29.  
  30. EXEC sp_addextendedproperty 'MS_Description', 'Container Type Table', 'SCHEMA', 'dbo', 'TABLE', 'container_types'
  31. GO
  32.  
  33. CREATE UNIQUE INDEX container_container_type_id_uindex
  34. ON container_types (container_type_id)
  35. GO
  36.  
  37. CREATE TABLE samples
  38. (
  39. sample_id INT IDENTITY
  40. CONSTRAINT samples_pk
  41. PRIMARY KEY NONCLUSTERED,
  42. name NVARCHAR(255) NOT NULL,
  43. accession_id INT NOT NULL,
  44. sample_type_id INT NOT NULL
  45. CONSTRAINT samples_sample_type_id_fk
  46. REFERENCES sample_types,
  47. container_type_id INT NOT NULL
  48. CONSTRAINT samples_container_type_id_fk
  49. REFERENCES container_types,
  50. description NVARCHAR(255),
  51. instruction NVARCHAR(255),
  52. is_prefix BIT DEFAULT 1 NOT NULL,
  53. modified_on DATETIME2 NOT NULL
  54. )
  55. GO
  56.  
  57. CREATE UNIQUE INDEX samples_sample_type_id_uindex
  58. ON samples (sample_type_id )
  59. GO
  60. CREATE UNIQUE INDEX samples_container_type_id_uindex
  61. ON container_types (container_type_id )
  62. GO
  63.  
  64. CREATE UNIQUE INDEX samples_sample_id_uindex
  65. ON samples (sample_id)
  66. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement