DEV Community

Cover image for Pushing skills to a new level
Karen Payne
Karen Payne

Posted on

Pushing skills to a new level

Introduction

As a developer, a professional, or just starting out, you must continually learn and hone your craft. There is a great way to accomplish this: first, write down objectives, then create a side project.

The objective here is to create a contact solution using a SQL Server relational database and Microsoft EF Core to interact with it, implemented in a class project.

database schema

Database creation

Developers should consider using AI tools to build their databases, especially if they have limited experience with relational databases and proper indices.

Using ChatGPT to create the database

Prompt

For the contact database, the following prompt was used.

For Microsoft SQL Server, create a new relational database script for the following to create a contact database.

Database name: Contacts

Person table, gender reference table (Male, Female, Other), United States reference table, Address type reference table, Address table, Device table (Home phone, Work phone, Home email, Work email)

What other tables do I need?

The last sentence allows ChatGPT (or whatever tool is used) to make recommendations. In this case, several junction tables were included.

Note
A junction table (also known as an associative, bridge, or linking table) is a standard relational database design practice used to manage many-to-many relationships between two other tables.

Populating database tables

For reference tables, the ChatGPT-generated script included several tables, including a gender table populated with data.

Executing the script created by ChatGPT

Using SSMS (SQL Server Management Studio)

  • Create the Contacts database
  • Run the script generated by ChatGPT
  • Create a backup of the database
  • Fully populate one contact
  • Read the contact using the following statement to validate the schema
SELECT P.PersonId,
       P.FirstName,
       P.LastName,
       P.MiddleName,
       P.DateOfBirth,
       P.GenderId,
       G.GenderName,
       P.CreatedAt,
       P.UpdatedAt,
       D.IsActive,
       D.DeviceValue,
       DT.DeviceTypeName,
       DT.DeviceKind,
       DT.DeviceTypeId,
       P.Notes
FROM dbo.DeviceType AS DT
         INNER JOIN dbo.Device AS D
                    ON DT.DeviceTypeId = D.DeviceTypeId
         INNER JOIN dbo.PersonDevice AS PD
                    ON D.DeviceId = PD.DeviceId
         INNER JOIN dbo.Person AS P
                    ON PD.PersonId = P.PersonId
         INNER JOIN dbo.Gender AS G
                    ON P.GenderId = G.GenderId;
Enter fullscreen mode Exit fullscreen mode
  • Continue with the current schema or make adjustments and re-validate the schema.

Reverse engineering the database

This is best done with a Microsoft Visual Studio extension, EF Power Tools which is easy to use.

Watch a 25-minute demo to get an introduction to the tool

The reverse engineering is done in a class project, which one or more frontend projects can work with, rather than reverse-engineering in a frontend project.

Integration to a frontend

The next step is to select the frontend project type from desktop, mobile, or web.

Rather than start coding or using an AI tool to create the frontend, this should be a time to learn by first creating a plan for the look and feel, identifying which classes are needed for forms or pages, and adding modals as needed.

Planning

Here are two ways to start planning.

  • Using a document and images
  • Gherkin syntax Behaviour-Driven Development (BDD)

Before coding

Create a GitHub repository for the solution, which can be private or public, and should house only working code.

Coding

Take your time, follow your plan, and, in many cases, it can change while coding; if so, update it.

Documentation

Don’t think that documentation is not needed, consider that you may not fully understand code written today next week.

  • Each project needs a README.md to at least describe the project
  • Document all classes and, methods and inline code
  • For mobile and web document CSS styles

Summary

Although the database base code and database script have been provided, consider trying this out on your next learning project.

For the frontend project selection, there will be plenty to learn, and resist the urge to use AI tools unless you are stuck.

Keep in mind the reason for all of this is to learn which is the number one reason to steer clear of vibe coding.

Source code

Top comments (0)