Repository navigation
interview: конструктор schema — поля по таблицам и внешние ключи - #47
Merged
Merged
Conversation
…k foreign keys
- content: build.kind: schema with tables (name, fields; a field is a name or {name, ref}) and distractor fields;
the loader checks identifiers, unique tables and fields, refs to known tables, distractors not equal to real fields;
the question gets table names and shuffled field pieces, the answer gets the reference schema after the summary
- validator: constructor blocks of kind schema (tables in the question, schema in the answer)
- AI review: with_text prompt says the schema is graded separately; the reference schema goes in as table(field -> ref)
- frontend: SchemaBuilder — drag fields onto table cards or pick a table from a menu (tap, keyboard), a select marks
the foreign key, Delete returns a field; scoreSchema = floor(10 * (fields in place + right refs) / (fields + refs)),
−2 per distractor, −1 per wrong ref; same-named fields (id) are interchangeable
- BuildPanel, GradeScale, Bit lines, results and the reference view know both kinds
- db-normalization-1nf-3nf: schema with_text (4 tables in 3NF, distractors items / customer_city / product_title)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что сделано
Новый вид конструктора:
kind: schema, схема БД (продолжение #43 и #46). Таблицы заданы. Кандидат раскладывает по ним поля и отмечает, на какую таблицу ссылается внешний ключ. Работает в обоих режимах:replaceиwith_text.Данные
a-z0-9_, без повторов;refуказывает только на таблицу из списка;stepsразрешены только дляsequence,tables— только дляschema.idразных таблиц разные куски, но они взаимозаменяемы.sequenceid кусков и их порядок не изменились: повторный импорт обновил только вопрос со схемой.items,customer_city,product_titleнарушают 1NF, 3NF и 2NF соответственно. Вопрос без компаний, в собеседование попадает через шаг роадмапа SQL «Проектирование схемы».docs/content.md.Оценка (в браузере, без ИИ)
Интерфейс
SchemaBuilder:BuildPanel(ConstructorTask = sequence | schema,findConstructorTask);GradeScale: шкала и «Как раскладывать»;ContentRenderer: эталон показывается карточками таблиц.customers(id, name, city); orders(id, customer_id -> customers)….Скриншоты
Поля разложены, два ключа из трёх отмечены:





Схема сдана: 9/10, у
product_idпометка «не отмечен внешний ключ»:Объяснение оценил ИИ: 7/10 от локального фейкового провайдера, поэтому текст разбора в карточке заготовлен заранее и к вопросу не относится. Итог 8/10, «Прошёл»:
Эталонная схема в ответе:
Телефон, 375px:
Проверки
vitest: 178 тестов.schema.test.ts: подсчёт балла (взаимозаменяемыеid, ключи, чужая таблица, отвлекающее поле, дубли) и поиск задания и эталона.BuildPanelschema: сборка через меню, ключ и сдача на 10/10; пометки ошибок; перенос поля и Delete.eslint,tsc -b,vite build,size-limit— без ошибок.pytest: 474 passed. Новое: формат schema (блоки, сломанные схемы, валидатор) иblocks_to_textдля схемы.ruffбез замечаний.test_schemathesis: 66 passed. В двух прогонах из пяти фаззингPOST /api/v1/admin/ai-settings/testпадал с UnicodeEncodeError на сгенерированных данных. Это плавающая проблема эндпоинта (не-ASCII ключ API уходит в заголовок), в этом PR он не менялся; наmainи на этой ветке тест в остальных прогонах проходит.