Aracılığıyla paylaş


Hızlı Başlangıç: Şema gezginini ve tasarımcıyı kullanma

Bu hızlı başlangıçta GitHub Copilot'un bağlama duyarlı önerilerle geliştiricilere veritabanı şemalarını tasarlama, anlama ve geliştirme konusunda nasıl yardımcı olduğunu öğreneceksiniz. İster sıfırdan ister var olan tabloları tersine mühendislik işlemi yapıyor olun, GitHub Copilot SQL ve nesne ilişkisel eşleme (ORM) çerçeveleri genelinde süreci kolaylaştırarak şemanın daha hızlı, daha akıllı ve bakımının daha kolay olmasını sağlar.

Bu bölüm hem sıfırdan yeni şemalar oluşturmayı hem de mevcut veritabanlarıyla çalışmayı kapsar. GitHub Copilot kullanarak kod öncelikli şema tanımları oluşturabilir, nesneleri güncelleştirebilir veya tersine mühendislik yapabilir ve mevcut veritabanlarını keşfedebilirsiniz.

Şema oluşturma

Temel şema oluşturma

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.

Şemayı değiştirme

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

İlişkiler ve kısıtlamalarla şema oluşturma

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.

Sütun eklemek için geçiş betiği oluşturma

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

Mevcut bir veritabanına ters mühendislik uygulama

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

Tablo yapısını özetleme

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

Python modeli oluşturma

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

Entity Framework Core bağlamı ve modelleri oluşturma

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

Model tanımı ve ilişkilendirmeleri oluşturma

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

Tablodan varlık oluşturma

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

Yeni tablo oluşturmak için geçiş betiği oluşturma

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

İlişkileri tanımlama

Yabancı anahtar referanslarıyla ilişkisel betik tanımlama

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

Şemaya yabancı anahtar referanslarıyla bir tablo ekleme

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

Tablo eklemek ve sütunları güncelleştirmek için veritabanını güncelleştirme

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.

Tablo için yabancı anahtar ilişkilerini tanımlayın

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

Bir yabancı anahtarı çoka-çok ilişkiyle değiştirme

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.

İki tablo arasında eşleme oluşturma

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

Veri modelini güncelleştirme

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

Şema doğrulaması

Hassas veriler için kısıtlamalar önerin

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

Veri türü kısıtlamalarını doğrulama

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

Birincil anahtar kısıtlamalarını doğrulama

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

Tablolar için denetim kayıtlarını doğrulama

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

Model tanımlama ve doğrulama mantığı ekleme

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

Biçim doğrulaması için veri açıklamaları ekleme

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

Deneyiminizi paylaşma

MSSQL uzantısı için GitHub Copilot'ı geliştirmemize ve geliştirmemize yardımcı olmak için aşağıdaki GitHub sorun şablonunu kullanarak geri bildiriminizi gönderin: GitHub Copilot Geri Bildirimi

Geri bildirim gönderirken şunları dahil etmeyi göz önünde bulundurun:

  • Test edilen senaryolar : Şema oluşturma, sorgu oluşturma, güvenlik, yerelleştirme gibi hangi alanlara odaklandığınız konusunda bize bilgi verin.

  • Başarılı Olanlar - Sorunsuz, yararlı veya beklentilerinizi aşan deneyimlerinizi açıklayın.

  • Sorunlar veya hatalar : Tüm sorunları, tutarsızlıkları veya kafa karıştırıcı davranışları içerir. Ekran görüntüleri veya ekran kayıtları özellikle yararlıdır.

  • İyileştirme önerileri : Kullanılabilirliği artırma, kapsamı genişletme veya GitHub Copilot'un yanıtlarını geliştirmeyle ilgili fikirleri paylaşın.