This question already has answers here:
Create an empty child record in Firebase
(2 answers)
Closed 4 years ago.
If I want to create keys that have no values, just to have list of certain data for each user in my case.
So it should look like something like that:
database
|
user_id6
|____data1
|____data2
In my example, each user should have a list of data, where the data is they key. Is it possible? Or I should just create a key with some arbitrary value for example:
database
|
user_id6
|____data1: true
|____data2: true
Nodes in Realtime Database can't have "no value", otherwise they would cease to exist. Assigning some boolean value, as you're showing, is one way to represent your data.
Related
This question already has answers here:
How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
(4 answers)
Closed 2 months ago.
Imagine I want to create a SQLite database of films, where the columns correspond to: title publication year, genre... How would you do it to store a list of actors in the database? Consider that:
Since the number of actors may vary from film to film, I cannot use one column per actor.
SQLite does not have a data type that corresponds to a list.
I want to use, for example "SELECT filmname FROM table WHERE X". Where X would be something that indicates if an actor is present in the film. I would like to be able to use a single or multiple actors on X
The best thing I though is to use a single string, like "actor1_actor2", and then apply "WHERE actorname LIKE %actor1". But that would allow me to filter films by only one actor.
Thanks!
You create tables movies, actors and a separate bridge table movies_actors for defining your many-to-many relationship (movie<->actor). The simplest form of the bridge table includes two columns, such as movie_id and actor_id, and two foreign keys: movies_actors.movie_id -> movies.id and movies_actors.actor_id -> actors.id.
I would suggest, create a mapping separate table for the actress with a mapping key as Film's primary table. so that you can run all type of query operations on your table structure.
This question already has answers here:
How to set unique constraint over multiple columns when any one can be null?
(3 answers)
Closed 4 months ago.
I have a unique constraint on one of my tables:
CREATE UNIQUE INDEX `role_contextid_targetid_ownerid_type_endedat_unique` on `role` (`contextId`, `targetId`, `ownerId`, `type`, `endedAt`)
You can see it is part of the db definition here:
But for some reason it is still allowing multiple entries which share all of their contextId, targetId, ownerId, type, endedAt values. Notice the last three items below:
Am I misunderstanding what a multi-column unique index is supposed to do? In not, why did SQLite allow me to add items that break these rules?
Here's what docs are saying
For the purposes of unique indices, all NULL values are considered different from all other NULL values and are thus unique.
So, it considers NULLS as different values which makes all the problem lines unique from the DB's point of view
dbfiddle
This question already has an answer here:
Teradata variable with list of values
(1 answer)
Closed 3 years ago.
We are trying to pass values from report to teradata view as parameter. How do we pass multiple values to teradata view ?
AND (v_fact_xyz in (?) or 'ALL' in (?))
is the line of code written currently
where ? can be single value('Abd, EFG(ORM)') or multiple values like these
The report is working fine with single parameter passed but throws error while passing multiple values
.net data provider for teradata 110083 error.
A Null has been specified as the value for a parameter
If I understand correctly, your question is how to pass multiple values to your IN clause, something like this:
SELECT *
FROM MyView
WHERE v_fact_xyz IN ('Abd','EFG(ORM)','AnotherValue')
If that's the case, one way to do it is using a "split" UDF (user-defined function) to convert your parameter string into a format that the IN clause supports. The IN clause can take record-sets or a single value, but not a comma-separated list.
This page may give you some ideas:
https://web.archive.org/web/20211020153409/https://www.4guysfromrolla.com/webtech/031004-1.shtml
Also check to see if Teradata offers any built-in "split" or "delimited" UDFs which you can use to do this.
This question already has answers here:
PreparedStatement IN clause alternatives?
(33 answers)
Closed 5 years ago.
Consider an SQL statement like
Select * from items where id in (123,456,789)
Can I use a prepared statement like
Select * from items where id in ?
and then supply the parameter as a set or list? Maybe I'd need parentheses around the "?".
I'm planning to use this in R, but I guess it's a general query for JDBC.
Two partial work-arounds:
Create a function that changes in (?) to in (?,?,?), depending on the length of the supplied list of values, then break that array into individual values for binding.
Pros: one query; binding is straight-forward
Cons: not feasible with large lists; have to wrap your queries in query-manglers, not fool-proof
Upload values to a temp table and change your query to
select * from items where id in (select val from temptable)
Pros: deal with arbitrary number of values; no need to trick SQL; binding is just as one would do for a multi-row insert
Cons: multiple calls; requires temp table and clean-up; might be problematic integrating with more complex queries (??)
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to make a search function for sql database , and how to get time when info from a table was edited?
How can I determine the last time when records have been inserted,
updated or deleted for a table ?
someone told me
select *
from sys.dm_db_index_usage_stats
where database_id = db_id( 'readpasttest' )
But I don't know how to use it I have a database table on asp.net site where I add informations like this:
edit-1.Name : Jax
edit-2.Age : 24
edit-3.Code : 12515
so when the users edit something lets say the name Jax it will be like this
edit-1.Name : newName - This was edited last time : the time/day !
Please help ,ty
For changes, you can add a datetime column to the table called 'LastModified' or something like that, and write the current date/time to it every time you write a record.
Alternatively, if you need to know when a record was deleted you can write a trigger that intercepts inserts/updates/deletes to the table in question, and write the timestamp value to another table, along with identifying information about the affected record.
The best way is to implement 'soft deletes' where a record is marked with some kind of status value (e.g. a 'IsDeleted' column) that can be flipped and subsequently ignored by other code in the application when reading from the table.