DBM QUIZ

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/46

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:09 AM on 9/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

47 Terms

1
New cards

Structured Query Language (SQL)

It is an industry-standard programming language used to insert, retrieve, modify, and delete data in a relational database. It also contains statements for defining and administering the objects in a database.

2
New cards

What SQL enables a programmer/DBA to do

Execute queries against a database; retrieve data from a database; insert records in a database; update records in a database; delete records from a database; create new databases; create new tables in a database; create stored procedures in a database; create views in a database; set permissions on tables, procedures, and views.

3
New cards

A Brief History of SQL

1970 – E. Codd develops relational database concept; 1974-1979 – System R with Sequel (later SQL) created at IBM Research Lab; 1979 – Oracle markets first relational DB with SQL; 1986 – ANSI SQL standard released; 1989, 1992, 1999, 2003 – Major ANSI standard updates; Current – SQL is supported by most major database vendors.

4
New cards

Relational Database

A database divided into logical units called tables, where tables are related to one another within the database. Relational database allows data to be broken down into logical, smaller, and manageable units for easier maintenance and better performance.

5
New cards

Tables

Collections of rows and columns. Tables are related to one another through common keys or fields in a relational database system, that's why even though the desired data may exist in more than one table, you can easily join multiple tables together to get combined data set using a single query.

6
New cards

Field or column

A single characteristic, attribute or property that provides information about an object.

7
New cards

Record or row

A complete set of all the fields/attributes combined together for a particular object.

8
New cards

Data Definition Language (DDL)

Commands used to define a database, including those for creating, altering, and dropping tables and establishing constraints. Sample commands are CREATE, ALTER and DROP.

9
New cards

Data Manipulation Language (DML)

Commands used for updating, inserting, modifying, and querying the data in the database. Sample commands are INSERT, UPDATE, DELETE and SELECT.

10
New cards

Data Control Language (DCL)

Commands help a DBA control the database; they include commands to grant or revoke privileges to access the database or particular objects within the database and to store or remove transactions that would affect the database.

11
New cards

Creating a Database

Before doing anything with the data we must need to create a database first. The basic syntax is CREATE DATABASE databasename.

12
New cards

Renaming a Database

To rename a database in SQL server, use the command sp_renamedb.

13
New cards

Deleting a Database

To delete an existing database in SQL server, use the command DROP DATABASE. Deleting a database will result in loss of complete information stored in the database.

14
New cards

Tables (as database objects)

Database objects that store data in a collection of rows and columns. Each row represents a unique record, and each column represents a field within the record.

15
New cards

Naming Tables and Columns

Table names can be up to 128 characters, must begin with an alphabetic character, and can also contain underscores (_), "at" symbols (@), pound signs (#), and numerals. Each table can have up to 1,024 columns. Spaces and other symbols may be used if delimited by double quotation marks or brackets [ ], though this is not recommended.

16
New cards

Data Types

An attribute that specifies the type of data that the column can store. The data type of an attribute decides the operations that can be performed on the data of that attribute (e.g., arithmetic operations can be performed on numeric data but not on character data).

17
New cards

Null

A value that may be assigned to an attribute when no other value applies or when the applicable value is unknown. A null value, or NULL, is not the same as zero (0), blank, or a zero-length or empty character string. NULL means that no entry has been made.

18
New cards

Primary Key

A field or a combination of fields that identify a record uniquely. The Primary key is a column or set of columns that are unique. Every table should have a primary key.

19
New cards

Rules for Primary Key

Each table can have only one Primary Key; all the values are unique and can uniquely identify each row; the system will not allow inserting a row with a primary key which already exists; Primary Key cannot be NULL.

20
New cards

Foreign Key

Provides a way of enforcing referential integrity within SQL Server. Foreign key ensures values in one table must be present in another table.

21
New cards

Rules for Foreign Key

NULL is allowed in Foreign key; the table being referenced is called the Parent Table; the table with the foreign key is called Child Table or dependent table; the foreign key in child table references the primary key in the parent table; this parent-child relationship enforces the rule known as "Referential Integrity."

22
New cards

Identity Column

Used to create a column that contains system-generated sequential values to identify each row inserted into a table. The (seed, increment) values will default to (1,1) if not specified.

23
New cards

Identity Seed

Provides the starting value for an Identity column.

24
New cards

Identity Increment

Defines how an Identity will increase or decrease with each new row added to a table.

25
New cards

Modifying Table

Syntax: ALTER TABLE table_name {[ALTER COLUMN column_name datatype] | ADD {[column definition]} | DROP {[CONSTRAINT] constraint_name | COLUMN column}}.

26
New cards

Alter a Table To Add A New Column

Syntax: ALTER TABLE table_name ADD column_1 datatype [NULL | NOT NULL].

27
New cards

Alter a Table To Drop a Column

Syntax: ALTER TABLE table_name DROP COLUMN column_name.

28
New cards

Alter a Table to Change The Data Type Of A Column

Syntax: ALTER TABLE table_name ALTER COLUMN column_name datatype.

29
New cards

Alter a Table Assign A Constraint In An Existing Column

Syntax: ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint_type(column_name).

30
New cards

Renaming Table Name

Use the SQL command sp_rename followed by old table name, then the new table name. Syntax: sp_rename 'old_table_name', 'new_table_name'.

31
New cards

Renaming Column Name of a Table

Use the SQL command sp_rename followed by old column name, then the new column name, and the last parameter is the keyword "column". Syntax: sp_rename 'table_name.old_column_name', 'new_column_name', 'column'.

32
New cards

Dropping a Table

Use the DROP command to drop or delete a table. Syntax: DROP TABLE table_name.

33
New cards

Data Integrity

Refers to the overall accuracy, consistency, and completeness of data. Data integrity is usually imposed during the database design phase through the use of standard procedures and rules, and can be maintained through various error-checking methods and validation procedures.

34
New cards

Categories of Data Integrity

Domain Integrity; Entity Integrity; Referential Integrity.

35
New cards

Domain Integrity

Also known as column integrity, this integrity specifies a set of data values that are valid for a column. Defined by data type, format, data length, nullability, default value and range of allowable values.

36
New cards

Entity Integrity

Also known as row integrity, this integrity requires that all the rows in a table have a unique identifier, enforced by either a PRIMARY KEY or UNIQUE constraint. Every table must have its own primary key and each has to be unique and not null.

37
New cards

Referential Integrity

The concept of foreign keys. A state in which all foreign key values in database are valid. For a foreign key to be valid, it must contain either the value NULL, or an existing key value from the PRIMARY KEY value or UNIQUE KEY columns referenced by the foreign key. The referenced row cannot be deleted if a FOREIGN KEY refers to a row, nor can the key value be changed if a FOREIGN KEY refers to it.

38
New cards

Constraints

Business logic that your database server enforces for you. Used to specify rules for the data in a table and limit the type of data that can go into a table. This ensures the accuracy and reliability of the data. Constraints prevent the deletion of a table if there are dependencies; if there is any violation, the action is aborted.

39
New cards

Constraints Guidelines

The constraint can be created within the CREATE TABLE T-SQL command while creating the table, or added using ALTER TABLE T-SQL command after creating the table. Constraints can be defined at the column level (applied to that column only) or declared independently at the table level (applied to more than one column).

40
New cards

Types of Constraints

Primary Key Constraints; Foreign Key Constraints; Check Constraints; Default Constraints; Unique Constraints.

41
New cards

Primary Key Constraints

Ensures no duplicate values are entered in particular columns and that NULL values are not entered in those columns. If an attempt is made to insert a row of data with duplicate value or NULL value for the primary key, an error message will result and the insert is not allowed.

42
New cards

Foreign Key Constraints

Governs the link between the parent or referenced table and the child or referencing table. Enforces referential integrity between tables. The number and data type of the column in the parent table key must match with the number and data type of the column in the child table.

43
New cards

Unique Constraints

Ensures no duplicate values are entered into specified columns that are not a table's primary key. It enforces uniqueness in a column or combination of columns. You can attach multiple unique constraints to a table, but only one primary key constraint.

44
New cards

Default Constraints

Enables you to define the value that will be supplied for a column whenever a user fails to enter a value.

45
New cards

Check Constraints

Used to enforce domain integrity by restricting the values allowed in a column to specific values. Contains a Boolean expression that causes the database to evaluate whether the value of an inserted or updated record matches the criteria. If the value is not within the allowed set, SQL server will raise an error.

46
New cards

Viewing a Table Constraints

To list available constraints on a table, use the command sp_helpconstraint. Syntax: sp_helpconstraint 'table_name'. The table_name specified must be local to the current database.

47
New cards

Dropping a Constraint

To drop or delete a constraint, alter the table and use the command DROP CONSTRAINT. Syntax: ALTER TABLE table_name DROP CONSTRAINT constraint_name. Note: A constraint cannot be modified or altered — drop the constraint first, then recreate it.