What I've ended up doing in the past is using sub-categories: having a single table with all common fields inside it, and then several tables which can have a zero-or-one relationship to the "core" table.
The example below is similar to something we use "in the wild"; it basically builds a hierarchical data structure, where each node may be a folder or document:
CREATE TABLE Node (
Id int identity primary key,
ParentId int null references Node.ParentId,
Name varchar(50) not null,
Description varchar(max) null
)
CREATE TABLE Doc (
Id int primary key references Node.Id,
FileExtension char(3) not null,
MimeType varchar(50) not null,
ContentLength bigint not null,
FilePathOnDisk varchar(255)
)
CREATE TABLE Folder (
Id int primary key references Node.Id,
ReadOnly bit not null
)
So your GetFolder
sproc will do:
SELECT n.Id, n.ParentId, n.Name, n.Description, f.ReadOnly
FROM Node n
JOIN Folder f ON n.Id = f.Id
WHERE f.Id = @Id
This translates quite nicely into class-based inheritance:
public class Folder : Node
{
public bool IsReadOnly { get; set; }
...etc
}