create table [dbo].[ActivityLog] (
    [Id] [int] not null identity,
    [ActivityLogTypeId] [int] not null,
    [CustomerId] [int] not null,
    [Comment] [nvarchar](max) not null,
    [CreatedOnUtc] [datetime] not null,
    [IpAddress] [nvarchar](200) null,
    primary key ([Id])
);
create table [dbo].[ActivityLogType] (
    [Id] [int] not null identity,
    [SystemKeyword] [nvarchar](100) not null,
    [Name] [nvarchar](200) not null,
    [Enabled] [bit] not null,
    primary key ([Id])
);
create table [dbo].[AlulaMeasurement] (
    [CustomerId] [int] not null,
    [MeasurementGuid] [uniqueidentifier] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([CustomerId], [MeasurementGuid])
);
create table [dbo].[ChatConnection] (
    [Id] [int] not null identity,
    [ConnectionGuid] [uniqueidentifier] not null,
    [CustomerId] [int] null,
    [OperatorId] [int] null,
    [ConnectionState] [int] not null,
    [StartDateTime] [datetime] not null,
    [ConnectionType] [nvarchar](max) null,
    [CustomerProblem] [nvarchar](max) null,
    [Conclusions] [nvarchar](max) null,
    [ConnectionAcceptedDateTime] [datetime] null,
    [ConnectionLastUpdate] [datetime] null,
    [TimePayed] [decimal](18, 2) null,
    [OperatorIdRequested] [int] null,
    [ConsultationId] [int] null,
    [VideoToken] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[ChatMessage] (
    [Id] [int] not null identity,
    [ChatConnectionId] [int] not null,
    [FromChatUserId] [int] null,
    [ToChatUserId] [int] null,
    [Message] [nvarchar](max) null,
    [DateMessage] [datetime] not null,
    [IsFile] [bit] not null,
    primary key ([Id])
);
create table [dbo].[ChatUser] (
    [Id] [int] not null identity,
    [CustomerId] [int] null,
    [Name] [nvarchar](max) null,
    [CustomerGuid] [uniqueidentifier] not null,
    primary key ([Id])
);
create table [dbo].[Company] (
    [Id] [int] not null identity,
    [PictureId] [int] null,
    [Name] [nvarchar](100) not null,
    [Details] [nvarchar](1000) null,
    [MobilePaySignature] [nvarchar](25) not null,
    [MobilePayFolderName] [nvarchar](100) not null,
    [Deleted] [bit] not null,
    [CreatedOnUTC] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[Consultation] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [OnlineNutritionistId] [int] not null,
    [DoctorAppointmentId] [int] null,
    [ChosenDoctorConsultationTypeId] [int] not null,
    [InitialCost] [decimal](18, 2) not null,
    [FinalCost] [decimal](18, 2) not null,
    [StartDate] [datetime] null,
    [EndTime] [datetime] null,
    [LastAddedTimeUtc] [datetime] null,
    [ConsultationType] [int] not null,
    [ConsultationStatus] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [UpdatedOnUtc] [datetime] not null,
    [CancelledOnUtc] [datetime] null,
    [Deleted] [bit] not null,
    [ReminderSent] [bit] not null,
    [ConsultationReason] [nvarchar](max) null,
    [RequireClinicVisit] [bit] null,
    [IsPaidByCustomer] [bit] not null,
    [PaidByCustomerId] [int] null,
    [PaidByRole] [int] null,
    [PaymentIsPending] [bit] not null,
    [IsGroupConsultation] [bit] not null,
    [IsSpecialistsBoard] [bit] not null,
    [MessagesBeforeConsultationCount] [smallint] not null,
    [MessagesAfterConsultationCount] [smallint] not null,
    [PatientNotArrived] [bit] null,
    primary key ([Id])
);
create table [dbo].[ConsultationCancelReason] (
    [Id] [int] not null identity,
    [ConsultationId] [int] not null,
    [OnlineNutritionistId] [int] not null,
    [Body] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[ConsultationNote] (
    [Id] [int] not null identity,
    [ConsultationId] [int] not null,
    [Title] [nvarchar](max) null,
    [Body] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [UpdatedOnUtc] [datetime] not null,
    [DeletedOnUtc] [datetime] null,
    [IsDeleted] [bit] not null,
    [OnlineNutritionistId] [int] null,
    primary key ([Id])
);
create table [dbo].[ConsultationParticipants] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [OnlineNutritionistId] [int] null,
    [ConsultationId] [int] not null,
    primary key ([Id])
);
create table [dbo].[ConsultationRecommendation] (
    [Id] [int] not null identity,
    [ConsultationId] [int] not null,
    [Body] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [UpdatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[ConsultationUploadedFile] (
    [Id] [int] not null identity,
    [ConsultationId] [int] not null,
    [Title] [nvarchar](max) null,
    [DownloadId] [int] not null,
    [CustomerId] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [DeletedBy] [int] null,
    [DeletedOnUTC] [datetime] null,
    primary key ([Id])
);
create table [dbo].[ConsultationUploadedFileXMessageInbox] (
    [Id] [int] not null identity,
    [MessageInboxId] [int] not null,
    [ConsultationUploadedFileId] [int] not null,
    primary key ([Id])
);
create table [dbo].[Country] (
    [Id] [int] not null identity,
    [Name] [nvarchar](100) not null,
    [TwoLetterIsoCode] [nvarchar](2) null,
    [ThreeLetterIsoCode] [nvarchar](3) null,
    [NumericIsoCode] [int] not null,
    [Published] [bit] not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[Currency] (
    [Id] [int] not null identity,
    [Name] [nvarchar](50) not null,
    [CurrencyCode] [nvarchar](5) not null,
    [DisplayLocale] [nvarchar](50) null,
    [CustomFormatting] [nvarchar](50) null,
    [Published] [bit] not null,
    [DisplayOrder] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [UpdatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaign] (
    [Id] [int] not null identity,
    [Name] [nvarchar](100) not null,
    [StartDate] [datetime] not null,
    [EndDate] [datetime] not null,
    [UnlimitedTimesPerUser] [bit] not null,
    [AllSpecialities] [bit] not null,
    [DiscountType] [tinyint] not null,
    [Discount] [decimal](18, 4) null,
    [Status] [tinyint] not null,
    [Deleted] [bit] not null,
    [VouchersGenerated] [bit] not null,
    [VouchersCodeBase] [nvarchar](10) null,
    [VouchersCodeRangeStart] [int] not null,
    [VouchersCodeRangeEnd] [int] not null,
    [UsedVouchers] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignHistory] (
    [Id] [int] not null identity,
    [CustomCampaignId] [int] not null,
    [Name] [nvarchar](100) not null,
    [StartDate] [datetime] not null,
    [EndDate] [datetime] not null,
    [UnlimitedTimesPerUser] [bit] not null,
    [AllSpecialities] [bit] not null,
    [DiscountType] [tinyint] not null,
    [Discount] [decimal](18, 4) null,
    [Status] [tinyint] not null,
    [Deleted] [bit] not null,
    [VouchersGenerated] [bit] not null,
    [VouchersCodeBase] [nvarchar](10) null,
    [VouchersCodeRangeStart] [int] not null,
    [VouchersCodeRangeEnd] [int] not null,
    [UsedVouchers] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignOnlineNutritionistTopic] (
    [Id] [int] not null identity,
    [CustomCampaignId] [int] not null,
    [OnlineNutritionistTopicId] [int] not null,
    [Discount] [decimal](18, 4) not null,
    [AllDoctors] [bit] not null,
    [Deleted] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] (
    [Id] [int] not null identity,
    [CustomCampaignOnlineNutritionistTopicId] [int] not null,
    [CustomCampaignId] [int] not null,
    [OnlineNutritionistTopicId] [int] not null,
    [Discount] [decimal](18, 4) not null,
    [AllDoctors] [bit] not null,
    [Deleted] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist] (
    [Id] [int] not null identity,
    [CustomCampaignOnlineNutritionistTopicId] [int] not null,
    [OnlineNutritionistId] [int] not null,
    [Deleted] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] (
    [Id] [int] not null identity,
    [CustomCampaignOnlineNutritionistTopicOnlineNutritionistId] [int] not null,
    [CustomCampaignOnlineNutritionistTopicId] [int] not null,
    [OnlineNutritionistId] [int] not null,
    [Deleted] [bit] not null,
    [CreatedAt] [datetime] not null,
    [CreatedById] [int] not null,
    [LastEdittedAt] [datetime] not null,
    [LastEdittedById] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignVoucher] (
    [Id] [int] not null identity,
    [CustomCampaignId] [int] not null,
    [VoucherGeneratedCode] [nvarchar](11) null,
    [OneTimeOnly] [bit] not null,
    [Used] [bit] not null,
    primary key ([Id])
);
create table [dbo].[CustomCampaignVoucherUsageHistory] (
    [ConsultationId] [int] not null,
    [CustomCampaignVoucherId] [int] not null,
    [LinkActive] [bit] not null,
    primary key ([ConsultationId])
);
create table [dbo].[Customer] (
    [Id] [int] not null identity,
    [CustomerGuid] [uniqueidentifier] not null,
    [Username] [nvarchar](1000) null,
    [FirstName] [nvarchar](max) null,
    [LastName] [nvarchar](max) null,
    [Email] [nvarchar](1000) null,
    [PIN] [nvarchar](max) null,
    [Password] [nvarchar](max) null,
    [PasswordFormatId] [int] not null,
    [PasswordHint] [nvarchar](max) null,
    [AdminComment] [nvarchar](max) null,
    [Active] [bit] not null,
    [Deleted] [bit] not null,
    [IsSystemAccount] [bit] not null,
    [SystemName] [nvarchar](400) null,
    [LastIpAddress] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [LastLoginDateUtc] [datetime] null,
    [LastActivityDateUtc] [datetime] not null,
    [IsAnonymized] [bit] not null,
    [AnonymizedOn] [datetime] null,
    [AnonymizedByOperator] [int] null,
    [AnonymizeNotes] [nvarchar](max) null,
    [Enabled2FA] [bit] null,
    [FailedLoginCount] [smallint] not null,
    [LockedOutOnUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[CustomerAttribute] (
    [Id] [int] not null identity,
    [Name] [nvarchar](400) not null,
    [IsRequired] [bit] not null,
    [AttributeControlTypeId] [int] not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomerAttributeValue] (
    [Id] [int] not null identity,
    [CustomerAttributeId] [int] not null,
    [Name] [nvarchar](400) not null,
    [IsPreSelected] [bit] not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[Customer_CustomerRole_Mapping] (
    [Customer_Id] [int] not null,
    [CustomerRole_Id] [int] not null,
    primary key ([Customer_Id], [CustomerRole_Id])
);
create table [dbo].[CustomerPasswordSalt] (
    [CustomerId] [int] not null,
    [PasswordSalt] [nvarchar](max) null,
    primary key ([CustomerId])
);
create table [dbo].[CustomerReview] (
    [Id] [int] not null identity,
    [OnlineNutritionistId] [int] not null,
    [ConsultationId] [int] null,
    [IsApproved] [bit] not null,
    [CustomerId] [int] not null,
    [Content] [nvarchar](max) null,
    [OverAllRating] [int] null,
    [ConsQuality] [int] null,
    [WaitTimeRating] [int] null,
    [DateCreated] [datetime] not null,
    [DateApproved] [datetime] null,
    [Deleted] [bit] not null,
    primary key ([Id])
);
create table [dbo].[CustomerRole] (
    [Id] [int] not null identity,
    [Name] [nvarchar](255) not null,
    [FreeShipping] [bit] not null,
    [Active] [bit] not null,
    [IsSystemRole] [bit] not null,
    [SystemName] [nvarchar](255) null,
    [PurchasedWithProductId] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomerSharedDocuments] (
    [DocumentId] [int] not null,
    [TopicId] [int] not null,
    primary key ([DocumentId], [TopicId])
);
create table [dbo].[CustomerUploadedFile] (
    [Id] [int] not null identity,
    [Title] [nvarchar](max) null,
    [DownloadId] [int] not null,
    [CustomerId] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [Shared] [bit] not null,
    primary key ([Id])
);
create table [dbo].[CustomerUploadedFileXMessageInbox] (
    [Id] [int] not null identity,
    [MessageInboxId] [int] not null,
    [CustomerUploadedFileId] [int] not null,
    primary key ([Id])
);
create table [dbo].[CustomerVitalParameterEntries] (
    [Id] [int] not null identity,
    [VitalParametersCustomCustomerMapId] [int] null,
    [VitalParameterStandardId] [int] null,
    [CustomerId] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [Value] [nvarchar](max) null,
    [Details] [nvarchar](max) null,
    [MeasuredOnUtc] [datetime] not null,
    [Normal] [bit] not null,
    [DownloadId] [int] null,
    primary key ([Id])
);
create table [dbo].[DoctorAppointment] (
    [Id] [int] not null identity,
    [AppointmentDate] [datetime] not null,
    [Active] [bit] not null,
    [Confirmed] [bit] not null,
    [CustomerId] [int] not null,
    [NutritionistId] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    [CreatedByPersonId] [int] not null,
    [UpdatedOnUtc] [datetime] not null,
    [UpdatedByPersonId] [int] null,
    [ExternalId] [int] null,
    primary key ([Id])
);
create table [dbo].[DoctorAppointment_DoctorScheduledAppointmentInterval_Mapping] (
    [DoctorAppointmentId] [int] not null,
    [DoctorScheduledAppointmentIntervalId] [int] not null,
    primary key ([DoctorAppointmentId], [DoctorScheduledAppointmentIntervalId])
);
create table [dbo].[DoctorScheduledAppointmentInterval] (
    [Id] [int] not null identity,
    [NutritionistId] [int] null,
    [ForDate] [datetime] null,
    [StartHour] [time](7) not null,
    [EndHour] [time](7) not null,
    [DisplayOrder] [int] null,
    [DefaultGenerated] [bit] not null,
    [Busy] [bit] not null,
    [Enabled] [bit] not null,
    [SlotDuration] [int] not null,
    [LocationId] [int] null,
    primary key ([Id])
);
create table [dbo].[DocumentPdfTemplate] (
    [Id] [int] not null identity,
    [Name] [nvarchar](200) not null,
    [Header] [nvarchar](max) null,
    [Body] [nvarchar](max) not null,
    [Footer] [nvarchar](max) null,
    [IsActive] [bit] not null,
    [LastUpdatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[Download] (
    [Id] [int] not null identity,
    [DownloadGuid] [uniqueidentifier] not null,
    [UseDownloadUrl] [bit] not null,
    [DownloadUrl] [nvarchar](max) null,
    [DownloadBinary] [varbinary](max) null,
    [ContentType] [nvarchar](max) null,
    [Filename] [nvarchar](max) null,
    [Extension] [nvarchar](max) null,
    [IsNew] [bit] not null,
    primary key ([Id])
);
create table [dbo].[EmailAccount] (
    [Id] [int] not null identity,
    [Email] [nvarchar](255) not null,
    [DisplayName] [nvarchar](255) null,
    [Host] [nvarchar](255) not null,
    [Port] [int] not null,
    [Username] [nvarchar](255) not null,
    [Password] [nvarchar](255) not null,
    [EnableSsl] [bit] not null,
    [UseDefaultCredentials] [bit] not null,
    primary key ([Id])
);
create table [dbo].[ExternalAuthenticationRecord] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [Email] [nvarchar](max) null,
    [ExternalIdentifier] [nvarchar](max) null,
    [ExternalDisplayIdentifier] [nvarchar](max) null,
    [OAuthToken] [nvarchar](max) null,
    [OAuthAccessToken] [nvarchar](max) null,
    [ProviderSystemName] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[FollowUpReminder] (
    [Id] [int] not null identity,
    [ConsultationId] [int] not null,
    [OnlineNutritionistId] [int] not null,
    [NotificationId] [int] null,
    [ReminderSent] [bit] not null,
    [ReminderDateUtc] [datetime] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[FrequentlyAskedQuestion] (
    [Id] [int] not null identity,
    [Question] [nvarchar](max) null,
    [Answer] [nvarchar](max) null,
    [Published] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[GDPRChoiceQuestion] (
    [Id] [int] not null identity,
    [Reason] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[GdprConsent] (
    [Id] [int] not null identity,
    [Message] [nvarchar](1000) not null,
    [IsRequired] [bit] not null,
    [RequiredMessage] [nvarchar](max) null,
    [AssociatedLink] [nvarchar](max) null,
    [DisplayDuringRegistration] [bit] not null,
    [DisplayOnCustomerInfoPage] [bit] not null,
    [SaveLog] [bit] not null,
    [DisplayOrder] [int] not null,
    [DisplayOnConsentForm] [bit] not null,
    primary key ([Id])
);
create table [dbo].[GDPRConsentDocuments] (
    [Id] [int] not null identity,
    [DownloadId] [int] not null,
    [CustomerId] [int] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[GDPRDomainQuestion] (
    [Id] [int] not null identity,
    [JobArea] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[GdprLog] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [ConsentId] [int] not null,
    [CustomerInfo] [nvarchar](max) null,
    [RequestTypeId] [int] not null,
    [RequestDetails] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[GDPRResearchQuestion] (
    [Id] [int] not null identity,
    [OptionText] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[GenericAttribute] (
    [Id] [int] not null identity,
    [EntityId] [int] not null,
    [KeyGroup] [nvarchar](400) not null,
    [Key] [nvarchar](400) not null,
    [Value] [nvarchar](max) not null,
    [StoreId] [int] not null,
    primary key ([Id])
);
create table [dbo].[Language] (
    [Id] [int] not null identity,
    [Name] [nvarchar](100) not null,
    [LanguageCulture] [nvarchar](20) not null,
    [UniqueSeoCode] [nvarchar](2) null,
    [FlagImageFileName] [nvarchar](50) null,
    [Rtl] [bit] not null,
    [DefaultCurrencyId] [int] not null,
    [Published] [bit] not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[LanguageNomenclator] (
    [Id] [int] not null identity,
    [Code] [nvarchar](max) null,
    [Name] [nvarchar](max) null,
    [DisplayOrder] [int] not null,
    [FlagImageFileName] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[LegalSupervisor] (
    [Id] [int] not null identity,
    [FirstName] [nvarchar](100) null,
    [LastName] [nvarchar](100) null,
    [Email] [nvarchar](254) null,
    [PhoneNumber] [nvarchar](15) null,
    [CustomerId] [int] null,
    [RepresentedCustomerId] [int] not null,
    [StartingFromDateUtc] [datetime] not null,
    [UntilDateUtc] [datetime] null,
    [Relationship] [int] null,
    primary key ([Id])
);
create table [dbo].[LocaleStringResource] (
    [Id] [int] not null identity,
    [LanguageId] [int] not null,
    [ResourceName] [nvarchar](200) not null,
    [ResourceValue] [nvarchar](max) not null,
    primary key ([Id])
);
create table [dbo].[LocalizedProperty] (
    [Id] [int] not null identity,
    [EntityId] [int] not null,
    [LanguageId] [int] not null,
    [LocaleKeyGroup] [nvarchar](400) not null,
    [LocaleKey] [nvarchar](400) not null,
    [LocaleValue] [nvarchar](max) not null,
    primary key ([Id])
);
create table [dbo].[Location] (
    [Id] [int] not null identity,
    [Name] [nvarchar](150) not null,
    [Address] [nvarchar](max) not null,
    [PhoneNumber] [nvarchar](max) null,
    [Schedule] [nvarchar](max) null,
    [Enabled] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    [ExternalId] [int] null,
    primary key ([Id])
);
create table [dbo].[Log] (
    [Id] [int] not null identity,
    [LogLevelId] [int] not null,
    [ShortMessage] [nvarchar](max) not null,
    [FullMessage] [nvarchar](max) null,
    [IpAddress] [nvarchar](200) null,
    [CustomerId] [int] null,
    [PageUrl] [nvarchar](max) null,
    [ReferrerUrl] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[MedicalAssistant] (
    [Id] [int] not null identity,
    [FirstName] [nvarchar](max) null,
    [LastName] [nvarchar](max) null,
    [Email] [nvarchar](max) null,
    [Phone] [nvarchar](max) null,
    [OnlineNutritionistId] [int] not null,
    [IsDeleted] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    [DeletedOnUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[MedicalDocuments] (
    [Id] [int] not null identity,
    [DocumentTitle] [nvarchar](max) null,
    [DownloadId] [int] not null,
    [CustomerId] [int] null,
    [SpecialistId] [int] null,
    [CreatedOnUtc] [datetime] not null,
    [ConsultationId] [int] null,
    [MedicalDocumentType] [nvarchar](max) null,
    [ToSpecialistId] [int] null,
    primary key ([Id])
);
create table [dbo].[MessageInbox] (
    [Id] [int] not null identity,
    [FromUserId] [int] null,
    [ToUserId] [int] not null,
    [ConsultationId] [int] null,
    [Subject] [nvarchar](300) not null,
    [Body] [nvarchar](max) not null,
    [ReadByReceiver] [bit] not null,
    [DeletedBySender] [bit] not null,
    [DeletedByReceiver] [bit] not null,
    [Notification] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    [PreviousMessageId] [int] not null,
    [MessageInboxCategoryId] [int] null,
    [MessageInboxCategoryTypeId] [int] null,
    [ShowInWaitingRoom] [bit] null,
    primary key ([Id])
);
create table [dbo].[MessageInboxCategory] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) null,
    [DisplayOrder] [int] not null,
    [CustomerCanReply] [bit] not null,
    [DoctorsOnly] [bit] not null,
    [PatientsOnly] [bit] not null,
    [Active] [bit] not null,
    [SystemName] [nvarchar](max) null,
    [ShowToMessages] [bit] not null,
    [ShowToNotifications] [bit] not null,
    primary key ([Id])
);
create table [dbo].[MessageInboxCategoryType] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) null,
    [DisplayOrder] [int] not null,
    [SystemName] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[MessageTemplate] (
    [Id] [int] not null identity,
    [Name] [nvarchar](200) not null,
    [BccEmailAddresses] [nvarchar](200) null,
    [Subject] [nvarchar](1000) null,
    [Body] [nvarchar](max) null,
    [IsActive] [bit] not null,
    [DelayBeforeSend] [int] null,
    [DelayPeriodId] [int] not null,
    [AttachedDownloadId] [int] not null,
    [EmailAccountId] [int] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionist] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [Active] [bit] not null,
    [Experience] [int] not null,
    [StartingFrom] [decimal](18, 2) not null,
    [FixedRate] [decimal](18, 2) not null,
    [PictureId] [int] null,
    [SignaturePictureId] [int] null,
    [Latitude] [decimal](18, 4) null,
    [Longitude] [decimal](18, 4) null,
    [ProfessionalTitleId] [int] null,
    [FirstName] [nvarchar](max) null,
    [LastName] [nvarchar](max) null,
    [SmallDescription] [nvarchar](max) null,
    [About] [nvarchar](max) null,
    [Training] [nvarchar](max) null,
    [Fees] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [VideoLink] [nvarchar](max) null,
    [FriendlySystemName] [nvarchar](max) null,
    [AvailableStatus] [int] not null,
    [BankAccount] [int] not null,
    [OneOffConsultationDuration] [int] null,
    [AvailabilitiesExternalId] [int] null,
    [IsHidden] [bit] not null,
    [CompanyId] [int] null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistDocument] (
    [Id] [int] not null identity,
    [CustomerId] [int] null,
    [UploadedById] [int] not null,
    [DeletedByCustomerId] [int] null,
    [DownloadId] [int] not null,
    [DocumentTitle] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [DeletedOnUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistLanguage] (
    [OnlineNutritionistId] [int] not null,
    [LanguageId] [int] not null,
    primary key ([OnlineNutritionistId], [LanguageId])
);
create table [dbo].[OnlineNutritionistLocation] (
    [OnlineNutritionistId] [int] not null,
    [LocationId] [int] not null,
    primary key ([OnlineNutritionistId], [LocationId])
);
create table [dbo].[OnlineNutritionistOneOffConsultationDurationHistory] (
    [Id] [int] not null identity,
    [OnlineNutritionistId] [int] not null,
    [OldOneOffConsultationDuration] [int] not null,
    [ValidUntil] [datetime] not null,
    [ChangedOnUtc] [datetime] not null,
    [ChangedBy] [int] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistSessionMapping] (
    [Id] [int] not null identity,
    [OnlineNutritionistId] [int] not null,
    [OnlineNutritionistSessionTypeId] [int] not null,
    [Enabled] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistSessionType] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) null,
    [Details] [nvarchar](max) null,
    [Enabled] [bit] not null,
    [Deleted] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistShowBy] (
    [Id] [int] not null identity,
    [SystemName] [nvarchar](max) null,
    [PublicName] [nvarchar](max) null,
    [DisplayOrder] [int] not null,
    [Enabled] [bit] not null,
    [Deleted] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistTopic] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) null,
    [Details] [nvarchar](max) null,
    [Deleted] [bit] not null,
    [PictureId] [int] null,
    [CreatedOnUtc] [datetime] not null,
    [ExternalId] [int] null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistTopicMapping] (
    [Id] [int] not null identity,
    [OnlineNutritionistId] [int] not null,
    [OnlineNutritionistTopicId] [int] not null,
    [Marked] [bit] not null,
    [Enabled] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[OnlineNutritionistTreatmentCourse] (
    [Id] [int] not null identity,
    [Title] [nvarchar](max) not null,
    [Duration] [int] not null,
    [Cost] [decimal](18, 2) not null,
    [Description] [nvarchar](max) not null,
    [MedicalServiceTypeId] [int] null,
    [IsGroupService] [bit] not null,
    [IsSpecialistsBoard] [bit] not null,
    [Active] [bit] not null,
    [DisplayOrder] [int] not null,
    [OnlineNutritionistTopicMappingId] [int] not null,
    [ExternalId] [int] null,
    primary key ([Id])
);
create table [dbo].[PermissionRecord] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) not null,
    [SystemName] [nvarchar](255) not null,
    [Category] [nvarchar](255) not null,
    primary key ([Id])
);
create table [dbo].[PermissionRecord_Role_Mapping] (
    [PermissionRecord_Id] [int] not null,
    [CustomerRole_Id] [int] not null,
    primary key ([PermissionRecord_Id], [CustomerRole_Id])
);
create table [dbo].[Picture] (
    [Id] [int] not null identity,
    [PictureBinary] [varbinary](max) null,
    [MimeType] [nvarchar](40) not null,
    [SeoFilename] [nvarchar](300) null,
    [AltAttribute] [nvarchar](max) null,
    [TitleAttribute] [nvarchar](max) null,
    [IsNew] [bit] not null,
    primary key ([Id])
);
create table [dbo].[ProfessionalTitle] (
    [Id] [int] not null identity,
    [Title] [nvarchar](50) not null,
    [Active] [bit] not null,
    primary key ([Id])
);
create table [dbo].[Question] (
    [Id] [int] not null identity,
    [QuestionText] [nvarchar](max) not null,
    [IsSingleLine] [bit] not null,
    [HasTitle] [bit] not null,
    [TitleText] [nvarchar](max) null,
    [IsActive] [bit] not null,
    [IsBlocked] [bit] not null,
    [QuestionTypeId] [int] not null,
    [QuestionCategoryId] [int] null,
    primary key ([Id])
);
create table [dbo].[QuestionAnswer] (
    [Id] [int] not null identity,
    [QuestionId] [int] not null,
    [AnswerText] [nvarchar](max) null,
    [DisplayOrder] [int] not null,
    [UserInputLimit] [int] null,
    [HasUserInput] [bit] not null,
    [UserInputLabel] [nvarchar](max) null,
    [IsActive] [bit] not null,
    primary key ([Id])
);
create table [dbo].[QuestionCategory] (
    [Id] [int] not null identity,
    [SystemName] [nvarchar](max) null,
    [Name] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireHeader] (
    [Id] [int] not null identity,
    [QuestionnaireName] [nvarchar](max) not null,
    [QuestionnaireTypeId] [int] not null,
    [Description] [nvarchar](max) null,
    [ShowDefaultToAppointment] [bit] not null,
    [RequiredBeforeConsultation] [bit] not null,
    [IssueObligation] [int] null,
    [IsActive] [bit] not null,
    [IsBlocked] [bit] not null,
    [PatientConsent] [nvarchar](max) null,
    [FinishDuringConsultationDateUTC] [datetime] null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireRecurrenceDoctorAssociation] (
    [Id] [int] not null identity,
    [QuestionnaireId] [int] not null,
    [CustomerId] [int] not null,
    [DoctorId] [int] not null,
    [RecurrenceType] [int] not null,
    [RecurrenceDay] [int] null,
    [FromDate] [datetime] not null,
    [ToDate] [datetime] not null,
    [CreatedOnUtc] [datetime] not null,
    [InvalidatedOnUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireResponseDetail] (
    [QuestionnaireResponseHeaderId] [int] not null,
    [SectionId] [int] not null,
    [QuestionId] [int] not null,
    [AnswerId] [int] not null,
    [UserInput] [nvarchar](max) null,
    primary key ([QuestionnaireResponseHeaderId], [SectionId], [QuestionId], [AnswerId])
);
create table [dbo].[QuestionnaireResponseHeader] (
    [Id] [int] not null identity,
    [ConsultationId] [int] null,
    [QuestionnaireHeaderId] [int] not null,
    [AssignedToId] [int] not null,
    [ForCustomerId] [int] not null,
    [IsEditable] [bit] not null,
    [CreatedOnUtc] [datetime] not null,
    [UpdatedOnUtc] [datetime] not null,
    [PatientConsentResponse] [bit] not null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireSectionAssociation] (
    [QuestionnaireID] [int] not null,
    [SectionID] [int] not null,
    [Required] [bit] not null,
    [DisplayOrder] [int] not null,
    [DisplaySectionName] [bit] not null,
    primary key ([QuestionnaireID], [SectionID])
);
create table [dbo].[QuestionnaireSectionHeader] (
    [Id] [int] not null identity,
    [SectionName] [nvarchar](max) not null,
    [Description] [nvarchar](max) null,
    [IsActive] [bit] not null,
    [CanBeSkipped] [bit] not null,
    [IsBlocked] [bit] not null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireSpecialtyDoctorAssociation] (
    [Id] [int] not null identity,
    [QuestionnaireID] [int] not null,
    [SpecialtyID] [int] null,
    [DoctorID] [int] null,
    primary key ([Id])
);
create table [dbo].[QuestionnaireType] (
    [Id] [int] not null identity,
    [SystemName] [nvarchar](max) not null,
    [Description] [nvarchar](max) null,
    [ForDoctorAccount] [bit] not null,
    [ShowToPatient] [bit] not null,
    [ForPatientAccount] [bit] not null,
    [ShowToDoctor] [bit] not null,
    primary key ([Id])
);
create table [dbo].[QuestionSectionAssociation] (
    [SectionID] [int] not null,
    [QuestionID] [int] not null,
    [DisplayOrder] [int] not null,
    [Required] [bit] not null,
    primary key ([SectionID], [QuestionID])
);
create table [dbo].[QuestionType] (
    [Id] [int] not null identity,
    [SystemName] [nvarchar](max) not null,
    [Description] [nvarchar](max) not null,
    primary key ([Id])
);
create table [dbo].[QueuedEmail] (
    [Id] [int] not null identity,
    [PriorityId] [int] not null,
    [From] [nvarchar](500) not null,
    [FromName] [nvarchar](500) null,
    [To] [nvarchar](500) not null,
    [ToName] [nvarchar](500) null,
    [ReplyTo] [nvarchar](500) null,
    [ReplyToName] [nvarchar](500) null,
    [CC] [nvarchar](500) null,
    [Bcc] [nvarchar](500) null,
    [Subject] [nvarchar](1000) null,
    [Body] [nvarchar](max) null,
    [AttachmentFilePath] [nvarchar](max) null,
    [AttachmentFileName] [nvarchar](max) null,
    [AttachedDownloadId] [int] not null,
    [Attachment] [varbinary](max) null,
    [CreatedOnUtc] [datetime] not null,
    [DontSendBeforeDateUtc] [datetime] null,
    [SentTries] [int] not null,
    [SentOnUtc] [datetime] null,
    [EmailAccountId] [int] not null,
    primary key ([Id])
);
create table [dbo].[ScheduleTask] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) not null,
    [Seconds] [int] not null,
    [RunHour] [smallint] null,
    [Type] [nvarchar](max) not null,
    [Enabled] [bit] not null,
    [StopOnError] [bit] not null,
    [LeasedByMachineName] [nvarchar](max) null,
    [LeasedUntilUtc] [datetime] null,
    [LastStartUtc] [datetime] null,
    [LastEndUtc] [datetime] null,
    [LastSuccessUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[Setting] (
    [Id] [int] not null identity,
    [Name] [nvarchar](200) not null,
    [Value] [nvarchar](2000) not null,
    [StoreId] [int] not null,
    primary key ([Id])
);
create table [dbo].[SharedPatient] (
    [Id] [int] not null identity,
    [SharingPractitionerId] [int] not null,
    [SharedPatientId] [int] not null,
    [SharedToPractitionerId] [int] not null,
    [ShareStartDate] [datetime] not null,
    [ShareEndDate] [datetime] not null,
    [SharedMessageInboxId] [int] null,
    [SharedMessage] [nvarchar](2000) not null,
    primary key ([Id])
);
create table [dbo].[Sms] (
    [Id] [int] not null identity,
    [Text] [nvarchar](max) null,
    [PhoneNo] [nvarchar](max) null,
    [FromCustomerId] [bigint] not null,
    [SentTries] [int] not null,
    [LastError] [nvarchar](max) null,
    [CreatedOnUtc] [datetime] not null,
    [SentOnUtc] [datetime] null,
    primary key ([Id])
);
create table [dbo].[StateProvince] (
    [Id] [int] not null identity,
    [CountryId] [int] not null,
    [Name] [nvarchar](100) not null,
    [Abbreviation] [nvarchar](100) null,
    [Published] [bit] not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[Store] (
    [Id] [int] not null identity,
    [Name] [nvarchar](400) not null,
    [Url] [nvarchar](400) not null,
    [SslEnabled] [bit] not null,
    [SecureUrl] [nvarchar](400) null,
    [Hosts] [nvarchar](1000) null,
    [DefaultLanguageId] [int] not null,
    [DisplayOrder] [int] not null,
    [CompanyName] [nvarchar](200) null,
    [CompanyAddress] [nvarchar](300) null,
    [CompanyPhoneNumber] [nvarchar](30) null,
    [CompanyVat] [decimal](18, 4) null,
    [RegistryNo] [nvarchar](50) null,
    [CUI] [nvarchar](50) null,
    [IBAN] [nvarchar](50) null,
    [Bank] [nvarchar](50) null,
    [SocialCapital] [decimal](18, 4) null,
    [CompanyStateProvinceId] [int] null,
    primary key ([Id])
);
create table [dbo].[Topic] (
    [Id] [int] not null identity,
    [SystemName] [nvarchar](max) null,
    [IncludeInSitemap] [bit] not null,
    [IncludeInTopMenu] [bit] not null,
    [IncludeInFooterColumn1] [bit] not null,
    [IncludeInFooterColumn2] [bit] not null,
    [IncludeInFooterColumn3] [bit] not null,
    [DisplayOrder] [int] not null,
    [AccessibleWhenStoreClosed] [bit] not null,
    [IsPasswordProtected] [bit] not null,
    [Password] [nvarchar](max) null,
    [Title] [nvarchar](max) null,
    [Body] [nvarchar](max) null,
    [Published] [bit] not null,
    [TopicTemplateId] [int] not null,
    [MetaKeywords] [nvarchar](max) null,
    [MetaDescription] [nvarchar](max) null,
    [MetaTitle] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[TopicTemplate] (
    [Id] [int] not null identity,
    [Name] [nvarchar](400) not null,
    [ViewPath] [nvarchar](400) not null,
    [DisplayOrder] [int] not null,
    primary key ([Id])
);
create table [dbo].[TreatmentCourseLocation] (
    [TreatmentCourseId] [int] not null,
    [LocationId] [int] not null,
    primary key ([TreatmentCourseId], [LocationId])
);
create table [dbo].[TreatmentCourseSessionType] (
    [SessionTypeId] [int] not null,
    [TreatmentCourseId] [int] not null,
    primary key ([SessionTypeId], [TreatmentCourseId])
);
create table [dbo].[UpdateHistoryLog] (
    [Id] [int] not null identity,
    [EntityId] [int] null,
    [EntityName] [nvarchar](max) null,
    [ObjectInformation] [nvarchar](max) null,
    [CreatedBy] [int] not null,
    [CustomerIp] [nvarchar](max) null,
    [CreatedOn] [datetime] not null,
    primary key ([Id])
);
create table [dbo].[UrlRecord] (
    [Id] [int] not null identity,
    [EntityId] [int] not null,
    [EntityName] [nvarchar](400) not null,
    [Slug] [nvarchar](400) not null,
    [IsActive] [bit] not null,
    [LanguageId] [int] not null,
    primary key ([Id])
);
create table [dbo].[VitalParametersCustomCustomerMap] (
    [Id] [int] not null identity,
    [CustomerId] [int] not null,
    [Name] [nvarchar](50) not null,
    [Description] [nvarchar](max) null,
    [MeasureUnit] [nvarchar](50) not null,
    [IntervalMin] [decimal](18, 4) null,
    [IntervalMax] [decimal](18, 4) null,
    [PerDay] [int] not null,
    [PerDayTime] [nvarchar](100) null,
    [Days] [nvarchar](70) not null,
    [State] [bit] not null,
    [CreatedById] [int] not null,
    [CreatedAt] [datetime] not null,
    [LastEditedById] [int] not null,
    [LastEditedAt] [datetime] not null,
    [AddedToEmail] [bit] not null,
    [ValueType] [int] not null,
    [StartMeasurement] [datetime] null,
    [EndMeasurement] [datetime] null,
    [ReferenceInterval] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[VitalParametersCustomCustomerMapHistory] (
    [Id] [int] not null identity,
    [VitalParameterCustomCustomerMapId] [int] not null,
    [CustomerId] [int] not null,
    [Name] [nvarchar](50) not null,
    [Description] [nvarchar](max) null,
    [MeasureUnit] [nvarchar](50) not null,
    [IntervalMin] [decimal](18, 4) null,
    [IntervalMax] [decimal](18, 4) null,
    [PerDay] [int] not null,
    [PerDayTime] [nvarchar](100) null,
    [Days] [nvarchar](70) not null,
    [State] [bit] not null,
    [CreatedById] [int] not null,
    [CreatedAt] [datetime] not null,
    [LastEditedById] [int] not null,
    [LastEditedAt] [datetime] not null,
    [AddedToEmail] [bit] not null,
    [ValueType] [int] not null,
    [StartMeasurement] [datetime] null,
    [EndMeasurement] [datetime] null,
    [ReferenceInterval] [nvarchar](max) null,
    primary key ([Id])
);
create table [dbo].[VitalParametersStandardNomenclator] (
    [Id] [int] not null identity,
    [Name] [nvarchar](max) null,
    [MeasureUnit] [nvarchar](max) null,
    [Description] [nvarchar](max) null,
    [IntervalMin] [decimal](18, 2) not null,
    [IntervalMax] [decimal](18, 2) not null,
    [Status] [bit] not null,
    [ExternalKey] [nvarchar](max) null,
    primary key ([Id])
);
alter table [dbo].[ActivityLog] add constraint [ActivityLog_ActivityLogType] foreign key ([ActivityLogTypeId]) references [dbo].[ActivityLogType]([Id]) on delete cascade;
alter table [dbo].[ActivityLog] add constraint [ActivityLog_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[AlulaMeasurement] add constraint [AlulaMeasurement_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[ChatConnection] add constraint [ChatConnection_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]);
alter table [dbo].[ChatConnection] add constraint [ChatConnection_Customer] foreign key ([CustomerId]) references [dbo].[ChatUser]([Id]);
alter table [dbo].[ChatConnection] add constraint [ChatConnection_Operator] foreign key ([OperatorId]) references [dbo].[ChatUser]([Id]);
alter table [dbo].[ChatMessage] add constraint [ChatMessage_ChatConnection] foreign key ([ChatConnectionId]) references [dbo].[ChatConnection]([Id]) on delete cascade;
alter table [dbo].[ChatMessage] add constraint [ChatMessage_FromChatUser] foreign key ([FromChatUserId]) references [dbo].[ChatUser]([Id]);
alter table [dbo].[ChatMessage] add constraint [ChatMessage_ToChatUser] foreign key ([ToChatUserId]) references [dbo].[ChatUser]([Id]);
alter table [dbo].[ChatUser] add constraint [ChatUser_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[Company] add constraint [Company_Picture] foreign key ([PictureId]) references [dbo].[Picture]([Id]) on delete cascade;
alter table [dbo].[Consultation] add constraint [Consultation_ChosenDoctorConsultationType] foreign key ([ChosenDoctorConsultationTypeId]) references [dbo].[OnlineNutritionistTreatmentCourse]([Id]) on delete cascade;
alter table [dbo].[ConsultationParticipants] add constraint [Consultation_ConsultationParticipants] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[Consultation] add constraint [Consultation_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[Consultation] add constraint [Consultation_DoctorAppointment] foreign key ([DoctorAppointmentId]) references [dbo].[DoctorAppointment]([Id]);
alter table [dbo].[Consultation] add constraint [Consultation_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[ConsultationCancelReason] add constraint [ConsultationCancelReason_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[ConsultationCancelReason] add constraint [ConsultationCancelReason_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[ConsultationNote] add constraint [ConsultationNote_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[ConsultationNote] add constraint [ConsultationNote_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[ConsultationParticipants] add constraint [ConsultationParticipant_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[ConsultationParticipants] add constraint [ConsultationParticipant_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[ConsultationRecommendation] add constraint [ConsultationRecommendation_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[ConsultationUploadedFile] add constraint [ConsultationUploadedFile_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[ConsultationUploadedFile] add constraint [ConsultationUploadedFile_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[ConsultationUploadedFile] add constraint [ConsultationUploadedFile_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]) on delete cascade;
alter table [dbo].[ConsultationUploadedFileXMessageInbox] add constraint [ConsultationUploadedFileXMessageInbox_ConsultationUploadedFile] foreign key ([ConsultationUploadedFileId]) references [dbo].[ConsultationUploadedFile]([Id]) on delete cascade;
alter table [dbo].[ConsultationUploadedFileXMessageInbox] add constraint [ConsultationUploadedFileXMessageInbox_MessageInbox] foreign key ([MessageInboxId]) references [dbo].[MessageInbox]([Id]) on delete cascade;
alter table [dbo].[CustomCampaign] add constraint [CustomCampaign_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaign] add constraint [CustomCampaign_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignHistory] add constraint [CustomCampaignHistory_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignHistory] add constraint [CustomCampaignHistory_CustomCampaign] foreign key ([CustomCampaignId]) references [dbo].[CustomCampaign]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignHistory] add constraint [CustomCampaignHistory_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopic] add constraint [CustomCampaignOnlineNutritionistTopic_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopic] add constraint [CustomCampaignOnlineNutritionistTopic_CustomCampaign] foreign key ([CustomCampaignId]) references [dbo].[CustomCampaign]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopic] add constraint [CustomCampaignOnlineNutritionistTopic_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopic] add constraint [CustomCampaignOnlineNutritionistTopic_OnlineNutritionistTopic] foreign key ([OnlineNutritionistTopicId]) references [dbo].[OnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] add constraint [CustomCampaignOnlineNutritionistTopicHistory_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] add constraint [CustomCampaignOnlineNutritionistTopicHistory_CustomCampaign] foreign key ([CustomCampaignId]) references [dbo].[CustomCampaign]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] add constraint [CustomCampaignOnlineNutritionistTopicHistory_CustomCampaignOnlineNutritionistTopic] foreign key ([CustomCampaignOnlineNutritionistTopicId]) references [dbo].[CustomCampaignOnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] add constraint [CustomCampaignOnlineNutritionistTopicHistory_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicHistory] add constraint [CustomCampaignOnlineNutritionistTopicHistory_OnlineNutritionistTopic] foreign key ([OnlineNutritionistTopicId]) references [dbo].[OnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionist_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionist_CustomCampaignOnlineNutritionistTopic] foreign key ([CustomCampaignOnlineNutritionistTopicId]) references [dbo].[CustomCampaignOnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionist_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionist_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory_CreatedBy] foreign key ([CreatedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory_CustomCampaignOnlineNutritionistTopic] foreign key ([CustomCampaignOnlineNutritionistTopicId]) references [dbo].[CustomCampaignOnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory_CustomCampaignOnlineNutritionistTopicOnlineNutritionist] foreign key ([CustomCampaignOnlineNutritionistTopicOnlineNutritionistId]) references [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory_LastEdittedBy] foreign key ([LastEdittedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory] add constraint [CustomCampaignOnlineNutritionistTopicOnlineNutritionistHistory_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignVoucher] add constraint [CustomCampaignVoucher_CustomCampaign] foreign key ([CustomCampaignId]) references [dbo].[CustomCampaign]([Id]) on delete cascade;
alter table [dbo].[CustomCampaignVoucherUsageHistory] add constraint [CustomCampaignVoucherUsageHistory_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]);
alter table [dbo].[CustomCampaignVoucherUsageHistory] add constraint [CustomCampaignVoucherUsageHistory_CustomCampaignVoucher] foreign key ([CustomCampaignVoucherId]) references [dbo].[CustomCampaignVoucher]([Id]) on delete cascade;
alter table [dbo].[Customer_CustomerRole_Mapping] add constraint [Customer_CustomerRoles_Source] foreign key ([Customer_Id]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[Customer_CustomerRole_Mapping] add constraint [Customer_CustomerRoles_Target] foreign key ([CustomerRole_Id]) references [dbo].[CustomerRole]([Id]) on delete cascade;
alter table [dbo].[CustomerAttributeValue] add constraint [CustomerAttributeValue_CustomerAttribute] foreign key ([CustomerAttributeId]) references [dbo].[CustomerAttribute]([Id]) on delete cascade;
alter table [dbo].[CustomerPasswordSalt] add constraint [CustomerPasswordSalt_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[CustomerReview] add constraint [CustomerReview_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]);
alter table [dbo].[CustomerReview] add constraint [CustomerReview_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomerReview] add constraint [CustomerReview_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[CustomerSharedDocuments] add constraint [CustomerSharedDocuments_CustomerUploadedFile] foreign key ([DocumentId]) references [dbo].[CustomerUploadedFile]([Id]);
alter table [dbo].[CustomerSharedDocuments] add constraint [CustomerSharedDocuments_OnlineNutritionistTopic] foreign key ([TopicId]) references [dbo].[OnlineNutritionistTopic]([Id]);
alter table [dbo].[CustomerUploadedFile] add constraint [CustomerUploadedFile_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomerUploadedFile] add constraint [CustomerUploadedFile_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]) on delete cascade;
alter table [dbo].[CustomerUploadedFileXMessageInbox] add constraint [CustomerUploadedFileXMessageInbox_CustomerUploadedFile] foreign key ([CustomerUploadedFileId]) references [dbo].[CustomerUploadedFile]([Id]) on delete cascade;
alter table [dbo].[CustomerUploadedFileXMessageInbox] add constraint [CustomerUploadedFileXMessageInbox_MessageInbox] foreign key ([MessageInboxId]) references [dbo].[MessageInbox]([Id]) on delete cascade;
alter table [dbo].[CustomerVitalParameterEntries] add constraint [CustomerVitalParameterEntry_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[CustomerVitalParameterEntries] add constraint [CustomerVitalParameterEntry_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]);
alter table [dbo].[CustomerVitalParameterEntries] add constraint [CustomerVitalParameterEntry_VitalParametersCustomCustomerMap] foreign key ([VitalParametersCustomCustomerMapId]) references [dbo].[VitalParametersCustomCustomerMap]([Id]);
alter table [dbo].[CustomerVitalParameterEntries] add constraint [CustomerVitalParameterEntry_VitalParameterStandard] foreign key ([VitalParameterStandardId]) references [dbo].[VitalParametersStandardNomenclator]([Id]);
alter table [dbo].[DoctorAppointment_DoctorScheduledAppointmentInterval_Mapping] add constraint [DoctorAppointment_AppointmentIntervals_Source] foreign key ([DoctorAppointmentId]) references [dbo].[DoctorAppointment]([Id]) on delete cascade;
alter table [dbo].[DoctorAppointment_DoctorScheduledAppointmentInterval_Mapping] add constraint [DoctorAppointment_AppointmentIntervals_Target] foreign key ([DoctorScheduledAppointmentIntervalId]) references [dbo].[DoctorScheduledAppointmentInterval]([Id]) on delete cascade;
alter table [dbo].[DoctorAppointment] add constraint [DoctorAppointment_CreatedByPerson] foreign key ([CreatedByPersonId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[DoctorAppointment] add constraint [DoctorAppointment_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[DoctorAppointment] add constraint [DoctorAppointment_Nutritionist] foreign key ([NutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[DoctorAppointment] add constraint [DoctorAppointment_UpdatedByPerson] foreign key ([UpdatedByPersonId]) references [dbo].[Customer]([Id]);
alter table [dbo].[DoctorScheduledAppointmentInterval] add constraint [DoctorScheduledAppointmentInterval_Location] foreign key ([LocationId]) references [dbo].[Location]([Id]);
alter table [dbo].[DoctorScheduledAppointmentInterval] add constraint [DoctorScheduledAppointmentInterval_Nutritionist] foreign key ([NutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[ExternalAuthenticationRecord] add constraint [ExternalAuthenticationRecord_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[FollowUpReminder] add constraint [FollowUpReminder_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]) on delete cascade;
alter table [dbo].[FollowUpReminder] add constraint [FollowUpReminder_Notification] foreign key ([NotificationId]) references [dbo].[MessageInbox]([Id]);
alter table [dbo].[FollowUpReminder] add constraint [FollowUpReminder_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[GDPRConsentDocuments] add constraint [GDPRConsentDocuments_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[GDPRConsentDocuments] add constraint [GDPRConsentDocuments_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]) on delete cascade;
alter table [dbo].[LegalSupervisor] add constraint [LegalSupervisor_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[LegalSupervisor] add constraint [LegalSupervisor_RepresentedCustomer] foreign key ([RepresentedCustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[LocaleStringResource] add constraint [LocaleStringResource_Language] foreign key ([LanguageId]) references [dbo].[Language]([Id]) on delete cascade;
alter table [dbo].[LocalizedProperty] add constraint [LocalizedProperty_Language] foreign key ([LanguageId]) references [dbo].[Language]([Id]) on delete cascade;
alter table [dbo].[Log] add constraint [Log_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[MedicalAssistant] add constraint [MedicalAssistant_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[MedicalDocuments] add constraint [MedicalDocuments_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[MedicalDocuments] add constraint [MedicalDocuments_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]) on delete cascade;
alter table [dbo].[MedicalDocuments] add constraint [MedicalDocuments_Specialist] foreign key ([SpecialistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[MessageInbox] add constraint [MessageInbox_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]);
alter table [dbo].[MessageInbox] add constraint [MessageInbox_FromUser] foreign key ([FromUserId]) references [dbo].[Customer]([Id]);
alter table [dbo].[MessageInbox] add constraint [MessageInbox_MessageInboxCategory] foreign key ([MessageInboxCategoryId]) references [dbo].[MessageInboxCategory]([Id]);
alter table [dbo].[MessageInbox] add constraint [MessageInbox_MessageInboxCategoryType] foreign key ([MessageInboxCategoryTypeId]) references [dbo].[MessageInboxCategoryType]([Id]);
alter table [dbo].[MessageInbox] add constraint [MessageInbox_ToUser] foreign key ([ToUserId]) references [dbo].[Customer]([Id]);
alter table [dbo].[OnlineNutritionist] add constraint [OnlineNutritionist_Company] foreign key ([CompanyId]) references [dbo].[Company]([Id]);
alter table [dbo].[OnlineNutritionist] add constraint [OnlineNutritionist_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[OnlineNutritionist] add constraint [OnlineNutritionist_Picture] foreign key ([PictureId]) references [dbo].[Picture]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionist] add constraint [OnlineNutritionist_ProfessionalTitle] foreign key ([ProfessionalTitleId]) references [dbo].[ProfessionalTitle]([Id]);
alter table [dbo].[OnlineNutritionist] add constraint [OnlineNutritionist_SignaturePicture] foreign key ([SignaturePictureId]) references [dbo].[Picture]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistDocument] add constraint [OnlineNutritionistDocument_Customer] foreign key ([UploadedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistDocument] add constraint [OnlineNutritionistDocument_Download] foreign key ([DownloadId]) references [dbo].[Download]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistDocument] add constraint [OnlineNutritionistDocument_UploadedBy] foreign key ([UploadedById]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistLanguage] add constraint [OnlineNutritionistLanguage_LanguageNomenclator] foreign key ([LanguageId]) references [dbo].[LanguageNomenclator]([Id]);
alter table [dbo].[OnlineNutritionistLanguage] add constraint [OnlineNutritionistLanguage_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[OnlineNutritionistLocation] add constraint [OnlineNutritionistLocation_Location] foreign key ([LocationId]) references [dbo].[Location]([Id]);
alter table [dbo].[OnlineNutritionistLocation] add constraint [OnlineNutritionistLocation_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[OnlineNutritionistOneOffConsultationDurationHistory] add constraint [OnlineNutritionistOneOffConsultationDuration_ChangedByCustomer] foreign key ([ChangedBy]) references [dbo].[Customer]([Id]);
alter table [dbo].[OnlineNutritionistOneOffConsultationDurationHistory] add constraint [OnlineNutritionistOneOffConsultationDuration_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[OnlineNutritionistSessionMapping] add constraint [OnlineNutritionistSessionMapping_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[OnlineNutritionistSessionMapping] add constraint [OnlineNutritionistSessionMapping_OnlineNutritionistSessionType] foreign key ([OnlineNutritionistSessionTypeId]) references [dbo].[OnlineNutritionistSessionType]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistTopicMapping] add constraint [OnlineNutritionistTopicMapping_OnlineNutritionist] foreign key ([OnlineNutritionistId]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[OnlineNutritionistTopicMapping] add constraint [OnlineNutritionistTopicMapping_OnlineNutritionistTopic] foreign key ([OnlineNutritionistTopicId]) references [dbo].[OnlineNutritionistTopic]([Id]) on delete cascade;
alter table [dbo].[OnlineNutritionistTreatmentCourse] add constraint [OnlineNutritionistTreatmentCourse_OnlineNutritionistTopicMapping] foreign key ([OnlineNutritionistTopicMappingId]) references [dbo].[OnlineNutritionistTopicMapping]([Id]) on delete cascade;
alter table [dbo].[PermissionRecord_Role_Mapping] add constraint [PermissionRecord_CustomerRoles_Source] foreign key ([PermissionRecord_Id]) references [dbo].[PermissionRecord]([Id]) on delete cascade;
alter table [dbo].[PermissionRecord_Role_Mapping] add constraint [PermissionRecord_CustomerRoles_Target] foreign key ([CustomerRole_Id]) references [dbo].[CustomerRole]([Id]) on delete cascade;
alter table [dbo].[Question] add constraint [Question_QuestionCategory] foreign key ([QuestionCategoryId]) references [dbo].[QuestionCategory]([Id]);
alter table [dbo].[QuestionSectionAssociation] add constraint [Question_QuestionSectionAssociations] foreign key ([QuestionID]) references [dbo].[Question]([Id]) on delete cascade;
alter table [dbo].[Question] add constraint [Question_QuestionType] foreign key ([QuestionTypeId]) references [dbo].[QuestionType]([Id]) on delete cascade;
alter table [dbo].[QuestionAnswer] add constraint [QuestionAnswer_Question] foreign key ([QuestionId]) references [dbo].[Question]([Id]);
alter table [dbo].[QuestionnaireSectionAssociation] add constraint [QuestionnaireHeader_QuestionnaireSectionAssociations] foreign key ([QuestionnaireID]) references [dbo].[QuestionnaireHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireSpecialtyDoctorAssociation] add constraint [QuestionnaireHeader_QuestionnaireSpecialtyDoctorAssociations] foreign key ([QuestionnaireID]) references [dbo].[QuestionnaireHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireHeader] add constraint [QuestionnaireHeader_QuestionnaireType] foreign key ([QuestionnaireTypeId]) references [dbo].[QuestionnaireType]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireRecurrenceDoctorAssociation] add constraint [QuestionnaireRecurrenceDoctorAssociation_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireRecurrenceDoctorAssociation] add constraint [QuestionnaireRecurrenceDoctorAssociation_Doctor] foreign key ([DoctorId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireRecurrenceDoctorAssociation] add constraint [QuestionnaireRecurrenceDoctorAssociation_Questionnaire] foreign key ([QuestionnaireId]) references [dbo].[QuestionnaireHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseDetail] add constraint [QuestionnaireResponseDetail_Question] foreign key ([QuestionId]) references [dbo].[Question]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseDetail] add constraint [QuestionnaireResponseDetail_QuestionAnswer] foreign key ([AnswerId]) references [dbo].[QuestionAnswer]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseDetail] add constraint [QuestionnaireResponseDetail_QuestionnaireResponseHeader] foreign key ([QuestionnaireResponseHeaderId]) references [dbo].[QuestionnaireResponseHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseDetail] add constraint [QuestionnaireResponseDetail_QuestionnaireSectionHeader] foreign key ([SectionId]) references [dbo].[QuestionnaireSectionHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseHeader] add constraint [QuestionnaireResponseHeader_AssignedTo] foreign key ([AssignedToId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseHeader] add constraint [QuestionnaireResponseHeader_Consultation] foreign key ([ConsultationId]) references [dbo].[Consultation]([Id]);
alter table [dbo].[QuestionnaireResponseHeader] add constraint [QuestionnaireResponseHeader_ForCustomer] foreign key ([ForCustomerId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireResponseHeader] add constraint [QuestionnaireResponseHeader_QuestionnaireHeader] foreign key ([QuestionnaireHeaderId]) references [dbo].[QuestionnaireHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireSectionAssociation] add constraint [QuestionnaireSectionAssociation_QuestionnaireSectionHeader] foreign key ([SectionID]) references [dbo].[QuestionnaireSectionHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionSectionAssociation] add constraint [QuestionnaireSectionHeader_QuestionSectionAssociations] foreign key ([SectionID]) references [dbo].[QuestionnaireSectionHeader]([Id]) on delete cascade;
alter table [dbo].[QuestionnaireSpecialtyDoctorAssociation] add constraint [QuestionnaireSpecialtyDoctorAssociation_Doctor] foreign key ([DoctorID]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[QuestionnaireSpecialtyDoctorAssociation] add constraint [QuestionnaireSpecialtyDoctorAssociation_Specialty] foreign key ([SpecialtyID]) references [dbo].[OnlineNutritionistTopic]([Id]);
alter table [dbo].[QueuedEmail] add constraint [QueuedEmail_EmailAccount] foreign key ([EmailAccountId]) references [dbo].[EmailAccount]([Id]) on delete cascade;
alter table [dbo].[SharedPatient] add constraint [SharedPatient_SharedCustomer] foreign key ([SharedPatientId]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[SharedPatient] add constraint [SharedPatient_SharedNotification] foreign key ([SharedMessageInboxId]) references [dbo].[MessageInbox]([Id]);
alter table [dbo].[SharedPatient] add constraint [SharedPatient_SharedToPractitioner] foreign key ([SharedToPractitionerId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[SharedPatient] add constraint [SharedPatient_SharingPractitioner] foreign key ([SharingPractitionerId]) references [dbo].[OnlineNutritionist]([Id]) on delete cascade;
alter table [dbo].[StateProvince] add constraint [StateProvince_Country] foreign key ([CountryId]) references [dbo].[Country]([Id]) on delete cascade;
alter table [dbo].[Store] add constraint [Store_CompanyStateProvince] foreign key ([CompanyStateProvinceId]) references [dbo].[StateProvince]([Id]);
alter table [dbo].[TreatmentCourseLocation] add constraint [TreatmentCourseLocation_Location] foreign key ([LocationId]) references [dbo].[Location]([Id]);
alter table [dbo].[TreatmentCourseLocation] add constraint [TreatmentCourseLocation_TreatmentCourse] foreign key ([TreatmentCourseId]) references [dbo].[OnlineNutritionistTreatmentCourse]([Id]) on delete cascade;
alter table [dbo].[TreatmentCourseSessionType] add constraint [TreatmentCourseSessionType_SessionType] foreign key ([SessionTypeId]) references [dbo].[OnlineNutritionistSessionType]([Id]);
alter table [dbo].[TreatmentCourseSessionType] add constraint [TreatmentCourseSessionType_TreatmentCourse] foreign key ([TreatmentCourseId]) references [dbo].[OnlineNutritionistTreatmentCourse]([Id]) on delete cascade;
alter table [dbo].[UpdateHistoryLog] add constraint [UpdateHistoryLog_Customer] foreign key ([CreatedBy]) references [dbo].[Customer]([Id]) on delete cascade;
alter table [dbo].[VitalParametersCustomCustomerMap] add constraint [VitalParametersCustomCustomerMap_CreatedBy] foreign key ([CreatedById]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[VitalParametersCustomCustomerMap] add constraint [VitalParametersCustomCustomerMap_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[VitalParametersCustomCustomerMapHistory] add constraint [VitalParametersCustomCustomerMap_CustomParameterHistory] foreign key ([VitalParameterCustomCustomerMapId]) references [dbo].[VitalParametersCustomCustomerMap]([Id]) on delete cascade;
alter table [dbo].[VitalParametersCustomCustomerMap] add constraint [VitalParametersCustomCustomerMap_LastEditedBy] foreign key ([LastEditedById]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[VitalParametersCustomCustomerMapHistory] add constraint [VitalParametersCustomCustomerMapHistory_CreatedBy] foreign key ([CreatedById]) references [dbo].[OnlineNutritionist]([Id]);
alter table [dbo].[VitalParametersCustomCustomerMapHistory] add constraint [VitalParametersCustomCustomerMapHistory_Customer] foreign key ([CustomerId]) references [dbo].[Customer]([Id]);
alter table [dbo].[VitalParametersCustomCustomerMapHistory] add constraint [VitalParametersCustomCustomerMapHistory_LastEditedBy] foreign key ([LastEditedById]) references [dbo].[OnlineNutritionist]([Id]);
