UNIT-1 (DBMS)
Q.1 Fill in the Blanks:
● DBMS stands for Database Management System.
● A table is the equivalent of a file system's record type.
● An entity is defined as anything about which data are to be collected and stored.
● Single-user Database supports only one user at a time.
● A Database that supports data located at a single site is centralized.
● The Same data appearing in different places is called data inconsistency.
● The authorised users of an organisation can share the data among multiple users.
● Database occupies a large space of memory and large processors to run them efficiently.
● The representation of data in the form of nodes connected via links between them, is known as
Network Model.
● It is the type of database that stores data in the form of parent-children relationship nodes, known as
Hierarchical Model.
Q.2 True or False:
● False. Data is not called metadata. Metadata is data about data.
● True. Data are distinct pieces of information.
● False. In DBMS, data files are not the record that store the data dictionary.
● True. In a DBMS, data integrity can be maintained.
● False. The Data in a Database can be shared.
● False. A DBMS can avoid data inconsistency.
● True. Using DBMS redundancy can be reduced.
● False. Security restrictions can be applied in a Database system.
● True. In distributed systems, data is distributed among different database systems of an
organization.
● True. E.F. Codd invented the relational model in 1970.
Q.3 Answer the following questions in brief:
1. Define DBMS. Explain the Advantages and Disadvantage of DBMS.
○ Definition: A DBMS (Database Management System) is a collection of programs that manages the
database structure and controls access to the data stored in the database. It acts as an intermediary
between the user and the database, hiding the database’s internal complexity.
○ Advantages of DBMS:
■ Improved data sharing.
■ Improved data security.
■ Better data integration.
■ Minimized data inconsistency.
■ Improved data access.
■ Improved decision making.
■ Increased end-user productivity.
○ Disadvantages of DBMS:
■ Increased costs for hardware, software, and personnel.
■ Management complexity due to multiple access sources and security concerns.
■ Maintaining current system through updates.
■ Vendor dependence.
■ Frequent upgrade/replacement cycles.
2. List and Describe types of Database.
○ Single-user database: Supports only one user at a time, often used on personal computers.
○ Multiuser database: Supports multiple users simultaneously.
■ Workgroup database: Supports a small number of users (less than 50) within a specific department.
■ Enterprise database: Supports many users (hundreds) across many departments within an entire
organization.
○ Centralized database: Supports data located at a single site.
○ Distributed database: Supports data distributed across several different sites.
○ Operational database: Supports a company’s day-to-day operations (transactional or production
database).
○ Data warehouse: Focuses on storing data used to generate information for tactical or strategic
decisions.
3. What is Database? Explain Database System Environment.
○ Definition: A database is a shared, integrated computer structure that stores a collection of
end-user data (raw facts) and metadata (data about data).
○ Database System Environment: It refers to an organization of components that define and
regulate the collection, storage, management, and use of data within a database environment.
■ Hardware: Physical devices like computers, storage devices, and network devices.
■ Software: Operating system software (e.g., Windows, Linux), DBMS software (e.g., SQL Server,
Oracle, MySQL), and application programs.
■ People: System administrators, database administrators, database designers, systems analysts and
programmers, and end users.
■ Procedures: Instructions and rules governing the design and use of the database system.
■ Data: Collection of facts stored in the database.
4. List the Functions of DBMS.
○ Data dictionary management.
○ Data storage management.
○ Data transformation and presentation.
○ Security management.
○ Multiuser access control.
○ Backup and recovery management.
○ Data integrity management.
○ Database access languages and application programming interfaces.
○ Database communication interfaces.
5. Difference between data Vs information.
○ Data is raw facts.
○ Information is the result of processing raw data to reveal its meaning.
6. Explain relational model of Database.
○ The Relational Model is implemented through a Relational Database Management System
(RDBMS). The RDBMS manages physical details, presenting the database as a collection of tables.
○ Advantages: Structural independence, conceptual simplicity, ad hoc query capability using SQL.
○ Disadvantages: Requires substantial hardware and system software overhead, potential for poor
use by untrained individuals, and may promote information problems.
7. Explain ER Model of Database.
○ The Entity Relationship (ER) Model is a graphical representation of entities and their relationships in
a database structure.
○ Components:
■ Entity: Anything about which data will be collected and stored, represented by a rectangle.
■ Attributes: Characteristics that describe the entity.
■ Relationships: Associations among data, such as one-to-many, many-to-many, and one-to-one.
○ Advantages: Visual modeling for conceptual simplicity, effective communication tool.
○ Disadvantages: Limited constraint and relationship representation, no data manipulation language.
8. Explain different types of Database users.
○ System administrators: Oversee the database system’s general operations.
○ Database administrators (DBAs): Manage the DBMS and ensure the database functions properly.
○ Database designers: Design the database structure.
○ Systems analysts and programmers: Design and implement application programs.
○ End users: Use application programs to run the organisation’s daily operations.
9. Explain Database Architecture.
○ The three-level architecture, also known as the three-schema architecture, is a framework used to
describe the structure of database systems.
■ External View (Highest Level): Concerned with the user perspective, hiding the complexities of the
DBMS software and hardware. There can be multiple external views, each tailored to a specific user.
■ Conceptual View (Intermediate Level): Describes entities, data types, relationships, user
operations, and constraints, hiding the details of physical storage structures.
■ Internal View (Lowest Level): Deals with the actual representation of the database, including how
data is stored on disk.
UNIT-2
Q.1 Fill in the Blanks:
1. UNION Combines all rows from two tables, excluding duplicate rows.
2. JOIN allows information to be combined from two or more tables.
3. In relational model table is known as relation.
4. INTERSECT operation results only rows that appear in both tables.
5. A table is perceived as a two-dimensional structure composed of rows and columns.
6. In relational model row is known as tuple/record.
7. In relational model column is known as attribute/field.
8. Each row/column intersection represents a single data value.
9. Key’s role is based on a concept known as superkey.
10. Superkey without unnecessary attribute is known as candidate key.
11. A primary key values must be unique and not null.
12. A secondary key is used for data retrieval purpose.
13. A candidate key is also known as alternate key.
Q.2 True or False:
1. True. A foreign key may have null values.
2. True. A foreign key is an attribute whose values match the Primary Key values in the related table.
3. True. All values in a column must conform to the same data format.
4. False. Each row/column intersection represents a single data value.
5. False. In relational model row is known as tuple/record.
6. False. For UNION operation two tables must have same number of column and same name of
column.
7. True. NULL values in table can create problems.
8. False. In relational model row is known as tuple/record.
Q.3 Answer the following questions in brief:
1. Define RDBMS.
○ An RDBMS (Relational Database Management System) is a sophisticated system that implements
the relational data model. It manages physical storage details while presenting the database as a collection
of tables to the user.
2. Define Integrity Rules with examples.
○ Integrity rules are designed to ensure high data quality by preventing inconsistencies and errors.
They define permissible values, relationships, and data operations to maintain accuracy and reliability.
■ Entity Integrity: Each row in a table must contain unique data (business key), ensuring the primary
key has no duplicates and no null values.
■ Referential Integrity: Guarantees consistent key reference constraints between tables using
primary and foreign keys. Every foreign key value in a child table must have a corresponding primary key
value in the parent table.
3. Explain the characteristics of RDBMS.
○ Data is stored in rows (tuples/records) and columns (attributes/fields) in a tabular format.
○ Each row is unique.
○ Foreign keys are used to relate tables.
○ Missing values are considered NULL.
○ Supports Normalisation to avoid data redundancy.
○ Supports distributed databases.
4. Explain different keys of RDBMS.
○ Candidate Key: An attribute or set of attributes that can uniquely identify a tuple.
○ Primary Key: An attribute or set of attributes that uniquely identifies each row in a table. It cannot
contain null values.
○ Foreign Key: Creates a link between tables by referencing the primary key in another table.
○ Surrogate Key: A synthetic primary key automatically generated by the database.
○ Secondary Key: A candidate key not selected as the primary key.
5. Explain tables and its characteristics.
○ A table is a two-dimensional structure composed of rows and columns.
○ Each row represents a single entity occurrence.
○ Each column represents an attribute with a distinct name.
○ Each row/column intersection represents a single data value.
○ All values in a column must conform to the same data format.
○ Each column has a specific range of values (attribute domain).
○ The order of rows and columns is immaterial to the DBMS.
○ Each table must have an attribute or combination of attributes that uniquely identifies each row.
6. Differentiate between DBMS and RDBMS
○ A DBMS (Database Management System) is a general-purpose database management system that
can use various models to store data, including hierarchical, network, or object-oriented models.
○ An RDBMS (Relational Database Management System) is a specific type of DBMS that is based on
the relational model. Data is organised in tables (relations) with rows and columns.
7. Explain relational set operators with example.
○ Relational set operators are used to fetch and manipulate data from relational tables.
■ Selection (σ): Selects tuples that satisfy a given predicate.
■ Example: σ BRANCH_NAME="perryride" (LOAN).
■ Projection (π): Shows a list of attributes, eliminating the rest.
■ Example: ∏ NAME, CITY (CUSTOMER).
■ Set Difference (-): Contains tuples that are in one relation but not in another.
■ Example: ∏ CUSTOMER_NAME (BORROW) - ∏ CUSTOMER_NAME (DEPOSITOR).
■ Set Intersection (∩): Contains tuples that are in both relations.
■ Example: ∏ CUSTOMER_NAME (BORROW) ∩ ∏ CUSTOMER_NAME (DEPOSITOR).
■ Cartesian Product (X): Combines each row in one table with each row in the other table.
■ Example: EMPLOYEE X DEPARTMENT.
Here's a detailed solution to the DBMS Unit 3 Assignment, incorporating information from the provided
sources:
Q.1: Fill in the Blanks
● An entity set is a set of entities of the same type that share the same properties, or attributes.
● Entity is a real-world object.
● The descriptive property possessed by each entity set is attribute.
● The attribute name could be structured as a composite attribute consisting of first name, middle
initial, and last name.
● The attribute AGE is calculated from DATE_OF_BIRTH. The attribute AGE is derived.
● Phone_number is an example of a multivalued attribute.
● Colors_Cars is an example of a multivalued attribute.
● Multivalued attributes are attributes that can have many values.
● Cardinalities express the minimum and maximum number of entity occurrences associated with
one occurrence of the related entity.
● Full form of ERM is Entity Relationship Model.
● Entity is represented in the E-R model by a rectangle symbol.
● Attribute is represented in Chen-Notation by an oval symbol.
● Relationship is represented in Chen-notation by a diamond symbol.
● Composite type of attribute can be subdivided.
● Association is maintained within a single entity is called a unary relationship.
● If tables are existence dependent then it is known as a weak entity.
● A single-valued attribute is an attribute that can have only a single value.
Q. 2: Draw E-R diagram (Take Maximum five Entities)
This question requires diagrams. Since I am unable to draw diagrams, I will list the entities and relationships
you could use in your diagrams.
1. Hospital Management:
○ Entities: Patient, Doctor, Appointment, Department, and Room.
○ Relationships: A Patient makes an Appointment with a Doctor. A Doctor works in a Department. A
Room is allocated for Appointments.
2. School Management:
○ Entities: Student, Teacher, Course, Class, and Enrolment.
○ Relationships: A Student enrolls in a Course. A Teacher teaches a Class. A Class is part of a
Course.
3. Ticket Reservation at Railway:
○ Entities: Passenger, Train, Ticket, Reservation, and Route.
○ Relationships: A Passenger makes a Reservation for a Ticket on a Train. A Train follows a Route.
4. Hotel Management:
○ Entities: Guest, Room, Reservation, Staff, and Service.
○ Relationships: A Guest makes a Reservation for a Room. A Staff provides a Service.
Q. 3: Explain in brief
1. Types of Entities:
○ Strong Entity: Exists independently of other entities. It has its own primary key.
○ Weak Entity: Its existence depends on another entity (the identifying or owner entity). It doesn't
have its own primary key; instead, it has a partial key and its primary key is derived from the parent entity.
○ Associative (Composite) Entity: Used to implement many-to-many relationships between two or
more entities. It contains primary keys of the connected entities.
2. Types of Attributes:
○ Simple Attribute: Cannot be further subdivided (e.g., age, gender).
○ Composite Attribute: Can be subdivided into additional attributes (e.g., Address into street, city,
state).
○ Single-valued Attribute: Can have only a single value (e.g., Social Security number).
○ Multi-valued Attribute: Can have multiple values (e.g., a person having multiple phone numbers).
○ Derived Attribute: Can be computed from other attributes (e.g., age derived from date of birth).
3. Degree of Relation with example:
○ The degree of a relationship indicates the number of entities involved in the relationship.
■ Unary Relationship: An association is maintained within a single entity. For example, an employee
manages other employees in the same entity.
■ Binary Relationship: Involves two entities. For example, a student enrolls in a course.
■ Ternary Relationship: Involves three entities. For example, a doctor prescribes medicine to a
patient.
4. Explain Connectivity and Cardinality with example:
○ Connectivity: Describes the relationship classification (1:1, 1:N, N:M).
○ Cardinality: Specifies the minimum and maximum number of entity occurrences associated with
one occurrence of the related entity.
○ Example: A professor teaches one or many courses (1:N). Each course is taught by only one
professor.
5. What is Functional Dependency? Explain with example:
○ Functional dependency exists when one attribute uniquely determines another attribute. If R is a
relation with attributes X and Y, a functional dependency between the attributes is represented as X->Y,
which specifies Y is functionally dependent on X.
○ Example: Stu_Id -> Stu_Name. If you know the Stu_Id, you can uniquely determine the
Stu_Name.
6. Draw Crow’s-Foot Notation for entity,primary key and relationship with example: This question
requires diagrams. Since I am unable to draw diagrams, I will list the notations.
○ Entity: Represented by a rectangle.
○ Primary Key: Underline the attribute that serves as the primary key within the entity rectangle.
○ Relationship: Represented by a line connecting entities. Cardinality is indicated by symbols at the
ends of the lines (e.g., a "crow's foot" symbol indicates "many").
Q. 4: Draw E-R diagram (Between 2 Entities)
This question requires diagrams. Since I am unable to draw diagrams, I will list the entities and relationships
you could use in your diagrams.
1. Professor teaches Classes:
○ Entities: Professor, Class
○ Relationship: A professor teaches zero, one or many classes. A class is taught by one professor
(1:N).
2. Course generates Classes:
○ Entities: Course, Class
○ Relationship: A course may generate zero, one or many classes. A class comes from one course
(1:N).
3. Class is held in Room:
○ Entities: Class, Room
○ Relationship: A class is held in one room. A room has many classes (1:N).
4. Invoice is written by Sales Rep:
○ Entities: Invoice, Sales Rep
○ Relationship: An invoice is written by one sales rep. A sales rep writes many invoices (1:N).
5. Vendor sells Products:
○ Entities: Vendor, Product
○ Relationship: A vendor sells many products. A product is bought from one vendor (1:N).
6. Invoice has Products:
○ Entities: Invoice, Product
○ Relationship: An invoice has one or many products. A product is found on zero, one or many
invoices (M:N). This would typically be resolved with a junction table.
Solving DBMS Unit-4 and Unit-5 Assignments
Here are the solutions to the questions in the Unit-4 and Unit-5 assignments, drawing information
from the provided sources.
DBMS Unit-4 Assignment
Q.1 Fill in the Blanks:
1. Normalization form which is based on No repeating values is classified as First Normal
Form (1NF).
2. Normal form which only includes indivisible values or single atomic values is classified
as First Normal Form (1NF).
3. Normalization of relations which is based on full functional dependency is classified as
Second Normal Form (2NF).
4. Normalization form which is based on partial dependency is classified as Second Normal
Form (2NF).
5. Normalization form which is based on transitive dependency is classified as Third
Normal Form (3NF).
6. If a relation is in 3NF, then it is also in 2NF and 1NF.
7. If a relation is in 2NF, then it is also in 1NF.
Q. 3 Explain in brief:
1. What is Normalization and De-normalization?
○ Normalization is the process of organising data in a database to reduce data
redundancy and improve data integrity. It involves dividing larger tables into
smaller, more manageable tables and defining relationships between them. The
goal is to eliminate undesirable characteristics like insertion, deletion, and update
anomalies. Normalization is divided into various normal forms, such as First Normal
Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF).
○ De-normalization is the process of adding redundancy back into a database design
to improve read performance. This is often done after a database has been
normalized. By combining tables or adding redundant data, the number of joins
required for certain queries can be reduced, leading to faster retrieval of information.
De-normalization is typically considered when performance becomes a critical
bottleneck in a highly normalized database.
2. Explain the need for Normalization and what are the anomalies with unnormalized
data.
○ Need for Normalization: The primary need for normalization is to avoid data
redundancy and maintain data consistency. By reducing redundancy, we
minimise the storage space required for the database. Furthermore, normalization
helps in preventing data inconsistencies that can arise when the same data is
stored in multiple places and not all copies are updated properly. It also helps to
organise data logically, making the database easier to understand and maintain.
○ Anomalies with Unnormalized Data: Unnormalized data can lead to several types
of anomalies:
■ Insertion Anomaly: It becomes difficult to insert data about a new entity
without also inserting data about another related entity. For example, in the
original HEALTH HISTORY REPORT table, we cannot add a new owner
without also adding a pet and a visit record.
■ Deletion Anomaly: Deleting a record may unintentionally delete information
about another related entity. For instance, if we delete the last visit record for
a particular pet in the original table, we might lose information about that pet
entirely.
■ Update Anomaly: Updating data may require updating multiple rows if the
same information is repeated in several places. For example, if an owner's
name changes in the original table, we would need to update all the records
associated with that owner.
3. Explain the process of Normalization.
○ The process of normalization involves a series of steps, moving through different
normal forms. The common normal forms are 1NF, 2NF, and 3NF.
○ First Normal Form (1NF): A relation is in 1NF if every attribute in every tuple is
single-valued (atomic). This means eliminating repeating groups of columns by
creating separate tables or expanding the primary key.
○ Second Normal Form (2NF): A relation is in 2NF if it is in 1NF and every non-key
attribute is fully functionally dependent on the primary key. This applies to
tables with composite primary keys. If a non-key attribute depends only on a part of
the composite key (partial dependency), the table needs to be decomposed.
○ Third Normal Form (3NF): A relation is in 3NF if it is in 2NF and no non-key
attribute is transitively dependent on the primary key. A transitive dependency
occurs when a non-key attribute depends on another non-key attribute. If such
dependencies exist, the table needs to be split into multiple tables.
○ Higher normal forms (like BCNF, 4NF, 5NF) exist and address more complex
dependencies, but 3NF is often considered sufficient for many practical database
designs.
4. Explain 1NF, 2NF, 3NF with example.
○ First Normal Form (1NF):
■ Definition: A table is in 1NF if all column values are atomic (indivisible) and
there are no repeating groups of columns.
■ Example: Consider a table with Order ID, Product Name, and
Quantity, Price. If a single order can have multiple products, the
Product Name and Quantity, Price would be repeating. To convert to
1NF, each product in an order would have its own row:
○ Second Normal Form (2NF):
■ Definition: A table is in 2NF if it is in 1NF and all non-key attributes are fully
functionally dependent on the entire primary key. 2NF is only relevant for
tables with composite primary keys.
■ Example: Consider a table with Order ID, Product ID, Order Date,
Product Name, Product Price. The primary key is (Order ID, Product
ID).
■ Order Date depends only on Order ID (partial dependency).
■ Product Name, Product Price depend only on Product ID
(partial dependency). To convert to 2NF, we split the table:
○ Third Normal Form (3NF):
■ Definition: A table is in 3NF if it is in 2NF and no non-key attribute is
transitively dependent on the primary key.
■ Example: Consider the Orders Table (from the 2NF example) and add
Customer ID and Customer City. Assume Customer ID determines
Customer City.
| Order ID | Order Date | Customer ID | Customer City | | :------- | :--------- |
:---------- | :------------ | | 101 | 2023-10-26 | C1 | London | | 102 | 2023-10-27 |
C2 | Paris |
Here, Customer ID -> Customer City (transitive dependency because
Customer City depends on a non-key attribute Customer ID). To
convert to 3NF, we split:
Q. 4 Draw the dependency diagram for 1NF for the following table
● Employee (Emp_Id, Emp_Name ,Dept_Id, Dept_Name , Address , Zipcode , City,
Phone_no)
In this table:
○ Emp_Id is likely the primary key.
○ Emp_Id functionally determines Emp_Name, Dept_Id, Address, Zipcode, City,
Phone_no.
○ Dept_Id functionally determines Dept_Name.
○ Zipcode functionally determines City (assuming a consistent database).
Dependency Diagram (Conceptual):
Emp_Id --> Emp_Name
Emp_Id --> Dept_Id --> Dept_Name
Emp_Id --> Address --> Zipcode --> City
Emp_Id --> Phone_no
●
● Student (Student_Id, Student_Name ,Course_Id, C_name , Institute_No ,
Institute_Name, Institute_Location , Grade)
In this table:
○ Student_Id is likely the primary key.
○ Student_Id functionally determines Student_Name, Course_Id,
Institute_No, Grade.
○ Course_Id functionally determines C_name.
○ Institute_No functionally determines Institute_Name,
Institute_Location.
Dependency Diagram (Conceptual):
Student_Id --> Student_Name
Student_Id --> Course_Id --> C_name
Student_Id --> Institute_No --> Institute_Name
Student_Id --> Institute_No --> Institute_Location
Student_Id --> Grade
●
DBMS Unit-5 Assignment
Q.1 Do As Directed:
1. SQL Stands for Structured Query Language.
2. SQL is used for Storing, Manipulating and Retrieving data Stored in a relational database.
(True).
3. In SQL Date stored in implementation-dependent Format. The sources mention DATE,
DATETIME, TIMESTAMP, YEAR as MySQL date and time data types, but don't specify a
single format.
4. NOT NULL tells that we cannot store a Null Value.
5. Constraint Unique specified values in column must be Unique (True).
6. Primary Key is field which can uniquely identify each row in a table and cannot contain
NULL values.
7. DEFAULT constraints is used to Specifies a default value.
Q. 2) Explain in brief:
1. What is SQL? What are the advantages of SQL?
○ What is SQL? SQL, or Structured Query Language, is the standard language for
accessing and managing records in a relational database management system
(RDBMS). It is a nonprocedural language that allows users to specify what needs to
be done without specifying how it is to be done. MySQL uses a standard form of
SQL.
○ Advantages of SQL:
■ Easy to Use: SQL is considered an easy-to-use database language.
■ Secure: SQL provides security features.
■ Compatible: It is compatible with many operating systems.
■ High Performance & High Productivity: SQL offers high performance and
productivity.
■ Platform Independent: SQL is platform-independent.
■ Data Manipulation: SQL is used for storing, manipulating, and retrieving
data.
■ Querying: It provides a powerful query language to retrieve specific data.
2. List and explain SQL Data types.
MySQL provides various data types for defining the kind of values a column can hold.
These can be broadly categorised into numeric, date and time, and string types.
○ Numeric Data Types: These include exact number types (like INTEGER, DECIMAL)
and approximate numeric types (like FLOAT, DOUBLE). MySQL also has BIT for
storing bit values. TINYINT(1) is used to represent boolean values (BOOLEAN,
BOOL are synonyms).
○ String Data Types: These are used to store text data. Examples include CHAR
(fixed-length strings), VARCHAR (variable-length strings), TEXT (for large text data),
BLOB (for binary data).
○ Date and Time Data Types: MySQL provides types for handling dates (DATE),
times (TIME), combinations of date and time (DATETIME, TIMESTAMP), and years
(YEAR).
○ JSON Data Type: MySQL also supports a native JSON data type for storing JSON
documents with automatic validation.
3. Explain below SQL constraints with example.
SQL constraints are rules applied to data columns to limit the type of data that can be
stored in a table. They ensure the accuracy and integrity of the data.
○ NOT NULL: This constraint ensures that a column cannot have a NULL value. It
forces a field to always contain a value.
■ Example: CREATE TABLE Person (ID int NOT NULL, LastName
varchar(255) NOT NULL, FirstName varchar(255));
○ UNIQUE: This constraint ensures that all values in a column are different. Multiple
UNIQUE constraints can be defined per table.
■ Example: CREATE TABLE Persons (ID int UNIQUE, LastName
varchar(255) NOT NULL, FirstName varchar(255));
○ PRIMARY KEY: This constraint uniquely identifies each record in a table. A table
can have only one primary key, and it cannot contain NULL values. It is a
combination of NOT NULL and UNIQUE.
■ Example: CREATE TABLE Persons (ID int PRIMARY KEY,
LastName varchar(255) NOT NULL, FirstName varchar(255));
○ FOREIGN KEY: This constraint is used to establish and enforce a link between two
tables. It references the PRIMARY KEY in another table, preventing actions that
would destroy links between tables. The table containing the foreign key is the child
table, and the table containing the primary key is the parent or referenced table.
■ Example: CREATE TABLE Orders (OrderID int NOT NULL,
OrderNumber int NOT NULL, PersonID int, PRIMARY KEY
(OrderID), FOREIGN KEY (PersonID) REFERENCES
Persons(ID));
○ CHECK: This constraint is used to limit the value range that can be placed in a
column. It ensures that the values in a column satisfy a specified condition.
■ Example: CREATE TABLE Persons (ID int NOT NULL, LastName
varchar(255) NOT NULL, FirstName varchar(255), Age int,
CHECK (Age>=18));
○ DEFAULT: This constraint sets a default value for a column if no value is specified
when a new record is inserted.
■ Example: CREATE TABLE Persons (ID int NOT NULL, LastName
varchar(255) NOT NULL, FirstName varchar(255), Age int,
City varchar(255) DEFAULT 'Sandnes');