Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Modular Code with OOP Patterns
00:00
5 left

Modular Code with OOP Patterns

HardSQL · PostgreSQL

Problem

Describe how you would implement specific Object-Oriented Programming (OOP) patterns to keep code modular.

For this SQL representation, use the provided pattern, module, and module-pattern tables to identify active modules associated with at least two distinct OOP patterns.

Output

  1. Return one row per qualifying active module with module_name, pattern_count, and alphabetically ordered pattern_names.
  2. Exclude inactive modules and modules associated with fewer than two patterns.
  3. Order by pattern_count descending, then module_name ascending.

Schema

oop_patterns
ColumnTypeDescription
pattern_idPKINTUnique identifier for an OOP pattern
pattern_nameVARCHAR(80)Name of the OOP pattern
categoryVARCHAR(40)Pattern category
code_modules
ColumnTypeDescription
module_idPKINTUnique identifier for a code module
module_nameVARCHAR(100)Name of the code module
is_activeBOOLEANWhether the module is currently active
descriptionTEXTOptional module description
module_patterns
ColumnTypeDescription
module_idINTReferenced code module
pattern_idINTReferenced OOP pattern
Tablesoop_patternscode_modulesmodule_patterns
Interviewer

Your question is Modular Code with OOP Patterns. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.