CREATE TABLE [dbo].[ProfileCreditRatingScore] (
    [Id]       INT           IDENTITY (1, 1) NOT NULL,
    [ProfileId] INT           NOT NULL,
	[BorrowerId] INT           NULL,
	[LoanRequestOfferId] INT  NULL,
	[CreditBureauScore] INT NOT NULL,
    [DerivedScore] INT      NOT NULL,
	[CreditBureauRobotScoreId] INT NOT NULL,
    [DerivedRobotScoreId]    INT NOT NULL,
	[ScoreDate] DATETIME NOT NULL,
    [Firstname] NVARCHAR(50) NOT NULL, 
    [Lastname] NVARCHAR(50) NOT NULL, 
    CONSTRAINT [PK_ProfileCreditRatingScore] PRIMARY KEY CLUSTERED ([Id] ASC),
	CONSTRAINT [FK_ProfileCreditRatingScore_Profile] FOREIGN KEY ([ProfileId]) REFERENCES [dbo].[Profile] ([Id]),
	CONSTRAINT [FK_ProfileCreditRatingScore_RobotScore] FOREIGN KEY ([DerivedRobotScoreId]) REFERENCES [dbo].[RobotScore]([Id]),
	CONSTRAINT [FK_ProfileCreditRatingScore_CrediBureauRobotScore] FOREIGN KEY ([CreditBureauRobotScoreId]) REFERENCES [dbo].[RobotScore]([Id]),
	CONSTRAINT [FK_ProfileCreditRatingScore_LoanRequestOffer] FOREIGN KEY ([LoanRequestOfferId]) REFERENCES [dbo].[LoanRequestOffer] ([Id]), 
    CONSTRAINT [FK_ProfileCreditRatingScore_Borrower] FOREIGN KEY ([BorrowerId]) REFERENCES [Profile]([Id])
    
);

