이 빠른 시작에서는 GitHub Copilot가 컨텍스트 인식 제안으로 데이터베이스 스키마를 디자인, 이해 및 발전시키는 데 개발자를 지원하는 방법을 알아봅니다. GitHub Copilot는 처음부터 빌드하든 기존 테이블을 리버스 엔지니어링하든 관계없이 SQL 및 ORM(개체 관계형 매핑) 프레임워크에서 프로세스를 간소화하여 스키마 작업을 더 빠르고 스마트하며 유지 관리하기 쉽습니다.
이 섹션에서는 새 스키마를 처음부터 만들고 기존 데이터베이스로 작업하는 방법에 대해 설명합니다. GitHub Copilot를 사용하여 코드 우선 스키마 정의를 생성하거나, 개체를 업데이트하거나, 리버스 엔지니어링하고, 기존 데이터베이스를 탐색할 수 있습니다.
스키마 만들기
기본 스키마 만들기
Write a SQL script to create a new schema named `blog` for a blog application. The schema should include three tables: `Posts`, `Comments`, and `Users`. Each table must have appropriate primary keys, and the necessary foreign key relationships and constraints should be defined.
스키마 수정
Add a new column named `LastModified` of type `datetime` to the `Posts` table in the `blog` schema. Generate the updated SQL script reflecting this change, including the full definition of the modified schema.
It isn't needed to create the schema, but it would be great if you could use the script generated and run it to validate the accuracy of the generated code. The following section continues using this new schema called `blog`.
관계 및 제약 조건을 사용하여 스키마 만들기
Generate a Prisma schema for a blog application using my current database. The schema should define a new database schema named `blog` and include tables for `posts`, `authors`, and `comments`, with appropriate relationships and constraints.
열을 추가하는 마이그레이션 스크립트 만들기
Generate a Prisma migration to add a column called `LastModified` (`datetime`) to the `Post` table.
기존 데이터베이스 리버스 엔지니어링
Reverse engineer the current database and generate `CREATE TABLE` statements for all tables in the `SalesLT` schema.
테이블 구조 요약
Summarize the structure of the `SalesLT.Product` table in natural language.
Python 모델 생성
Generate a `models.py` (Django) file that reflects the structure of the `SalesLT.Customer` table.
Entity Framework Core 컨텍스트 및 모델 생성
Generate an Entity Framework Core DbContext and model classes for the `SalesLT` schema.
모델 정의 및 연결 만들기
Create a Sequelize model definition for the `SalesLT.Product` and `SalesLT.Category` tables with appropriate associations.
테이블에서 엔터티 생성
Generate a TypeORM entity for the `SalesLT.Customer` table, including primary key and indexed fields.
새 테이블을 만드는 마이그레이션 스크립트 생성
Generate a `knex.js` migration script to create the `SalesLT.SalesOrderHeader` table with `OrderDate`, `CustomerID`, and `TotalDue` columns.
관계 정의
외래 키 참조를 사용하여 관계형 스크립트 정의
Write SQL to define a one-to-many relationship between `Users` and `Posts` in the `blog` schema. Ensure the foreign key in `Posts` references `Users(UserId)`.
외래 키 참조를 사용하여 스키마에 테이블 추가
Add a `Categories` table to the `blog` schema and update the `Posts` table to include a nullable foreign key referencing `Categories(CategoryId)`.
테이블을 추가하고 열을 업데이트하도록 데이터베이스 업데이트
Write SQL to update the `Users` table to include a `RoleId` column and create a new `Roles` table. Define a foreign key relationship and enforce that every user must have a role.
테이블의 외래 키 관계 식별
Identify and describe all foreign key relationships that involve the `SalesLT.SalesOrderHeader` table.
외래 키를 다대다 관계로 변환하기
Write a SQL script that removes a foreign key between `Posts` and `Categories` in the `blog` schema and replaces it with a many-to-many relationship using a new join table.
두 테이블 간의 매핑 생성
Write Prisma relation mappings between `Customer`, `SalesOrderHeader`, and `SalesOrderDetail`.
데이터 모델 업데이트
Update a Sequelize model to include a `hasMany` and `belongsTo` relationship between `Customer` and `Order`.
스키마 유효성 검사
중요한 데이터에 대한 제약 조건 제안
Suggest constraints for a table storing user passwords (for example, special characters and length limits).
데이터 형식 제약 조건 유효성 검사
Confirm that the `Name` column in `SalesLT.ProductCategory` doesn't use `nvarchar(max)` and has a reasonable maximum length constraint.
기본 키 제약 조건 유효성 검사
Check whether the `SalesLT.Address` table has a primary key and all required fields defined.
테이블에 대한 감사 레코드 유효성 검사
Generate a SQL script to validate that all tables in the `SalesLT` schema include a `CreatedDate` or `ModifiedDate` column.
모델 정의 및 유효성 검사 논리 포함
Define a SQLAlchemy model for the `Customer` table and include validation logic using Pydantic or custom Python validators before inserting into the database.
형식 유효성 검사를 위한 데이터 주석 추가
Add data annotations in an Entity Framework model to ensure fields like `Email` and `PhoneNumber` follow specific formats.
사용자 경험 공유
MSSQL 확장에 대한 GitHub Copilot를 구체화하고 개선하는 데 도움이 되도록 다음 GitHub 문제 템플릿을 사용하여 피드백을 제출합니다. GitHub Copilot 피드백
피드백을 제출할 때 다음을 포함하는 것이 좋습니다.
테스트된 시나리오 – 스키마 만들기, 쿼리 생성, 보안, 지역화와 같이 집중한 영역을 알려주세요.
잘 작동하는 기능 – 원활하거나 도움이 되거나 예상을 초과한 모든 경험을 설명합니다.
문제 또는 버그 – 문제, 불일치 또는 혼란스러운 동작을 포함합니다. 스크린샷 또는 화면 녹화는 특히 유용합니다.
개선 제안 - 유용성 향상, 적용 범위 확장 또는 GitHub Copilot의 응답 향상을 위한 아이디어를 공유합니다.