Computer Science

Integrity Constraints in SQL

Integrity constraints in SQL are rules that ensure the accuracy and consistency of data in a database. They are used to prevent invalid data from being entered into a database and to maintain the integrity of the data. Examples of integrity constraints include primary keys, foreign keys, and check constraints.

Written by Perlego with AI-assistance

10 Key excerpts on "Integrity Constraints in SQL"

  • Book cover image for: Database Systems For Advanced Applications '93 - Proceedings Of The 3rd International Symposium On Database Systems For Advanced Applications
    INTEGRITY This page is intentionally left blank OPTIMIZING D I S T R I B U T E D I N T E G R I T Y C O N S T R A I N T S Subhasish Mazumdar Mathematics, Computer Science, and Statistics, University of Texas at San Antonio, San Antonio, TX 78249, U.S.A. EMail: mazumdarQringer.cs.utsa.edu A B S T R A C T Database integrity constraints can be extremely expensive to maintain unless attention is paid to the problem dur-ing the design of the database. In the case of distributed databases, and particularly in the case of heterogeneous databases, the problems associated with constraint mainte-nance are even more acute. We lay the basis for an design-time tool that derives sufficient conditions from the original constraints as well as those derived after transaction analysis with the aim of reduction in non-locality of the constraints. I N T R O D U C T I O N Database integrity* is a guarantee of protection pro-vided by a Database Management System against misuse, more specifically, against nonmalicious errors 34 ). Integrity is specified through a set of integrity con-straints, which are assertions that each legal or consistent database state is supposed to respect, i. e., the assertions can be expressed as predicates on database states 6 ). In practice, however, the database designer finds the guarantee of integrity to be limited mainly because integrity checking generally consumes excessive computing resources. Indeed, commercial relational database systems of today support few integrity constraints — at best, one can hope for the (often indirect) support of key and referential integrity 13 Turning to the research community, we find that in explor-ing the process of design of relational databases, the choice of good relation forms has been examined in depth, but the problem of choosing a good set of integrity constraints 19 ) has been largely neglected 21 > 30 ). The neglect is even more dramatic in the case of distributed databases.
  • Book cover image for: SQL: 1999
    eBook - PDF

    SQL: 1999

    Understanding Relational Language Components

    • Jim Melton, Alan R. Simon(Authors)
    • 2001(Publication Date)
    • Morgan Kaufmann
      (Publisher)
    Constraints, Assertions, and Referential Integrity Introduction Your organization's databases are only as good as the integrity of the data con- tained within their tables and records. That is, the reliability and consistency of the data is critical to your applications, decision support and query tools, and other aspects of your information systems environment that utilize your data- base. Outright errors in the data are an obvious problem, although not the only one. Missing information, lost linkages among data elements, and other prob- lems can result in incorrect reports and can lead the database users to lose confi- dence in the overall database environment. The integrity of the data can be ensured by applying constraints, or rules, to the structure of the database and its contents. There are two primary methods by which these constraints can be specified, applied, and enforced: 9 through the applications programs and software systems that use the data- base 9 through the database management system itself Traditionally, application programs have been the medium through which such constraints have been applied. Examples include 355 356 Chapter 10 Constraints, Assertions, and Referential Integrity 9 Verifying that an input value for a particular data item is within the correct range of values (e.g., a new employee's age must be between 16 and 90, and hourly wage must be greater than the legal minimum wage rate) or is from the correct list of values (e.g., a new movie's type can only be CHILDREN, HORROR, COMEDY, OTHER). 9 Verifying that the relationship between two or more values is correct (e.g., comparing the number of copies of a particular CD that we have on hand with the number requested in an incoming order). The ever-growing use of relational database management systems intro- duced the concept of database-enforced constraints to many information systems users.
  • Book cover image for: Dynamic and Mobile GIS
    eBook - PDF

    Dynamic and Mobile GIS

    Investigating Changes in Space and Time

    • Roland Billen, Elsa Joao, David Forrest(Authors)
    • 2006(Publication Date)
    • CRC Press
      (Publisher)
    Within the context of VR systems, constraints are often implemented as the behaviour of objects. An illustration is the constraint ‘two trees (objects) cannot grow on the same location’, which is realised (hard coded in the edit environment) by collision detection, a well-known computer graphics technique. Referential integrity, topological correctness and collision detection are just a few examples of constraint types, but the available solutions may only work in certain subsystems. Other subsystems may not be aware of these and may have different ‘opinions’ of correct data. So constraints must be implemented at various levels (or subsystems), including application (edit, simulate,…) level, data exchange (communication) level and database level. Although support for integrity constraints is patchy, there has been some research in this area. Primarily, integrity constraints are related to data quality (Hunter, 1996) and the source of errors (Collins and Smith, 1994) such as during data collection, data input, data storage, data manipulation, data output and the use of results. Cockcroft (1997) was one of the first researchers presenting a taxonomy of (spatial) integrity constraints. A contribution of the current chapter is a refinement of this taxonomy. Cockcroft (2004) advocated an integrated approach to handling integrity, based on a repository that contains the model together with the constraints. Cockcoft (2004) concluded that the constraints should be part of the object class definition, similar to other aspects of the definition. The repository is used both by the database and the application as a consistent source of integrity constraints. The current chapter continues these investigations into the possibilities of managing constraints in an integrated system-wide manner and adds data communication as an additional part of the system where constraints are important.
  • Book cover image for: Convergence and Hybrid Information Technologies
    • Marius Crisan(Author)
    • 2010(Publication Date)
    • IntechOpen
      (Publisher)
    6 A Framework for Localizing Integrity Constraints Checking in Distributed Database Ali Amer Alwan, Hamidah Ibrahim and Nur Izura Udzir Department of Computer Science Faculty of Computer Science and Information Technology Universiti Putra Malaysia, 43400 Serdang, Malaysia 1. Introduction The validity, accuracy, and semantic of data are significant requirements in modern database applications. Semantic data in database is normally represented under the form of integrity constraints. Integrity constraints are properties, typically depending on the nature of the application domain, which must always be satisfied for the data to be considered consistent . Maintaining obedience of data with respect to integrity constraints is an essential requirement, since, if some data lacks integrity, then answers to queries cannot be trusted. Databases usually contain massive collections of data that rapidly evolve over time; this makes perfect checking at each update too time consuming a task to be feasible. In this regard, DBMS needs to be extended with the ability to automatically verify that database updates do not introduce any violation of integrity (Martinenghi, 2005; Christiansen & Martinenghi, 2006). The way we pursue here is the so-called simplification of integrity constraints. Simplification means to generate a set of integrity tests from the initial constraints whose satisfaction implies the satisfaction of the original constraints in the updated state. The main interest of the simplification process is to obtain a set of integrity tests (simplified forms) that are as easy to evaluate as possible. In this sense, simplification technique is feasible in terms of the cost of evaluating the constraints. Integrity constraint checking is the process of ensuring that the integrity constraints are satisfied by the database after it has been updated.
  • Book cover image for: Database Systems For Next-generation Applications: Principles And Practice
    • W Kim, Yahiko Kambayashi, I S Paik(Authors)
    • 1993(Publication Date)
    • World Scientific
      (Publisher)
    A test is therefore necessary to ensure that the update does not create an inconsistent database state. Since the checking is done as often as transactions are performed, the test must be efficient. In other words, the integrity checking problem is basically the minimization of computation effort as well as database accesses for integrity checking. One of the classical solutions to this problem is to extend the relational model to include modeling of certain common integrity constraints such as unique key constraints, referential constraints [Date86], domain constraints and nonnull constraints. Instead of developing a general algorithm to handle every possible integrity constraint, this method provides different solutions for different classes of constraints. These classes of constraints were introduced into the relational model to enrich the semantics data modeling capabilities. One of the major strengths of this method is that those common constraints have been fully studied by many authors and various efficient methods have been developed and implemented in a number of database systems. In [Beve87], the author discussed a new storage structure which can speed up the validation of referential constraints. In [Cass88], the author addressed the integrity problem concerning inclusion dependencies and referential constraints with a discussion on how his monitor system can handle some other kinds of database updates such as block deletions and cascade deletions efficiently. Another advantage of this method is that most of these constraints can be easily specified or derived in the database schema definition. For example, METUGDBMS has an automatic update integrity subsystem that is evolved from a multi-level DBMS software implementation based on the Entity-Relationship model. Constraints like A staff cannot be both a clerk and a lecturer can be easily specified using a mutually exclusive IS-A relationship.
  • Book cover image for: Database
    eBook - PDF

    Database

    Principles Programming Performance

    While the constraint makes the update refusal auto-matic, the alternative action to be performed must be supplied by the appli-cation programmer. As another example, we might have a rule to accept only valid name and address data from order entry clerks—for example, to guarantee that the zip code is correct for the state named. (Zip codes do not cross state borders—this constraint could be implemented using refer-ential integrity.) If such a check fails, however, we wouldn't want to simply refuse to accept the data. We would presumably want to call a routine that asked the clerk to re-enter the information, and if the error is repeated, accept it provisionally, possibly in a separate table. After all, data that is not totally accurate may still be of some value to an enterprise, and it might be possible for later analysis to correct the entry. In both of these examples, specifying the test for the non-procedural constraint is the sim-plest part of the job. The hard part is specifying the course to take if the test fails; clearly a procedural approach is needed for this. 6.1 Integrity Constraints Guaranteeing Transactional Consistency. Another common example of 413 an important constraint is that of consistency, one of the guarantees made to the programmer in update transactions. For example, in moving money between different account records in a commercial transaction, a consis-tency rule might be that money should be neither created nor destroyed. Application programming managers who are responsible for such update transactions would be extremely happy about a constraint capability to catch subtle consistency-breaking program bugs at runtime. However, no major commercial product provides constraints that apply to interactive effects between two or more updates at the end of a transaction.
  • Book cover image for: Oracle SQL
    eBook - PDF

    Oracle SQL

    Jumpstart with Examples

    • Gavin JT Powell, Carol McCullough-Dieter(Authors)
    • 2004(Publication Date)
    • Digital Press
      (Publisher)
    447 20 Constraints In this chapter: What is Referential Integrity? What are constraints and how are they used to implement Referential Integrity? How are constraints placed into tables? What else can constraints do? This chapter shows you how to define constraints on tables. Constraints perform validation on data both within and between tables and, to a lesser degree, with views. Primary and foreign key constraints are probably the most significant of constraints. These constraints can be used to enforce the validity (integrity) of relationships (references) between rows in tables (entities). A primary key reference is placed on a unique identifying column in a superset entity. A foreign key is placed on a subset table, which contains a copy of the primary key value from the superset entity. Oracle uses primary and foreign key con-straints to validate values between superset and subset tables. Referential Integrity can be enforced using constraints or triggers, or can be coded at the application level. My personal recommendation is to use constraints. Note: A superset contains a subset. The superset contains a primary key and the subset contains a foreign key. A foreign key can have many iterations of a primary key. So let’s move on to looking at constraints in detail. 448 20.1 What Are Constraints? 20.1 What Are Constraints? A constraint , as the word implies, constrains or applies a rule to an object or a part of an object. In Oracle Database 10 g , constraints are used to restrict values in tables or make validation checks on one or more columns in a table, or check values between columns in different tables. 20.1.1 Types and Uses of Constraints There are two levels of constraints you can place on relational tables: Inline Constraint . A constraint that applies to an individual column in a table. Out-of-Line Constraint . A constraint that applies to a table as a whole or to multiple columns in a table.
  • Book cover image for: Concepts of Database Management
    • Joy Starks, Philip Pratt, Mary Last, , Joy Starks, Philip Pratt, Mary Last(Authors)
    • 2018(Publication Date)
    This is why it is better to say that you control redundancy rather than eliminate it. 5. Facilitating consistency. Suppose an individual client ’ s address appears in more than one place. Client 175, for example, might be listed at 12 Saratoga Parkway in one place and at 12 Saratoga Pky in another place. In this case, the data for the client is inconsistent. Because the potential for this sort of problem is a direct result of redundancy and because the database approach reduces redundancy, there is less potential for this sort of inconsistency occurring with the database approach. 6. Referential integrity . Referential integrity is a relational database concept stating that table relationships must be consistent and follow integrity constraints. An integrity constraint ensures that changes made to the database do not result in a loss of data consistency. For example, the consultant number given for any client must be one that is already in the database. In other words, users cannot enter an incorrect or nonexistent consultant number for a client. A database has integrity when the data in it satisfies all established integrity constraints. A good DBMS should provide an opportunity for users to incorporate these integrity constraints when they design the database. The DBMS then should ensure that the constraints are not violated. According to the integrity constraint about clients, the DBMS should not allow you to store data about a given client when the consultant number you enter is not the number of a consultant that already is in the database. 7. Expanding security. Security is the prevention of unauthorized access to the database. A DBMS has many features that help ensure the enforcement of security measures. For example, a DBA can assign passwords to authorized users, and then only those users who enter an acceptable password can gain access to the data in the database.
  • Book cover image for: Encyclopedia of Geographic Information Science
    Thus, when considering data integrity, quality, and consistency and the rules that could be defined as constraints and enforced in a GIS, there are two classes of spatially influenced constraints over and above topological rules: semantic integrity constraints and user-defined integrity constraints. These are illustrated in Figure 1. Integrity Constraints ——— 231 Semantic Integrity Constraints Semantic integrity constraints differ from topological integrity constraints in that they are concerned with the meaning of geographical features. An often-quoted (and encountered) data quality problem is that of road centerlines not connecting at intersections. The concern is the topological consistency of the line object road centerline, which is a geometric condition and has implications for analysis. This could be addressed using topological rules, regardless of the semantic information that this is a road. Semantic integrity constraints apply to database states that are valid by virtue of stored properties of objects. In this category, an example would be a rule that states that a user must not create a road crossing any body of water, which is defined by a class of “water” objects, including rivers, lakes, and streams. If the user attempts to create, for example, a road running through a lake, a semantic rule would be activated stating that this is a body of water and a road would not normally run through it. User-Defined Integrity Constraints User-defined integrity constraints allow database con-sistency to be maintained according to user-defined constraints, analogous to business rules in nonspatial database management systems. For example, for external or legal reasons, it may desirable to locate a nuclear power station greater than a given distance from residential areas. When attempting to create a database entry where this condition is not met, a user rule would be activated to prevent the entry.
  • Book cover image for: Database Systems
    eBook - PDF
    The process of developing such definitions which form the key elements of the schema of a database is considered in detail in Chapters 16 and 17. A brief extension for the academic database might be: Extension : University Modules : Relational Database Systems Relational Database Design Students : John Davies was born on 1 July 1985 Peter Jones was born on 1 January 1985 Susan Smith was born on 1 April 1986 Takes : John Davies takes Relational Database Systems Here we have provided specific instances of classes such as relational database systems , of relationships such as John Davies takes relational database systems and of attributes such as John Davies was born on 1 July 1985 . In fact, we have also implicitly defined some instances of attributes for the class modules. We have provided a list of two so-called identifiers for the instances of the class modules, in this case relational database systems and relational database design . Identifiers are special attributes which serve to uniquely identify instances of classes. ➠ 1.3 I N T E G R I T Y When we say that a database displays integrity we mean that it is an accurate reflection of its UoD. The process of ensuring integrity is a major feature of modern information systems. The process of designing for integrity is a much neglected aspect of database development. Integrity is an important issue because most databases are designed, once in use, to change. In other words, the data in a database will change over a period of time. If a database does not change, i.e. it is only used for reference purposes, then integrity is not an issue of concern. It is useful to think of database change as occurring in discrete rather than continuous time. In this sense, we may conceive of a database as undergoing a number of state-changes, caused by external and internal events. Of the set of possible future states feasible for a database some of these states are valid and some are invalid.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.