Suppose i have a table with 3 fields
Person_id, Name and address. Now the problem is that a person can have multiple addresses. and the principle of atomic values says that data should be atomic.
So then how am i suppose to store multiple addresses for a single person ?
In most database systems you can store only a single value in a field. But in Access, you can also create a field that holds multiple values (up to 100). For example, you want to track employees working on issues.
Thus, we can use INSERT-SELECT-UNION query to insert data into multiple rows of the table. The SQL UNION query helps to select all the data that has been enclosed by the SELECT query through the INSERT statement.
In SQL, for matching multiple values in the same column, we need to use some special words in our query. Below, 3 methods are demonstrated to achieve this using the IN, LIKE and comparison operator(>=). For this article, we will be using the Microsoft SQL Server as our database.
The IN operator allows you to specify multiple values in a WHERE clause.
You're supposed to create an ADDRESS
table that has a foreign key linking it to a PERSON
record, i.e. PERSON_ID
. This is the "relational" component of a relational database, and it's why it's more flexible than a flat file (which is like a single table).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With