Nuta
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować się zalogować lub zmienić katalog.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
W tym przewodniku Szybki start dowiesz się, jak GitHub Copilot pomaga deweloperom w projektowaniu, zrozumieniu i rozwijaniu schematów baz danych dzięki sugestiom uwzględniającym kontekst. Niezależnie od tego, czy tworzysz od podstaw, czy przeprowadzasz inżynierię wsteczną istniejących tabel, narzędzie GitHub Copilot usprawnia proces w SQL i frameworkach mapowania obiektowo-relacyjnego (ORM), dzięki czemu praca z schematami jest szybsza, inteligentniejsza i łatwiejsza w utrzymaniu.
W tej sekcji omówiono tworzenie nowych schematów od podstaw i pracę z istniejącymi bazami danych. Za pomocą GitHub Copilot można generować definicje schematów opartych na kodzie, aktualizować obiekty, wykorzystać inżynierię wsteczną oraz eksplorować istniejące bazy danych.
Tworzenie schematu
Tworzenie podstawowego schematu
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.
Modyfikowanie schematu
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`.
Tworzenie schematu z relacjami i ograniczeniami
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.
Tworzenie skryptu migracji w celu dodania kolumny
Generate a Prisma migration to add a column called `LastModified` (`datetime`) to the `Post` table.
Inżynieria odwrotna istniejącej bazy danych
Reverse engineer the current database and generate `CREATE TABLE` statements for all tables in the `SalesLT` schema.
Podsumowanie struktury tabeli
Summarize the structure of the `SalesLT.Product` table in natural language.
Generowanie modelu w języku Python
Generate a `models.py` (Django) file that reflects the structure of the `SalesLT.Customer` table.
Generowanie kontekstu i modeli platformy Entity Framework Core
Generate an Entity Framework Core DbContext and model classes for the `SalesLT` schema.
Tworzenie definicji i skojarzeń modelu
Create a Sequelize model definition for the `SalesLT.Product` and `SalesLT.Category` tables with appropriate associations.
Generowanie jednostki na podstawie tabeli
Generate a TypeORM entity for the `SalesLT.Customer` table, including primary key and indexed fields.
Generowanie skryptu migracji w celu utworzenia nowej tabeli
Generate a `knex.js` migration script to create the `SalesLT.SalesOrderHeader` table with `OrderDate`, `CustomerID`, and `TotalDue` columns.
Definiowanie relacji
Definiowanie skryptu relacyjnego z odwołaniami do klucza obcego
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)`.
Dodawanie tabeli do schematu z odwołaniami do klucza obcego
Add a `Categories` table to the `blog` schema and update the `Posts` table to include a nullable foreign key referencing `Categories(CategoryId)`.
Aktualizowanie bazy danych w celu dodania tabeli i zaktualizowania kolumn
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.
Identyfikowanie relacji kluczy obcych dla tabeli
Identify and describe all foreign key relationships that involve the `SalesLT.SalesOrderHeader` table.
Zastąp klucz obcy relacją wiele do wielu
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.
Generowanie mapowania między dwiema tabelami
Write Prisma relation mappings between `Customer`, `SalesOrderHeader`, and `SalesOrderDetail`.
Aktualizowanie modelu danych
Update a Sequelize model to include a `hasMany` and `belongsTo` relationship between `Customer` and `Order`.
Weryfikacja schematu
Sugerowanie ograniczeń dotyczących poufnych danych
Suggest constraints for a table storing user passwords (for example, special characters and length limits).
Weryfikowanie ograniczeń typu danych
Confirm that the `Name` column in `SalesLT.ProductCategory` doesn't use `nvarchar(max)` and has a reasonable maximum length constraint.
Weryfikowanie ograniczeń klucza podstawowego
Check whether the `SalesLT.Address` table has a primary key and all required fields defined.
Weryfikowanie rekordów inspekcji dla tabel
Generate a SQL script to validate that all tables in the `SalesLT` schema include a `CreatedDate` or `ModifiedDate` column.
Definiowanie modelu i uwzględnianie logiki walidacji
Define a SQLAlchemy model for the `Customer` table and include validation logic using Pydantic or custom Python validators before inserting into the database.
Dodawanie adnotacji danych na potrzeby walidacji formatu
Add data annotations in an Entity Framework model to ensure fields like `Email` and `PhoneNumber` follow specific formats.
Podziel się swoimi doświadczeniami
Aby pomóc nam udoskonalić i ulepszyć narzędzie GitHub Copilot dla rozszerzenia MSSQL, użyj następującego szablonu problemu GitHub, aby przesłać swoją opinię: GitHub Copilot Feedback
Podczas przesyłania opinii należy wziąć pod uwagę następujące kwestie:
Przetestowane scenariusze — daj nam znać obszary, na przykład tworzenie schematu, generowanie zapytań, zabezpieczenia, lokalizację.
Co się udało — opisz wszelkie doświadczenia, które przebiegły sprawnie, były pomocne lub przerosły twoje oczekiwania.
Problemy lub błędy — obejmują wszelkie problemy, niespójności lub mylące zachowania. Zrzuty ekranu lub nagrania ekranu są szczególnie przydatne.
Sugestie dotyczące poprawy — podziel się pomysłami na poprawę użyteczności, rozszerzaniem zasięgu lub ulepszaniem odpowiedzi w usłudze GitHub Copilot.
Treści powiązane
- Rozszerzenie GitHub Copilot for MSSQL dla programu Visual Studio Code
- Szybki przewodnik: korzystanie z czatu i wbudowanych sugestii GitHub Copilot
- Szybki start: generowanie kodu
- Szybki start: korzystanie z konstruktora zapytań inteligentnych
- Szybki start: Asystent optymalizatora zapytań
- Szybki start: używanie narzędzia objaśniającego logikę biznesową
- Szybki start: analizator zabezpieczeń
- Szybki start: pomocnik lokalizacji i formatowania
- Szybki start: generowanie danych na potrzeby testowania i pozorowania
- Ograniczenia i znane problemy