mod1

    Master this deck with 21 terms through effective study methods.

    Generated from uploaded pptx

    Created by @pranjali

    What are constraints in a database?

    Constraints are rules enforced on the data columns of a table to limit the type of data that can be entered. They ensure the accuracy and reliability of the data in the database.

    Why are keys important in a relational database?

    Keys uniquely identify any record or row of data in a table and establish relationships between tables, ensuring data integrity and accessibility.

    What is a domain constraint?

    A domain constraint ensures that the data value entered for a particular column matches the data type defined for that column, maintaining data validity.

    What is an entity constraint?

    An entity constraint requires that every relation must have a primary key, which must be unique and not null, ensuring that each record can be uniquely identified.

    How does referential integrity work between two tables?

    Referential integrity ensures that if a foreign key in Table 1 refers to the primary key of Table 2, every value of the foreign key in Table 1 must either be null or match a value in Table 2.

    What is a primary key and how is it defined in SQL?

    A primary key is a unique identifier for each row in a database table. In SQL, it can be defined using the CONSTRAINT keyword, such as 'CONSTRAINT PK_Person PRIMARY KEY (ID, LastName)'.

    What is the purpose of a foreign key?

    A foreign key is used to uniquely identify a row in another table, establishing a link between the two tables and enforcing referential integrity.

    What is the difference between column level and table level constraints?

    Column level constraints apply to individual columns, while table level constraints apply to the entire table, affecting multiple columns or the table as a whole.

    What does the NOT NULL constraint do?

    The NOT NULL constraint ensures that a column cannot have a NULL value, enforcing that every record must contain a value for that column.

    What is the UNIQUE constraint in SQL?

    The UNIQUE constraint ensures that all values in a column are different, preventing duplicate entries in that column.

    How can a DEFAULT constraint be used in SQL?

    A DEFAULT constraint provides a default value for a column when no value is specified during record insertion, ensuring that the column has a valid value.

    What happens if a constraint is violated in a database?

    If a constraint is violated, the data action that caused the violation is aborted, preventing invalid data from being entered into the database.

    What is the role of integrity constraints in a relational database?

    Integrity constraints maintain the accuracy and reliability of data by enforcing rules that govern the data's validity and relationships within the database.

    What is a candidate key?

    A candidate key is a set of attributes that can uniquely identify a record in a table. An entity set can have multiple candidate keys, but only one can be designated as the primary key.

    When should you use a composite primary key?

    A composite primary key should be used when a single attribute is not sufficient to uniquely identify a record, requiring a combination of two or more attributes.

    How do you alter a table to add a primary key in SQL?

    To add a primary key to an existing table in SQL, you can use the ALTER TABLE statement, such as 'ALTER TABLE Persons ADD PRIMARY KEY (ID);'.

    What is the significance of the primary key in data integrity?

    The primary key is crucial for data integrity as it ensures that each record is unique and can be reliably referenced, preventing duplicate records and maintaining data consistency.

    What is the impact of referential integrity on database design?

    Referential integrity impacts database design by enforcing relationships between tables, ensuring that foreign keys correctly reference primary keys, which helps maintain data consistency across the database.

    How can constraints improve data reliability?

    Constraints improve data reliability by enforcing rules that prevent invalid data entry, ensuring that the data adheres to defined standards and relationships.

    What are the consequences of not using constraints in a database?

    Not using constraints can lead to data inconsistency, duplication, and integrity issues, making it difficult to maintain accurate and reliable data within the database.

    What is the process to drop a primary key in SQL?

    To drop a primary key in SQL, you can use the ALTER TABLE statement with the DROP PRIMARY KEY clause, such as 'ALTER TABLE Persons DROP PRIMARY KEY;'.