Click here to Skip to main content
15,885,546 members
Home / Discussions / Database
   

Database

 
QuestionAdvice or opinion on database planning for Angular using MongoDB and perhaps a 2nd technology. Pin
jkirkerx30-Aug-19 8:16
professionaljkirkerx30-Aug-19 8:16 
AnswerRe: Advice or opinion on database planning for Angular using MongoDB and perhaps a 2nd technology. Pin
Afzaal Ahmad Zeeshan30-Aug-19 11:56
professionalAfzaal Ahmad Zeeshan30-Aug-19 11:56 
GeneralRe: Advice or opinion on database planning for Angular using MongoDB and perhaps a 2nd technology. Pin
jkirkerx1-Sep-19 10:46
professionaljkirkerx1-Sep-19 10:46 
QuestionCompact and Repair Access Database using C# ? Pin
Member 245846729-Aug-19 15:14
Member 245846729-Aug-19 15:14 
AnswerRe: Compact and Repair Access Database using C# ? Pin
Victor Nijegorodov29-Aug-19 20:37
Victor Nijegorodov29-Aug-19 20:37 
QuestionHwere's a Head-Scratcher Pin
#realJSOP28-Aug-19 9:37
mve#realJSOP28-Aug-19 9:37 
AnswerRe: Hwere's a Head-Scratcher Pin
Richard Deeming28-Aug-19 10:00
mveRichard Deeming28-Aug-19 10:00 
GeneralRe: Hwere's a Head-Scratcher Pin
Mycroft Holmes28-Aug-19 12:42
professionalMycroft Holmes28-Aug-19 12:42 
GeneralRe: Hwere's a Head-Scratcher Pin
#realJSOP28-Aug-19 23:23
mve#realJSOP28-Aug-19 23:23 
GeneralRe: Hwere's a Head-Scratcher Pin
Richard Deeming29-Aug-19 1:22
mveRichard Deeming29-Aug-19 1:22 
GeneralRe: Hwere's a Head-Scratcher Pin
#realJSOP29-Aug-19 1:47
mve#realJSOP29-Aug-19 1:47 
GeneralRe: Hwere's a Head-Scratcher Pin
Richard Deeming29-Aug-19 1:55
mveRichard Deeming29-Aug-19 1:55 
GeneralRe: Hwere's a Head-Scratcher Pin
#realJSOP29-Aug-19 1:59
mve#realJSOP29-Aug-19 1:59 
QuestionError With Simple Script Pin
Kevin Marois22-Aug-19 8:26
professionalKevin Marois22-Aug-19 8:26 
AnswerRe: Error With Simple Script Pin
Richard Deeming23-Aug-19 1:08
mveRichard Deeming23-Aug-19 1:08 
Quote:
SQL
...
[Category]  [INT] NULL FOREIGN KEY (Id) REFERENCES BookCategories(Id),
... 
[Book]      [INT] NULL FOREIGN KEY (Id) REFERENCES Books(Id),
[Author]    [INT] NULL FOREIGN KEY (Id) REFERENCES Authors(Id)
...
The definition of your foreign keys is wrong. You're saying that the ID of the book must also exist in the BookCategories table, and the ID of the book author must exist in both the Books and Authors tables.

Once you fix the FK definitions, the rest of your script will work:
SQL
CREATE TABLE [dbo].[BookCategories]
(
    [Id]        [INT] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Name]      VARCHAR(MAX) NOT NULL
)

CREATE TABLE [dbo].[Books]
(
    [Id]        [INT] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Category]  [INT] NULL FOREIGN KEY REFERENCES BookCategories(Id),
    [Title]     VARCHAR(MAX) NOT NULL,
    [Price]     MONEY NULL
)

CREATE TABLE [dbo].[Authors]
(
    [Id]        [INT] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Name]      VARCHAR(MAX) NOT NULL
)

CREATE TABLE [dbo].[BookAuthors]
(
    [Id]        [INT] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Book]      [INT] NULL FOREIGN KEY REFERENCES Books(Id),
    [Author]    [INT] NULL FOREIGN KEY REFERENCES Authors(Id)
)




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Error With Simple Script Pin
Kevin Marois23-Aug-19 6:21
professionalKevin Marois23-Aug-19 6:21 
QuestionError With Simple Script Pin
Kevin Marois22-Aug-19 8:25
professionalKevin Marois22-Aug-19 8:25 
AnswerRe: Error With Simple Script Pin
David Mujica24-Oct-19 9:56
David Mujica24-Oct-19 9:56 
QuestionAccess SQL Server Remotely Via VPN Pin
Kevin Marois20-Aug-19 5:40
professionalKevin Marois20-Aug-19 5:40 
AnswerRe: Access SQL Server Remotely Via VPN Pin
Richard Deeming20-Aug-19 5:56
mveRichard Deeming20-Aug-19 5:56 
QuestionSQL Remote Connection Problem Pin
Kevin Marois19-Aug-19 7:52
professionalKevin Marois19-Aug-19 7:52 
AnswerRe: SQL Remote Connection Problem Pin
Richard Deeming19-Aug-19 8:45
mveRichard Deeming19-Aug-19 8:45 
GeneralRe: SQL Remote Connection Problem Pin
Kevin Marois19-Aug-19 9:21
professionalKevin Marois19-Aug-19 9:21 
GeneralRe: SQL Remote Connection Problem Pin
Richard Deeming19-Aug-19 9:28
mveRichard Deeming19-Aug-19 9:28 
GeneralRe: SQL Remote Connection Problem Pin
Kevin Marois19-Aug-19 9:42
professionalKevin Marois19-Aug-19 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.