Naming of boolean column in database table [closed] - sql-server

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
The community reviewed whether to reopen this question 3 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have 'Service' table and the following column description as below
Is User Verification Required for service ?
Is User's Email Activation Required for the service ?
Is User's Mobile Activation required for the service ?
I Hesitate in naming these columns as below
IsVerificationRequired
IsEmailActivationRequired
IsMobileActivationRequired
or
RequireVerification
RequireEmailActivation
RequireMobileActivation
I can't determined which way is the best .So, Is one of the above suggested name is the best or is there other better ones ?

I would (and do) use "IsVerificationRequired"
I try to add some meaning to my column names so it's obvious (ValueDate, InsertedDateTime, IsActive, HazCheezBurger, ProductName etc). "Isxxxx" implies yes/no for example without thinking and you only have 2 states unlike "ProductName".

Run with the Is variants, or at the very least swap the Require to Requires. Booleans should be phrased as questions. Is, Can, Has, Should, they're all good prefixes for Boolean functions/columns. See 1370840 for more arguments on this

I would choose VerificationRequired, EmailActivationRequired etc.
Database is the snapshot of the state, so the above said column names goes better over the ones you have mentioned in my opinion.

I would go for the one that fits more the syntax you are using in your current project. Either one is fine since they describe what the variable contains, the only thing you need to worry about is that you keep the same naming standard for all your project. If you haven't decide any naming standard for your project yet, the first one would be better since it is what is closer of the Java Bean naming standard which is something that a lot of developer are used to.

Neither. Name the column such that it makes sense if "is" were to be prepended, but don't prepend it:
VerificationRequired
EmailActivationRequired
MobileActivationRequired
The datatype being boolean implies the "is" - you don't need to load it into the variable/field name. Just as you shouldn't name timestamp columns with "timestamp", eg define the column as expiry timestamp not expiry_timestamp timestamp.
Adding is to the name is a form of Hungarian notation, which has long been accepted as an anti-pattern.
In java, the convention is to name of the accessor method of a field (especially on a DTO) as isX rather than the usual getX because it reads more naturally, eg:
public boolean isVerificationRequired { return verificationRequired; }`
reads more naturally than:
public boolean getVerificationRequired { return verificationRequired; }`
Or name the accessor hasX if it reads more naturally.
Whether you name the accessor isX or hasX, a boolean field (in your case a database column) should not have is or has in its name.

Related

How can I combine nominal data on SPSS?

I am doing my dissertation about brand recall. I created on spss a variable with the brands that the respondents recalled first (eg: 1 = "Facebook", 2="Instagram" and so on). I also created a variable with the brands that the respondents recalled in second place (1= "Facebook" and so on). I want to combine those two variables into one, in order to have only one variable called "brand recall". However, I don't know how to do it. Basically, when I sent the questionnaire to the respondents they mentioned more than one brand in their answers. I don't know how to combine all those answers into one in spss.
You can't do this because you will alter the data. From what I read you have a ranking question or a multiple answear question.
The first variables is for the FIRST brand recalled
The second variables if for the SECOND brand recalled.
Imagine that you want the answer gave in second variable aka second brand to be moved in the first variable. How will you make difference what was the first brand recalled and second brand recalled.
Another thing. If a respondent selected Facebook as first brand(in the first variable) in the second option Facebook was showed/you have the possibility to select it again? If that's the case this is not ok. Imagine that I can select Facebook in first brand recalled and also in the second one.
Give more details and maybe I can help you
Well if it's an open-ended question you can do a basic coding of that OE question and it goes like this:
1.run a basic frequency of the open-end question. example: fre [Open-end question].
2.after you see what answers you have like Facebook, Twitter etc. will have an overview of what brands were mentioned.
Create a numeric variable named brands. example: numeric brands (f2.0) assuming that you have more than 10 individual brands mentioned in the open-end. In case you have more than 100 brands mentioned write (f3.0).
Add value labels for the newly created brands variable. example:
value labels brands
1"Facebook"
2"Instagram"
3"Twitter"
4"[Any other brands mentioned".(very important to have . at the last value label code added)
after you created the variable and added all the brands as value labels/answear options the recode part start:
if [Open-end question]="the exact wording" brands=[select what answear option].
exe.
Example:
if [open-end question]="IG" brands=2. Respondent referred to Instagram.
if [open-end question]="Faaacebook" brands=1. Respondent referred to Facebook.
.
.
.
exe. (do not forget to add at the end .exe in order to run the syntax code)
After you populated the brand variable run a simple frequency to see how many mentions you have.
Hope this answers helps.

Dapper.plus get tablename and key column name from DapperPlusManager

I'm using Dapper.Plus with DapperPlusManager to map objects from database.
I map my class like this:
DapperPlusManager.Entity<Order>()
.Key(order => order.OrderID)
.Table("zzz.customers");
I would like to receive the table name and the column name in my dao class. Is it possible?
Disclaimer: I'm the owner of Dapper Plus
That is currently impossible (no easy syntax for it)
I recommend you to create an issue here: https://github.com/zzzprojects/Dapper-Plus/issues and link this Stack Overflow post. We will surely try to find something that will meet your requirement.

Laravel - Translating data after fetching from databsase OR to have translated text in database? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I want to start a multilingual website with Laravel.
Is it a good idea to:
Translate an string from fetched data from database using trans()?
OR
Have three columns for each language with different titles?
For example in number 1 I have:
ID - title
1 - hello
2 - how_are_you
$texts = Text::all();
$translatedText = trans('somefile.'.$texts[0]->title);
And for number 2 I have:
ID - title_fa - title_en - title_ar
1 - درود - Hello - سلام
2 - خوبی؟ - How are you - کیف احوالک؟
$texts = Text::all();
$translatedText = $texts[0]->title_fa;
Which one is better from different aspects?
It depnds on your requirements and the amount of data you would like to change. Both have their own pros and cons.
1. Using translation file:
Your database would be clean and you don't need to worrie about the conditional fields display. So only the effective data would be there no redundant data.
If you are uncentain about text, would be difficult to add translation about that.
2. Using database:
You would have more flexibility to change/update the translated text dynamically from UI interface if you wish.
You can add conditions in Accessor for setting attribute values so not need to worrie inside blade.
You don't need to worrie about the field content becuase there would be separate translated field for that.
Database performance could be impacted if you have large set of data.
So based on your requirements of application you can choose the approach best fit to you.
At last, if you are going with database approach, you should create different translation tables instead of inserting columns in same table.
Like you have 5 fields in table1 where you need to keep translation for 3 fields then you should create different table like table1_translation with those 3 fields and keep only 2 fields in table1

Firebase + AngularFire -> States?

I'd like to know how I would deal with object states in a FireBase environment.
What do I mean by states? Well, let's say you have an app with which you organize order lists. Each list consists of a bunch of orders, so it can be considered a hierarchical data structure. Furthermore each list has a state which might be one of the following:
deferred
open
closed
sent
acknowledged
ware completely received
ware partially received
something else
On the visual (HTML) side the lists shall be distinguished by their state. Each state shall be presented to the client in its own, say, div-element, listing all the related orders beneath.
So the question is, how do I deal with this state in FireBase (or any other document based database)?
structure
Do I...
... (option 1) use a state-field for each orderlist and filter on the clientside by using if or something similar:
orderlist1.state = open
order1
order2
orderlist2.state = open
order1
orderlist3.state = closed
orderlist4.state = deferred
... (option 2) use the hierarchy of FireBase to classify the orderlists like so:
open
orderlist1
order1
order2
orderlist2
order1
closed
orderlist3
deferred
orderlist4
... (option 3) take a totally different approach?
So, what's the royal road here?
retrieval, processing & visual output of option 2
Since for option 1 the answer to this question is apparantly pretty straight forward (if state == ...) I continue with option 2: how do I retrieve the data in option 2? Do I use a Firebase-object for each state, like so:
var closedRef = new Firebase("https://xxx.firebaseio.com/closed");
var openRef = new Firebase("https://xxx.firebaseio.com/open");
var deferredRef = new Firebase("https://xxx.firebaseio.com/deferred");
var somethingRef = new Firebase("https://xxx.firebaseio.com/something");
Or what's considered the best approach to deal with that sort of data/structure?
There is no universal answer to this question. The "best approach" is going to depend on the particulars of your use case, which you haven't provided here. Specifically, how you will be reading and manipulating the data.
Data architecture in NoSQL is all about working hard on writes to make reads easy. It's all about how you plan to use the data. (It's also enough material for a chapter in a book.)
The advantage to "option 1" is that you can easily iterate all the entire list. Great if your list is measured in hundreds. This is a great approach if you want to fetch the list and manipulate it on the fly on the client side.
The advantage to "option 2" is that you can easily grab a subset of the list. Great if your list is measured in thousands and you will typically be fetching open issues only rather than closed ones. This is great for archiving/new/old lists like yours.
There are other options as well.
Sorted Data using Priorities
Perhaps the most universal approach is to use ordered data. This allows you to query a subset of your records using something like:
new Firebase(URL).startAt('open').endAt('open').limit(10);
This is sufficient in most cases where you have only one criteria, or when you can create a unique identifier from multiple criteria (e.g. 'open:marketing') without difficulty. Examples are scoreboards, state lists like yours, data ordered by timestamps.
Using an index
You can also create custom subsets of your data by creating an index of keys and using that to fetch the others.
This is most useful when there is no identifiable characteristic of your subsets. For example, if I pick them from a list and store my favorites.
I think my this plnkr can help you for this.
Here, click on edit/add and just check the country(order in your case) - State(state in your case) dependent dropdown may be the same as you want.just one single thing you may need to add is filter it.
They both are different tables in db.
You can also get it from git.

Take the qualifiers - postgresql

I'm working on the postgresql 8.4 source code. I need to extrapolate the qualifiers (where part) from the query.
For example if the query is: select name from student where age > 18
I need to know "age" and "18".
I've already took the target list, and the range list in this way
Query *query_idr = (Query *)linitial(querytree_list);
ListCell *l;
ListCell *tl;
foreach(l, query_idr->rtable){
Oid tab_idT = ((RangeTblEntry *) lfirst(l)) ->relid;
}
foreach(tl, query_idr->targetList){
TargetEntry *tle = (TargetEntry *) lfirst(tl);
Oid col_id = tle->resorigtbl;
}
and it works, and I've got the id of the table student (with the first foreach) and id of name column (with the second foreach), but I can't understand how I have to take the qualifier.
Here is the navigable Query structure http://doxygen.postgresql.org/structQuery.html
I doubt you are going to get an answer here. In general hacking the PostgreSQL source code is not likely to have enough people here who can answer it that a general site like this will be helpful. However rather than leave this withough any such resources I would like to reply to provide a list of resources for answering questions like this one as well as my reading of the docs as someone with quite a bit of experience buildign things on Pg.
In essence what you are trying to do is navigate through the parse tree of the query. It looks to me like the setOperations member might be the place to look just because I can't think of anywhere else and because this might help with both join conditions and where clause filters (remember these are considered interchangeable by the planner). However I have little experience in this area and so I could be wrong.
I would entirely second the suggestion that the pgsql-hackers list is likely to be the best place to ask this sort of question. You will probably get a better answer there.

Resources