Velocer › Thẻ ghi nhớ › University of Wisconsin–Madison › CS 574: Data Security and Privacy · UW-Madison
CS 574: Data Security and Privacy · UW-Madison
For CS 574 exam review. · bởi stack_and_sprout · 167 thẻ
- What does ACID stand for in relational database transactions?Atomicity, Consistency, Isolation, Durability.
- What is the purpose of Relational Algebra in databases?It provides a formal query language for expressing operations on relations, forming the theoretical foundation for SQL queries.
- What is BSON in MongoDB?A binary-encoded serialization format used by MongoDB to store documents, extending JSON with additional data types.
- What is MQL?MongoDB Query Language, the syntax used to query and manipulate documents in MongoDB.
- What is an aggregation pipeline in MongoDB?A framework of staged operations that process documents through multiple transformations to compute aggregated results.
- What is GeoJSON used for in MongoDB?It is a format for encoding geographic data structures, enabling spatial indexing and geospatial queries.
- What is Elasticsearch built on, and what is its core data structure?It is built on Apache Lucene and uses distributed inverted indexes for full-text search.
- What is BM25 in Elasticsearch?A relevance scoring algorithm that ranks documents based on term frequency, inverse document frequency, and document length.
- What is kNN vector search used for in Elasticsearch?It finds the nearest vectors to a query vector, enabling similarity search for embeddings and unstructured data.
- What does SSH provide in system administration?Secure encrypted remote access to systems for administration and data transfer.
- What are OLAP window functions used for in SQL?They perform calculations across a set of rows related to the current row, enabling analytics like running totals and rankings without collapsing rows.
- What is the purpose of query auditing in data security?To monitor, log, and analyze database queries to detect unauthorized access, enforce policies, and ensure correctness and compliance.
- What is a nested mapping in Elasticsearch?A mapping that allows arrays of objects to be indexed independently so each object's fields are queried as a unit.
- What is a Lucene analyzer responsible for?It converts text into tokens through character filtering, tokenization, and token filtering to prepare text for indexing and search.
- What command generates an SSH key pair?ssh-keygen generates a private key and a matching public key.
- Where is the SSH private key stored, and how should it be handled?It is stored on the client (e.g., ~/.ssh/id_rsa or id_ed25519) and must be kept strictly secret.
- Where must the SSH public key be placed to enable login on a remote server?It is appended to ~/.ssh/authorized_keys on the remote VM.
- Why does OpenSSH refuse key authentication based on file permissions?OpenSSH rejects key auth if directory or file permissions allow other users write access, so permissions must be hardened.
- Which file holds the server-side SSH daemon configuration, and how is it reloaded?It lives in /etc/ssh/sshd_config and is reloaded with sudo service ssh restart.
- What does SSH local port forwarding accomplish?It securely forwards traffic from a local machine port to a service bound to localhost on a remote server.
- Give examples of services commonly reached via SSH local port forwarding.JupyterLab on port 8888, Kibana on 5601, and MySQL on 3306.
- In SSH key authentication, which key stays on the client and which goes to the server?The private key stays secret on the client; the public key is placed in authorized_keys on the server.
- What is the purpose of the authorized_keys file?It lists public keys permitted to authenticate to the account on the remote server.
- What is asymmetric key authentication in SSH?A method where a client proves identity using a private key while the server verifies it with the corresponding public key.
- What are the three permission scopes in POSIX permission bits?User/Owner (u), Group (g), and Others (o).
- What numeric values correspond to the read, write, and execute permission bits?Read (r) = 4, Write (w) = 2, Execute (x) = 1.
- What does the octal permission 755 represent in symbolic notation?rwxr-xr-x (owner: read/write/execute, group: read/execute, others: read/execute).
- What does the octal permission 600 represent in symbolic notation?rw------- (owner: read/write, group: none, others: none).
- What are the file descriptor numbers for stdin, stdout, and stderr?stdin = 0, stdout = 1, stderr = 2.
- In a shell pipeline like cmdA | cmdB, what happens to stderr?stderr is not piped across the pipe; it prints directly to the terminal unless explicitly redirected.
- What is the difference between > and >> for output redirection?> truncates the file and writes stdout; >> appends stdout to the end of the file.
- How do you redirect only stderr to a file?Use 2> filename (e.g., cmd 2> err.log).
- How do you redirect both stdout and stderr to the same file?Use &> filename or > filename 2>&1.
- What does the && operator do between two commands?Runs the first command, and executes the second command only if the first exits with status 0 (success).
- What does appending & to a command do?Launches the command asynchronously in the background and immediately returns shell control.
- What is the difference between kill <PID> and kill -9 <PID>?kill <PID> sends SIGTERM (15) for graceful termination; kill -9 <PID> sends SIGKILL (9) for immediate termination.
- What is a database transaction?A logical unit of work comprising one or more database reads and/or writes.
- What does the A in ACID stand for, and what does it mean?Atomicity ("All-or-Nothing"): either every operation in the transaction completes and is committed, or if any statement fails, the entire transaction is aborted and rolled back to its pre-transaction state.
- What does the C in ACID stand for, and what does it mean?Consistency (Integrity Preservation): every committed transaction transitions the database from one valid state to another, preserving all declared schema constraints such as PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, and triggers.
- What does the I in ACID stand for, and what does it mean?Isolation (Concurrency Control): concurrent transactions execute as if isolated from one another, and uncommitted intermediate modifications of one transaction cannot corrupt other concurrent transactions.
- What does the D in ACID stand for, and what does it mean?Durability (Crash Persistence): once a transaction commits, its modifications are permanently recorded in non-volatile storage (write-ahead logs / disk) and survive power loss or system crashes.
- Which ACID property guarantees that a failed statement undoes the entire transaction?Atomicity — the transaction is aborted and rolled back to its pre-transaction state.
- Which ACID property relies on schema constraints like PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK?Consistency — committed transactions must preserve all declared schema constraints.
- Which ACID property prevents uncommitted changes from corrupting other concurrent transactions?Isolation (Concurrency Control).
- Which ACID property ensures committed data survives a power loss or system crash?Durability — modifications are written to non-volatile storage such as write-ahead logs or disk.
- What mechanism commonly provides durability for committed transactions?Write-ahead logs and disk (non-volatile storage).
- What happens to a transaction if any of its statements fails?Under atomicity, the entire transaction is aborted and rolled back to its pre-transaction state.
- What is the difference between atomicity and durability?Atomicity is about all-or-nothing execution of a transaction's operations; durability is about committed changes persisting permanently across crashes.
- What is the difference between consistency and isolation in ACID?Consistency ensures each committed transaction moves the database between valid states preserving constraints; isolation ensures concurrent transactions don't see or corrupt each other's uncommitted work.
- What SQL command permanently records a transaction's changes?COMMIT.
- What does the COMMIT command do in terms of ACID properties?It permanently records the transaction's modifications in non-volatile storage, satisfying durability.
- What does the ROLLBACK command do?It aborts the transaction and undoes its changes, returning the database to its pre-transaction state (atomicity).
- What is the difference between CHAR(n) and VARCHAR(n) in MySQL?CHAR(n) is fixed-length (up to 255 bytes) and right-padded with spaces; VARCHAR(n) is variable-length (up to 65,535 bytes) with a 1–2 byte length prefix.
- When would you choose CHAR over VARCHAR?When storing fixed-length codes like 2-letter state abbreviations, since CHAR is fast for fixed-length values.
- What are the four MySQL TEXT types, ordered by size?TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT.
- How many bytes does a MySQL TINYINT use, and what are its signed and unsigned ranges?1 byte; signed range is -128 to 127, UNSIGNED range is 0 to 255.
- What is the difference between DECIMAL and FLOAT/DOUBLE in MySQL?DECIMAL is fixed-point and exact; FLOAT and DOUBLE are floating-point and approximate.
- In DECIMAL(p, s), what do p and s represent?p is the total number of digits and s is the number of digits after the decimal point.
- What format does MySQL's DATE type use?'YYYY-MM-DD'.
- What format does MySQL's TIME type use?'HH:MM:SS'.
- What format does MySQL's DATETIME type use?'YYYY-MM-DD HH:MM:SS'.
- How does MySQL's TIMESTAMP type differ from DATETIME?TIMESTAMP stores a UTC-converted epoch timestamp, while DATETIME stores a literal date and time without timezone conversion.
- What is the logical evaluation order of a SQL query?FROM/JOIN/ON → WHERE → GROUP BY → HAVING → SELECT (and window functions) → DISTINCT → ORDER BY → LIMIT/OFFSET.
- Why can't a column alias defined in SELECT be used in WHERE?Because WHERE is evaluated before SELECT in the logical order, so the alias doesn't exist yet when WHERE runs.
- Why can't aggregate functions like SUM or COUNT appear in WHERE?WHERE runs before GROUP BY, so groups don't exist yet. Use HAVING to filter groups after aggregation.
- What is an uncorrelated subquery?An inner query that is completely independent of the outer query and executes once before the outer query.
- What is a correlated subquery?An inner query that references a column from the outer query's table and is logically re-evaluated for each outer row, often used with EXISTS/NOT EXISTS.
- What is the danger of using NOT IN with a subquery that returns NULL?If the subquery returns any NULL, x NOT IN (...) evaluates to UNKNOWN, producing an empty result set.
- What does > ANY mean in a quantified comparison?It means greater than the minimum value returned by the subquery (true if greater than at least one value).
- What does > ALL mean in a quantified comparison?It means greater than the maximum value returned by the subquery (true only if greater than every value).
- Which clause filters individual rows before grouping?WHERE, which runs before GROUP BY.
- Which clause filters groups after aggregation?HAVING, which runs after GROUP BY.
- At what point in the logical order are window functions evaluated?During the SELECT phase, after GROUP BY and HAVING.
- Which SQL clause runs last in the logical evaluation order?LIMIT/OFFSET, after ORDER BY.
- What is the difference between lexical (written) order and logical evaluation order in SQL?Lexical order is how the query is written; logical order is the sequence in which clauses are actually evaluated, starting with FROM/JOIN.
- When does DISTINCT execute relative to SELECT and ORDER BY?DISTINCT runs after SELECT (and window functions) but before ORDER BY.
- How does a window function differ from GROUP BY?GROUP BY collapses each group into a single summary row, while a window function computes across related rows but preserves every individual row.
- What does ROW_NUMBER() return for tied values like 100, 90, 90, 80?1, 2, 3, 4 — it assigns strictly unique consecutive integers with arbitrary tie-breaking.
- What does RANK() return for tied values like 100, 90, 90, 80?1, 2, 2, 4 — ties get the same rank, and subsequent rank numbers are skipped.
- What does DENSE_RANK() return for tied values like 100, 90, 90, 80?1, 2, 2, 3 — ties get the same rank with no gaps in the rank numbers.
- Which ranking function skips rank numbers after a tie?RANK() skips subsequent rank numbers after assigning the same rank to tied values.
- Which ranking function produces no gaps in rank numbers?DENSE_RANK() assigns the same rank to ties without leaving gaps.
- Which ranking function guarantees strictly unique consecutive integers?ROW_NUMBER() always returns unique consecutive integers, breaking ties arbitrarily.
- What is a window function?A function that computes an aggregate or ranking across a sliding window of related rows while preserving every individual row.
- What is BSON?BSON is MongoDB's binary-encoded serialization format for documents. It uses length prefixes for fast field skipping and supports richer data types than JSON.
- How many data types does standard JSON support, and what are they?JSON supports 6 data types: string, number, boolean, null, array, and object. It is human-readable plain text requiring full string parsing.
- What advantage do BSON length prefixes provide?Length prefixes enable fast field skipping and traversal without parsing the entire document. This makes lookups more efficient than full string parsing.
- What is ObjectId in MongoDB?ObjectId is a 12-byte unique identifier used as the default _id field. It is a native BSON data type.
- Which BSON type should be used for exact financial calculations?Decimal128. It provides exact decimal representation, avoiding floating-point rounding errors for financial data.
- What BSON type stores UTC milliseconds for dates?The Date type stores dates as UTC milliseconds. It is a native BSON data type not available in standard JSON.
- What is embedding (denormalization) in MongoDB schema design?Embedding nests related entities inside a parent document, such as order line items inside an order. It allows atomic single-document reads and writes without joins.
- What is linking (normalization) in MongoDB schema design?Linking stores foreign _id references across separate collections and joins them at query time via $lookup. It avoids unbounded document growth and duplication when sub-entities change frequently.
- What is the maximum BSON document size in MongoDB?16 MB. This limit is a key reason to use linking instead of embedding when sub-entities could grow unbounded.
- Which aggregation stage joins linked collections in MongoDB?$lookup. It performs a join across collections at query time for linked (normalized) documents.
- When should you prefer embedding over linking?Prefer embedding when related data is accessed together and sub-entities don't change frequently. It enables atomic single-document operations without joins.
- When should you prefer linking over embedding?Prefer linking when sub-entities change frequently or could grow unbounded beyond the 16 MB limit. It avoids duplication and document bloat.
- What are the key differences between JSON and BSON?JSON is human-readable text with 6 data types; BSON is binary with length prefixes and rich types like ObjectId, Date, Decimal128, Int32, Int64, BinData, and RegExp.
- Name three BSON-specific data types not available in standard JSON.ObjectId, Date, and Decimal128 (also Int32, Int64, BinData, RegExp). These add rich native typing beyond JSON's 6 types.
- Why does BSON enable faster traversal than JSON?BSON stores length prefixes for fields, allowing the database to skip over fields without parsing them. JSON requires full string parsing to navigate.
- What does db.col.count_documents(filter) do?Returns an exact count of documents matching the filter by scanning the matches.
- What does db.col.estimated_document_count() do?Returns an approximate count from collection metadata in O(1) time, without scanning documents.
- What does db.col.distinct("field", filter) return?An array of the distinct values of the specified field across documents matching the optional filter.
- What is the difference between \(exists: true and \)type: "null"?\(exists: true matches documents where the key is present, even if its value is null. \)type: "null" matches only documents where the field explicitly holds null.
- What does the $expr operator allow in find()?It allows aggregation expressions to compare two fields within the same document. Field names inside \(expr must be prefixed with "\)".
- What does {"tags": "python"} match when tags is an array?It matches if "python" is an element of the tags array.
- What does {"tags": {"$all": ["python", "sql"]}} match?It matches documents whose array contains both "python" and "sql", in any order.
- What does {"tags": {"$size": 3}} match, and what is its limitation?It matches documents whose array has exactly length 3. It cannot take a range directly; use \(expr with \)size for ranges.
- Why is $elemMatch needed for multi-condition array queries?Without it, conditions can be satisfied by different array elements. $elemMatch requires at least one single array element to satisfy all conditions simultaneously.
- What does {"items.name": "Pen", "items.qty": {"\(gt": 10}} match without \)elemMatch?It matches if any element has name "Pen" and any (possibly different) element has qty > 10, even across separate elements.
- What does {"items": {"\(elemMatch": {"name": "Pen", "qty": {"\)gt": 10}}}} require?At least one single array element must have name "Pen" and qty > 10 simultaneously.
- What does the $slice projection operator do?Returns only a specified number of array elements: a positive number returns the first N, a negative number returns the last N.
- How do you achieve an exact category match in Elasticsearch?Use a term query on a keyword field (e.g., category_raw) so the exact unanalyzed string is compared against the exact token.
- On which ports do Elasticsearch and Kibana listen by default?Elasticsearch on port 9200 and Kibana on port 5601.
- What is a shard in Elasticsearch and why are replica shards used?Each index is partitioned into horizontal shards; replica shards provide high availability (and read scaling) alongside primary shards.
- When does a newly indexed document become searchable in Elasticsearch?After an index refresh, which is triggered automatically about every 1 second (or manually via client.indices.refresh).
- What is the difference between a match query and a term query?match analyzes the query string before searching, while term does not analyze the query and looks for an exact token match.
- What does Logstash do in the ELK Stack?It is a server-side ingestion pipeline that parses, enriches, and transforms records before they reach Elasticsearch.
- What are Beats in the ELK Stack?Lightweight edge data shippers installed on servers to forward logs and metrics into the pipeline.
- What is Elasticsearch built on and what type of engine is it?It is a distributed, RESTful JSON search and analytics engine built on Apache Lucene.
- What does the must clause in a bool query do?Clauses that must match and contribute to the relevance _score.
- What does the filter clause in a bool query do?Clauses that must match but run in filter context: _score = 0.0, cached in bitsets for fast execution. Use for exact categories, dates, and price ranges.
- How does the should clause behave when no must or filter clause is present?It acts as a logical OR. When must/filter are present, should clauses instead boost the _score of matching documents.
- What is the must_not clause used for in a bool query?Exclusion in filter context, so matching documents are excluded and contribute _score = 0.0.
- What are the three BM25 relevance scoring factors?Term Frequency (TF), Inverse Document Frequency (IDF), and Field Length Normalization.
- How does Term Frequency affect BM25 scoring?More occurrences of the query term in a document increase _score, with saturating diminishing returns.
- How does Inverse Document Frequency (IDF) affect BM25 scoring?Rare terms across the corpus receive a much higher weight than common terms.
- How does field length normalization affect BM25 scoring?A match in a short field (e.g., a 3-word name) receives a higher score than a match in a 500-word description.
- What happens to an array of objects in standard JSON mapping?It is flattened: variants: [{"color": "Red", "size": "S"}, {"color": "Blue", "size": "L"}] becomes variants.color: ["Red", "Blue"] and variants.size: ["S", "L"], losing the pairing between elements.
- What problem does flattening an array of objects cause for queries?Querying color == Red AND size == L produces a false positive match because the pairing between individual array elements is lost.
- How do you fix the array-of-objects flattening trap?Map the field with "type": "nested", which indexes each array element as a hidden separate Lucene document, and query with a nested query.
- What does setting "size": 0 do in an Elasticsearch aggregation request?It suppresses hits in the response so only aggregation results are returned, which is the standard pattern for aggregation-only queries.
- Which Elasticsearch metric aggregation gives an approximate distinct count, and what algorithm does it use?The cardinality aggregation, which uses HyperLogLog++ to approximate distinct counts.
- What is the default "size" for an Elasticsearch terms bucket aggregation, and why is it a problem?The default is 10, so only the top 10 buckets are returned and smaller categories are silently dropped unless size is increased.
- How do you set a fixed-width numeric bucketing interval in an Elasticsearch histogram aggregation?Use the histogram aggregation with the "interval" parameter.
- How do you create monthly buckets in an Elasticsearch date_histogram aggregation?Use date_histogram with "calendar_interval": "month".
- Why is storing missing prices as a sentinel value like -1.0 dangerous for sorting?Sorting ascending on price puts the -1.0 sentinel items first, so missing values appear as the cheapest items.
- How does a sentinel value like -1.0 pollute an avg aggregation, and how do you prevent it?It drags the average down; prevent it by adding a range filter such as {"range": {"price": {"gt": 0}}} before aggregating.
- What filter should you apply before sorting or aggregating a price field that may contain sentinel values?A range filter excluding non-positive values, e.g. {"range": {"price": {"gt": 0}}}.
- What is the difference between metric and bucket aggregations in Elasticsearch?Metric aggregations compute a single numeric value (e.g. avg, sum), while bucket aggregations group documents into buckets (e.g. terms, histogram, date_histogram, range).
- Which Elasticsearch aggregation groups documents by a keyword field into categories?The terms aggregation, which groups by keyword field values.
- In MySQL, what is the basic data unit and where does it live?A row (tuple) stored in a table.
- How does MongoDB represent a data unit, and where is it stored?A BSON document stored in a collection.
- What is the data unit in Elasticsearch and where is it stored?A JSON document stored in the _source field of an index.
- How does schema enforcement differ between MySQL and MongoDB?MySQL uses strict DDL (CREATE TABLE); MongoDB is flexible with optional JSON Schema validation.
- In MySQL, what is the difference between WHERE and HAVING?WHERE filters rows before grouping; HAVING filters after grouping.
- How do you filter documents in MongoDB?Use find(filter) or a $match stage in an aggregation pipeline.
- What is the difference between query.bool.must and query.bool.filter in Elasticsearch?must contributes to scoring; filter is unscored and cached for faster filtering.
- How do you group and aggregate in MySQL?Use GROUP BY col with aggregate functions like SUM(), AVG(), and COUNT(col).
- What MongoDB aggregation stage performs grouping and rollups?The \(group stage, e.g. {"\)group": {"_id": "\(col", "total": {"\)sum": "$val"}}}.
- How are bucket and metric aggregations used in Elasticsearch?Bucket aggs (e.g. terms on keyword, date_histogram) group documents, and metric sub-aggs (avg, sum) compute values within buckets.
- How do you join entities in MySQL?Use INNER, LEFT, or RIGHT JOIN ... ON ... between tables.
- What MongoDB stage performs joins between collections?The $lookup stage using from, localField, foreignField, and as.
- How does Elasticsearch handle relationships instead of joins?Through denormalized documents or nested sub-documents.
- What MySQL feature supports window analytics?The OVER (PARTITION BY ... ORDER BY ... ROWS ...) clause.
- Which MongoDB stage provides window analytics?$setWindowFields with partitionBy, sortBy, and output.
- How does Elasticsearch perform window-style analytics?Through pipeline aggregations such as moving_fn, cumulative_sum, and derivative.
- How do you capture both stdout and stderr to a file in Bash?Use &> (e.g., command &> file).
- How do Docker containers and VMs differ regarding the OS kernel?Containers share the host OS kernel (lightweight, fast startup, no cross-OS kernel execution); VMs virtualize hardware via a hypervisor with a separate guest kernel per VM.
- Why is BETWEEN '2026-02-01' AND '2026-02-28' problematic on a DATETIME column?It misses everything after 00:00:00 on Feb 28 because the upper bound is midnight.
- When counting child matches in a LEFT JOIN, why avoid COUNT(*)?COUNT(*) counts rows including unmatched parents; use COUNT(child.pk) to count only actual child matches.
- In MongoDB, does {"field": {"$exists": True}} exclude null values?No, it matches null values as well as present fields.
- How do you match false, null, and missing values in MongoDB?Use {"field": {"$ne": True}}.
- When should you use $elemMatch in MongoDB?Whenever multiple predicates must hold on the same array element.
- What mistake should you avoid when summing a parent-level total over an array in MongoDB?Never $unwind the array before summing a parent-level total.
- Which Elasticsearch mapping and query type suit full-text tokenized search?Use text mapping with match queries.
- Which Elasticsearch mapping and query type suit exact filtering, sorting, and terms aggregations?Use keyword mapping with term queries.
- How do you query arrays of objects in Elasticsearch?Use nested mappings with nested queries.
Velocer miễn phí: ôn tập ngắt quãng và thẻ của riêng bạn từ bất kỳ tài liệu nào.
PDF to flashcards · Lecture to flashcards · Practice exam · Syllabus study plan · Anki import
Thêm bộ thẻ của University of Wisconsin–Madison
- comp sci 240 midterm 1
- comp sci 240 midterm 2
- COMP SCI 240 Midterm 3
- COMP SCI 240 Final
- comp sci 300 full course review
- CS 639: Introduction to Reinforcement Learning · UW-Madison
- CS 839: Reinforcement Learning · UW-Madison
- CS 544: Intro to Big Data Systems · UW-Madison
- CS 580: Intelligent Robotics · UW-Madison
- CS 784: Foundations of Data Management · UW-Madison
- CS 880: Quantum Algorithms · UW-Madison
- CS 765: Data Visualization · UW-Madison