Having briefly studied databases in college, I haven’t worked with them since and have drawn a bit of a blank, so I was wondering if someone could help me out. I have a database called Convert, which holds the following tables:
**File**
ID int PK
ISBN nvarchar(MAX)
UserName nvarchar(50)
CoverID
PDFID
**PDF**
PDFID int PK
FileContent image
MimeType nvarchar
FileName nvarchar
**Cover**
CoverID int PK
FileContent image
MimeType nvarchar
FileName nvarchar
I’ve just drawn a blank on two things really.
-
Relationships. I think if I a sql query such as below I will create foreign keys:
Alter TABLE Cover ADD FOREIGN KEY (CoverID) REFERENCES File (CoverID)
What I need to do is create one to one relationships –> One File will have one Cover, and one PDF.
The second is thing I’m having difficulty getting my head around again is the insert statements. Any advice on how I should handle those would be appreciated?
I’m using SQL Server 2008 Also.
if you want to ensure that a relation will have one to one relationship, then make one big table.
one table where you have
what you might ment in your original design is to make one table that could contain all 3 types and each row is different by having different value at “mime type” which is also possible, if hold keys that relet the table to itself.
such as