MTA Exam 1

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What are the default ports to secure a SQL server?

  • 41 and 42
  • 80 and 82
  • 1433 and 1434 (correct)
  • 8080 and 8090

Which two methods can be used to grant temporary permissions to users when you cannot create new groups?

  • Add the users to an existing role that has appropriate access (correct)
  • Grant each user explicit permissions to the role (correct)
  • Create a view with shared permissions
  • Remove existing role permissions temporarily

What action can a user perform on data that is on the server if granted unlimited access?

  • No
  • Read-only
  • Delete only
  • Unlimited (correct)

To allow a user to read data in a table, which command should be used?

<p>Grant select (D)</p> Signup and view all the answers

What does the term 'truncate' refer to in a database context?

<p>Removing data (D)</p> Signup and view all the answers

What is the purpose of using a unique index in a database?

<p>It ensures that the index key contains no duplicate values. (C)</p> Signup and view all the answers

In a relational database, what is the requirement for a foreign key in a table?

<p>Must refer to a primary key of another table (B)</p> Signup and view all the answers

Which command is used to remove a table from a database?

<p>Drop table (C)</p> Signup and view all the answers

What should be applied to the Employee table to ensure an employee can only be assigned to an existing department?

<p>A foreign key (D)</p> Signup and view all the answers

What type of data should be recommended for storing financial amounts in a database?

<p>Money (B)</p> Signup and view all the answers

Which command is used to create a query returning a set of table data by using the UPDAT statement?

<p>No change is needed (C)</p> Signup and view all the answers

What type of constraint ensures that data entered into a column is valid?

<p>Constraint (D)</p> Signup and view all the answers

Which command would you use to add a column to an existing table?

<p>Alter (D)</p> Signup and view all the answers

Which SQL statement is used to retrieve rows from a table?

<p>Select (C)</p> Signup and view all the answers

How is a non-clustered index defined on a table?

<p>Using a clustered index or view (C)</p> Signup and view all the answers

What is one limitation of a delete statement in SQL?

<p>It cannot specify a where clause. (C)</p> Signup and view all the answers

What is the recommended method to store volunteer data with given name, surname, telephone number, and email address?

<p>Create a table that contains columns for given name, surname, phone number, and email. (B)</p> Signup and view all the answers

Which database object should you add to the Sales table to ensure valid associated salesperson records?

<p>Foreign key (A)</p> Signup and view all the answers

Which DDL keyword is used to delete a database table?

<p>Drop (B)</p> Signup and view all the answers

Which statement is true regarding the ALTER statement?

<p>It is used to modify an existing table. (B)</p> Signup and view all the answers

First normal form requires a database to exclude which of the following?

<p>Repeating groups (C)</p> Signup and view all the answers

Which statement about clustered and non-clustered indexes is true?

<p>A clustered index stores all table data in order based on the index key. (B)</p> Signup and view all the answers

What is the purpose of a foreign key in a database?

<p>To ensure data integrity and establish relationships between tables. (C)</p> Signup and view all the answers

What is the relationship of StateID in the state table?

<p>It is a primary key in the state table. (A)</p> Signup and view all the answers

Which statement about SQL Server logins is incorrect?

<p>A SQL Server login is granted permission to database view only. (D)</p> Signup and view all the answers

What is the purpose of the SELECT statement in SQL?

<p>To retrieve rows from one or many tables. (A)</p> Signup and view all the answers

Which SQL clause is used to specify criteria for selecting records?

<p>WHERE (D)</p> Signup and view all the answers

Which constraint ensures that each value in the ID column is unique?

<p>Primary Key (B)</p> Signup and view all the answers

If you want to retrieve rows from a table, which DML command should you use?

<p>SELECT (B)</p> Signup and view all the answers

What data type is recommended for storing financial transactions?

<p>Money (D)</p> Signup and view all the answers

To improve query performance on a column, which item should you consider adding?

<p>Index (C)</p> Signup and view all the answers

What type of constraint would you use to establish a relationship between two tables?

<p>Foreign Key (C)</p> Signup and view all the answers

Which data type should be used to store project names that range from three to 30 characters while minimizing storage space?

<p>Varchar (30) (C), Varchar (3,30) (D)</p> Signup and view all the answers

What is required to define a column in a SQL table?

<p>Data type and name (B)</p> Signup and view all the answers

What should you specify for a column that cannot contain duplicate values in a SQL table?

<p>UNIQUE (A)</p> Signup and view all the answers

What SQL keywords are valid to use in a CREATE TABLE statement?

<p>Primary Key and Foreign Key (C)</p> Signup and view all the answers

Which SQL statement correctly creates a view that returns a list of games sorted alphabetically?

<p>Select Name from Games order by Name (B)</p> Signup and view all the answers

When creating an integer-type column that must be assigned a value between 1 and 10, what should you include?

<p>A CHECK constraint (B)</p> Signup and view all the answers

Using a relational database minimizes redundant data and allows data retrieval:

<p>Quickly and easily (D)</p> Signup and view all the answers

If you want to ensure a column in a SQL table cannot be empty, what constraint should you specify?

<p>NOT NULL (D)</p> Signup and view all the answers

What is the characteristic of a non-clustered index?

<p>Does not affect the physical order of data storage. (C)</p> Signup and view all the answers

Which statement correctly describes a unique index?

<p>Ensures each row has a unique index key. (D)</p> Signup and view all the answers

Which of the following statements about clustered indexes is true?

<p>They sort and store data based on the indexed columns. (C)</p> Signup and view all the answers

Which SQL statement correctly updates a table named loanedBooks?

<p>Update loanedBooks set Books = 1 Where (Name = 'Harry' AND City = 'San Francisco') (B)</p> Signup and view all the answers

What is the appropriate SQL statement to create a table named Student with specified attributes?

<p>Create Table Student (ID INT, Name Varchar(100), Age Int) (D)</p> Signup and view all the answers

What is true about filtered indexes?

<p>They help optimize queries that select a small percentage of rows. (D)</p> Signup and view all the answers

Which SQL statement can be used to create an index on a column?

<p>Create Index Employee_Index on Employee(EmployeeID) (A)</p> Signup and view all the answers

Which statement describes the relationship between clustered and non-clustered indexes?

<p>Non-clustered indexes do not affect the order of records. (A)</p> Signup and view all the answers

Flashcards

What are the default ports to secure a SQL server?

Secure the SQL server using ports 1433 and 1434. These ports are commonly used to connect to the SQL Server engine.

How to grant a collection of users permissions to tables temporarily, without creating new groups?

Two ways to grant user permissions: 1. Adding users to an existing role: Assign users to a role already having the required permissions. 2. Granting individual permissions: Provide specific access rights to each user directly.

What is a foreign key in a relational database?

A foreign key is a field in a table that references the primary key of another table. It ensures data integrity by enforcing relationships between tables.

How to ensure an employee can be assigned to only an existing department?

Use a foreign key constraint to ensure that an employee can only be assigned to an existing department. This ensures the integrity of data in the Employee table.

Signup and view all the flashcards

What is the TRUNCATE command used for?

The 'TRUNCATE' command removes all data from a table, but keeps the table structure intact. It's faster than deleting data row by row.

Signup and view all the flashcards

How to grant read permission to a table?

The ALLOW SELECT command grants permission to read data from a table. This is needed for users who only need to view data.

Signup and view all the flashcards

Which command is used to retrieve data from a table?

The SELECT statement is used to retrieve data from a table. It's used for querying and displaying information.

Signup and view all the flashcards

How to modify existing data in a table?

The UPDATE statement is used to modify existing data in a table. This is used to change or update specific records.

Signup and view all the flashcards

What is a unique index?

A unique index ensures that the index key contains no duplicate value and that every row in the table or view is unique.

Signup and view all the flashcards

What is a non-clustered index?

A non-clustered index is defined on a table or view by using a clustered index or heap.

Signup and view all the flashcards

How to improve query performance?

To improve query performance, an index on the 'Salary' column would be beneficial.

Signup and view all the flashcards

How to remove a table from a database?

The 'DROP TABLE' command removes a table and all its associated data from the database.

Signup and view all the flashcards

What is a constraint in a relational database?

A constraint in a relational database management system ensures that data entered into a field in a column is valid.

Signup and view all the flashcards

What is the best data type for financial transactions?

The 'MONEY' data type is recommended for storing and performing financial calculations.

Signup and view all the flashcards

How to add a column to an existing table?

The 'ALTER TABLE' command adds a new column to an existing table.

Signup and view all the flashcards

What is a row in a table?

A row holds information for a single record in a table. It's like a single line in a spreadsheet.

Signup and view all the flashcards

Foreign Key (FK)

A database object that ensures that each record in a dependent table (e.g., Sales) has a valid corresponding record in a related table (e.g., SalesPerson). It acts like a link between two tables, enforcing the data integrity by ensuring that the referenced data exists.

Signup and view all the flashcards

Primary Key (PK)

A database object that is added to a table to create a unique identifier for each record, preventing redundant entries and ensuring data integrity. It determines the order in which the rows of a table are physically stored.

Signup and view all the flashcards

DROP

A Data Definition Language (DDL) keyword used to remove an existing table from a database, effectively deleting all associated data.

Signup and view all the flashcards

Non-clustered Index

A database object that helps in organizing the data retrieval process. It stores only a sorted index of the data, not the whole data itself, providing a faster way to locate specific data.

Signup and view all the flashcards

Clustered Index

A database object that stores data in a sorted order based on the index key. It is used to improve data retrieval efficiency.

Signup and view all the flashcards

First Normal Form (1NF)

The first stage of database normalization, where a table is designed to eliminate repeating groups of data. Each row represents a unique entity, and there are no duplicate rows.

Signup and view all the flashcards

Foreign Key

A database object that defines a relationship between two tables, allowing data from one table to be referenced in another. This enforces data integrity by ensuring that the referenced data exists.

Signup and view all the flashcards

Primary Key

A database object that acts as a unique identifier for each record within a table. It is used to prevent data redundancy and ensure data integrity.

Signup and view all the flashcards

Is a SQL Server Login using Windows Authentication possible?

A SQL Server login can use Windows Authentication to verify the identity of a user. This allows for seamless integration with Active Directory.

Signup and view all the flashcards

What does a SQL Server Role provide permissions for?

Roles in SQL Server manage object-level permissions, granting access to specific functions or actions within a database.

Signup and view all the flashcards

Which SQL clause defines filtering conditions?

The WHERE clause is used to specify conditions for data retrieval, filtering the results based on certain criteria.

Signup and view all the flashcards

What constraint ensures uniqueness within a table?

The PRIMARY KEY constraint ensures each record in a table has a unique identifier, preventing duplicates and maintaining data integrity.

Signup and view all the flashcards

Which DML command retrieves data?

When working with data in a table, the SELECT statement is used to retrieve information or rows.

Signup and view all the flashcards

Which data type is best for monetary values?

The MONEY data type is specifically designed to accurately store and perform calculations on monetary values, ensuring precise financial operations.

Signup and view all the flashcards

What can be added to a column to enhance query performance?

Adding an index to the salary column can significantly improve query performance by creating a faster way to find specific salary values.

Signup and view all the flashcards

What constraint links tables together?

A FOREIGN KEY constraint establishes a relationship between two tables, linking a column in one table to the primary key of another table.

Signup and view all the flashcards

What is a clustered index?

A clustered index orders and stores the data columns of a table or view based on the clustered index key.

Signup and view all the flashcards

How do you update data in a table?

An update statement modifies existing data in a table. It specifically targets rows that meet a given condition.

Signup and view all the flashcards

How do you create a new table?

The CREATE TABLE statement is used to define a new table structure in a database. This includes specifying column names, data types, and potential constraints.

Signup and view all the flashcards

How do you create an index?

The CREATE INDEX statement is used to create an index on a table. An index helps to speed up data retrieval by providing a quick lookup path.

Signup and view all the flashcards

VARCHAR

A data type that stores variable-length text strings, optimizing storage by using only the space needed for the actual text.

Signup and view all the flashcards

CHAR

A data type that stores fixed-length text strings, allocating a predetermined amount of space regardless of the actual text length.

Signup and view all the flashcards

View

A database object that presents a specific view of the underlying data in a table, without storing data itself.

Signup and view all the flashcards

UNIQUE Constraint

Ensures data integrity by preventing duplicate values within a column. It helps maintain unique records within a table.

Signup and view all the flashcards

DEFAULT Constraint

Allows for the specification of a default value automatically assigned to a column when no value is explicitly provided during data insertion.

Signup and view all the flashcards

CHECK Constraint

A rule that restricts the values allowed in a column, ensuring data validity and consistency within a table.

Signup and view all the flashcards

Relational Database

A relational database design principle that minimizes redundancy and promotes data integrity by storing data in separate tables with relationships defined between them.

Signup and view all the flashcards

Study Notes

MTA Exam Questions Review

  • SQL Server Default Ports: The default ports for securing a SQL server are 1433 and 1434.

  • Temporary User Permissions (2 methods): Two ways to grant temporary permissions to users on multiple tables without creating new groups are granting explicit permissions to the role, and adding users to an existing role with appropriate access.

  • User Actions on Server Data: Users can perform actions on database objects on the server. The extent of these actions can vary.

  • Granting Read Access: The ALLOW SELECT command grants select permission to read data in a table. If it makes the statement correct to read data, state No change is needed. If the statement is incorrect, correct the statement by saying Grant select. Or Permit read.

  • Database Operations (Truncate): Truncate is a database operation used to clear/correct data if a database is damaged or corrupt. (NOT for backups). Other terms that could pertain, and should be used if appropriate, are Attach and Commit (or Restoring).

  • Foreign Key Constraints: In relational databases, foreign keys in a table must be unique in that table and cannot refer to the primary key of another table. Foreign keys cannot contain null values.

  • Employee Table Assignment: To ensure that employees can only be assigned to existing departments, a foreign key should be added to the Employee table linking the Employee table with department table.

  • SQL Query for Table Data: The statement UPDATE is not used to retrieve data, but SELECT is.

Database Table Structure and Data Types

  • SQL Database Table Keywords: To delete a table use DROP.

  • Data Types and Normal Form: First normal form requires elimination of repeating groups and duplicate rows in table data.

  • SQL Database Table Relationships: A primary key is a constraint ensuring each row in the Table is unique and is related to other tables. A foreign key in one table can point to a primary key in another table.

Database Objects and Constraints

  • Removing Tables: The command to remove a table is DROP TABLE.

  • Data Integrity: Using Constraints, especially Foreign Keys, keeps the reference data consistent across related tables, preventing orphaned rows and inconsistencies.

  • Data Types: Use INT for numerical data in a table column. Use VARCHAR for string data, but specify the maximum length.

  • Indexes: Indexes improve query performance by speeding up data retrieval. A clustered index sorts data physically on disk. A non-clustered index doesn't. Indexes are often added to commonly queried fields.

Data Validation and Relationships

  • Data Types For Financial Transactions: Recommendations for financial transactions in a database table are MONEY and DECIMAL to support precise calculations and avoid rounding errors.

  • Unique Values & Data Integrity (Constraints): A primary key ensures a unique value for each row in a table, guaranteeing distinct identification for all records.

  • Relationships and Data Consistency: Use foreign keys to ensure data consistency by enforcing connections between related tables, preventing invalid or orphaned data.

  • Adding Columns: The correct command to add a column to an existing table is ALTER TABLE.

  • Data Consistency: A database with constraints guarantees a consistent set of data in related tables, improving data integrity.

Query and Data Manipulation

  • Query Performance Optimization: Use indexes on columns frequently searched.

  • Data Modification Statements:

    • UPDATE for changing data in a table
    • DELETE to eliminate rows.
    • INSERT to add new rows.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

MTA Database Reviewer PDF

More Like This

MTA Training Test 1 Flashcards
72 questions
MTA Conductor Study Guide
23 questions

MTA Conductor Study Guide

WellReceivedSquirrel7948 avatar
WellReceivedSquirrel7948
M131 MTA Revision Questions Part 1
20 questions
Use Quizgecko on...
Browser
Browser