Click here to Skip to main content
15,884,472 members
Home / Discussions / Database
   

Database

 
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 
GeneralRe: SQL Remote Connection Problem - UPDATE Pin
Kevin Marois19-Nov-19 7:39
professionalKevin Marois19-Nov-19 7:39 
GeneralRe: SQL Remote Connection Problem - UPDATE Pin
Richard Deeming19-Nov-19 7:51
mveRichard Deeming19-Nov-19 7:51 
QuestionDate format in SQL Database export to Excel 23/01/1990 00:00:00 instat of 23/01/1990 Pin
jan Meeling18-Aug-19 22:15
jan Meeling18-Aug-19 22:15 
QuestionRe: Date format in SQL Database export to Excel 23/01/1990 00:00:00 instat of 23/01/1990 Pin
Richard MacCutchan18-Aug-19 22:54
mveRichard MacCutchan18-Aug-19 22:54 
AnswerRe: Date format in SQL Database export to Excel 23/01/1990 00:00:00 instat of 23/01/1990 Pin
jan Meeling19-Aug-19 1:39
jan Meeling19-Aug-19 1:39 
GeneralRe: Date format in SQL Database export to Excel 23/01/1990 00:00:00 instat of 23/01/1990 Pin
Victor Nijegorodov19-Aug-19 3:20
Victor Nijegorodov19-Aug-19 3:20 
GeneralRe: Date format in SQL Database export to Excel 23/01/1990 00:00:00 instat of 23/01/1990 Pin
Richard MacCutchan19-Aug-19 4:23
mveRichard MacCutchan19-Aug-19 4:23 

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.