Database Schema Management & Architecture
Customizing SQL Server Schemas, Organizing Constants, and Leveraging Clean Architectural Standards in AUA
SQL Server Schema Management
A key security and organizational consideration in SQL Server is the table schema. By default, tables are created with the standard dbo prefix. The AUA framework allows developers to easily customize and override this schema. Furthermore, to manage application-wide constants cleanly and prevent dispersal, constants are organized systematically within structured classes.
The Architectural Philosophy behind AUA
The AUA (Asp.Net Unique Architecture) Framework empowers developers to write cleaner, faster, and more orderly code. It builds upon modern principles including Clean Architecture, Clean Code, Domain-Driven Design (DDD), Lmax Architecture, SOLID principles, Code Refactoring, and GRASP object-oriented design patterns.
Without a uniform architectural structure, software projects suffer from code inconsistency, task duplication, and fragility where changes in one module break others. Just as frontend developers rely on utility libraries like Bootstrap rather than writing raw CSS from scratch, backend engineers utilize general-purpose frameworks to save time, reduce costs, and maintain high standards of code maintainability.
Custom Schema & Consts Definition
public class SchemaConsts
{
public const string Accounting = "Acc";
public const string School = "Sch";
}
[Table("Student", Schema = SchemaConsts.School)]
public class Student : DomainEntity
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
Stored Procedure Context & Service Call
// 1. Output ViewModel
public class GetUserRolesSpResult
{
public int RoleId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
// 2. Service Implementation
public class StoredProcService : FuncBaseService, IStoredProcService
{
public StoredProcService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
public IQueryable<GetUserRolesSpResult> GetUserRolesSp(long userId)
{
var cmd = LoadStoredProc(StoredProcedureConsts.GetUserRoles)
.WithSqlParam("userId", userId);
return cmd.ExecutStoredProc<GetUserRolesSpResult>();
}
}
"If you think good architecture is expensive, try bad architecture."AUA Framework Philosophy