Megosztás:


Rövid útmutató: A sémakezelő és a tervező használata

Ebben a rövid útmutatóban megtudhatja, hogyan segíti a GitHub Copilot a fejlesztőket az adatbázisséma tervezésében, megértésében és fejlesztésében környezettudatos javaslatokkal. Akár az alapoktól, akár a meglévő táblák visszafejtésével dolgozik, a GitHub Copilot leegyszerűsíti a folyamatot az SQL- és objektum-relációs leképezési (ORM-) keretrendszerekben, így a séma gyorsabban, intelligensebben és könnyebben karbantarthatóvá válik.

Ez a szakasz az új sémák létrehozását és a meglévő adatbázisokkal való munkát ismerteti. A GitHub Copilot használatával kódelső sémadefiníciókat hozhat létre, objektumokat frissíthet vagy visszafejthet, és megismerheti a meglévő adatbázisokat.

Séma létrehozása

Alapszintű séma létrehozása

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.

Séma módosítása

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`.

Séma létrehozása kapcsolatok és korlátozások használatával

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.

Migrálási szkript létrehozása oszlop hozzáadásához

Generate a Prisma migration to add a column called `LastModified` (`datetime`) to the `Post` table.

Meglévő adatbázis visszafejtése

Reverse engineer the current database and generate `CREATE TABLE` statements for all tables in the `SalesLT` schema.

Táblázatstruktúra összegzése

Summarize the structure of the `SalesLT.Product` table in natural language.

Python-modell létrehozása

Generate a `models.py` (Django) file that reflects the structure of the `SalesLT.Customer` table.

Entity Framework Core-környezet és -modellek létrehozása

Generate an Entity Framework Core DbContext and model classes for the `SalesLT` schema.

Modelldefiníciók és társítások létrehozása

Create a Sequelize model definition for the `SalesLT.Product` and `SalesLT.Category` tables with appropriate associations.

Entitás létrehozása táblából

Generate a TypeORM entity for the `SalesLT.Customer` table, including primary key and indexed fields.

Migrálási szkript létrehozása új tábla létrehozásához

Generate a `knex.js` migration script to create the `SalesLT.SalesOrderHeader` table with `OrderDate`, `CustomerID`, and `TotalDue` columns.

Kapcsolatok definiálása

Relációs szkript definiálása idegenkulcs-hivatkozásokkal

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)`.

Táblázat hozzáadása egy sémához idegenkulcs-hivatkozásokkal

Add a `Categories` table to the `blog` schema and update the `Posts` table to include a nullable foreign key referencing `Categories(CategoryId)`.

Adatbázis frissítése táblázat hozzáadásához és oszlopok frissítéséhez

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.

Tábla idegenkulcs-kapcsolatainak azonosítása

Identify and describe all foreign key relationships that involve the `SalesLT.SalesOrderHeader` table.

Egy idegen kulcs cseréje több-a-többhöz kapcsolatra

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.

Leképezés létrehozása két tábla között

Write Prisma relation mappings between `Customer`, `SalesOrderHeader`, and `SalesOrderDetail`.

Adatmodell frissítése

Update a Sequelize model to include a `hasMany` and `belongsTo` relationship between `Customer` and `Order`.

Sémaellenőrzés

Bizalmas adatokra vonatkozó korlátozások ajánlása

Suggest constraints for a table storing user passwords (for example, special characters and length limits).

Adattípus-korlátozások érvényesítése

Confirm that the `Name` column in `SalesLT.ProductCategory` doesn't use `nvarchar(max)` and has a reasonable maximum length constraint.

Elsődleges kulcskorlátozások ellenőrzése

Check whether the `SalesLT.Address` table has a primary key and all required fields defined.

Táblák naplózási rekordjainak ellenőrzése

Generate a SQL script to validate that all tables in the `SalesLT` schema include a `CreatedDate` or `ModifiedDate` column.

Modell definiálása és érvényesítési logika belefoglalása

Define a SQLAlchemy model for the `Customer` table and include validation logic using Pydantic or custom Python validators before inserting into the database.

Adatjegyzetek hozzáadása formátumérvényesítéshez

Add data annotations in an Entity Framework model to ensure fields like `Email` and `PhoneNumber` follow specific formats.

Ossza meg tapasztalatait

Az MSSQL-bővítményHez tartozó GitHub Copilot pontosításához és fejlesztéséhez használja a következő GitHub-problémasablont a visszajelzés elküldéséhez: GitHub Copilot Feedback

Visszajelzés küldésekor fontolja meg a következőket:

  • Tesztelt forgatókönyvek: Tudassa velünk, hogy mely területekre összpontosított, például sémalétrehozásra, lekérdezésgenerálásra, biztonságra, honosításra.

  • Ami jól működött: Ismertesse azokat a tapasztalatokat, amelyek zökkenőmentesnek, hasznosnak mutattak, vagy amelyek meghaladták az Ön elvárásait.

  • Problémák vagy hibák: Tartalmazzon bármilyen problémát, következetlenséget vagy zavaró viselkedést. A képernyőképek és a képernyőfelvételek különösen hasznosak.

  • Fejlesztési javaslatok: Ötletek megosztása a használhatóság javítására, a lefedettség bővítésére vagy a GitHub Copilot válaszainak javítására.