We have a table following fields. like ID, Name, Address.
The company table uses several numbers of clients. after a sudden time, separate client needs different fields in the company table as per their business.
for this, we decided to provide a facility to our clients so that every client add entry fields to the company table.
Please implement the feature to add customization on the table only for the text/varchar fields.
Please design the database in a way so that in the future another type field can be added.
Task 1: Create CRUD for the company table. \b Task 2: Implement company-wise extra field facility.
This document provides an overview of the database schema used in the PrimeTech application. It details the implementation of CRUD operations for the Company table along with a feature to allow clients to add custom fields to the Company
table. This design ensures that only text/varchar fields can be added initially, with the potential for adding other types in the future.
- C#
- .NET Core
- REST API
- ASP.NET Core
- Entity Framework Core
- CQRS (Command Query Responsibility Segregation)
- DDD (Domain-Driven Design)
- Unit of Work Pattern
- Repository Pattern
- Clean Architecture
- FluentValidation
- Serilog
- Swagger
- SQL
- Git
- -Github
- CRUD Operations
- Dynamic Custom Fields
Id
(int): Primary keyName
(string): Name of the companyAddress
(string): Address of the company
Id
(int): Primary keyCompanyId
(int): Foreign key referencing theCompany
tableFieldName
(string): Name of the custom fieldFieldValue
(string): Value of the custom field
- Create: Add a new company.
- Read: Retrieve company details.
- Update: Modify company information.
- Delete: Remove a company from the database.
- Allow clients to add custom text/varchar fields to the
Company
table.
- Select all companies with their custom fields.
- Add a new custom field for a company.
- Update a company's address.
- Delete a custom field.
- Add support for new field types (e.g., date, integer) in custom fields.
The Company
table stores information about companies.
Column | Type | Description |
---|---|---|
Id |
int | Primary key |
Name |
string | Name of the company |
Address |
string | Address of the company |
The CustomField
table stores custom fields added by clients for their specific business needs.
Column | Type | Description |
---|---|---|
Id |
int | Primary key |
CompanyId |
int | Foreign key referencing the Company table |
FieldName |
string | Name of the custom field |
FieldValue |
string | Value of the custom field |
- Company to CustomField: A company can have multiple custom fields associated with it. This is a one-to-many relationship between the
Company
table and theCustomField
table, where theCustomField.CompanyId
is a foreign key referencing theCompany.Id
.
SELECT c.Id, c.Name, c.Address, cf.FieldName, cf.FieldValue
FROM Company c
LEFT JOIN CustomField cf ON c.Id = cf.CompanyId;