I have come across some salesforce DB field names like ID, OWNERID etc., which are reserved fieldnames of REFERENCE type. I was searching for some resources where all such types of reserved field names can be found. Would be very much helpful as well as thankful, if somebody can provide some resources or help.
I don't know of a comprehensive list, but you've got:
System Fields
Frequently-Occurring Fields
Custom Object Standard Fields
Standard Objects and their fields
There may be more, but I hope that provides a good start.
Related
Not sure which is the best Stack Exchange site for this, so will try my hand here.
I have a web application that stores user disciplinary data for organisations. Rather than clients enter their staff into multiple systems, some want to push the basic personnel data into ours (data such as First Name, Surname, DOB, Job Title etc) from their source (e.g. HR/ERP) databases.
Our clients are using a range of existing systems to store their data, such as Oracle, SAP, JD Edwards, etc.
I am familiar with the technical methods to get this data (e.g. web service, web API), but not for a case such as when a person's surname changes (e.g. Janet Smith gets married and becomes Janet Doe). Unless there is a unique identifier for that person across both systems, I can't see how that change can be managed reliably.
How is this process best-managed please? Is an additional field added to the destination database that contains the UID of the source data? Or, do both parties agree on a common field, e.g. employee number, that never changes?
This issue arises in many circumstances. One case is in the Texas school system where students are tracked longitudinally through numerous education subsystems. A social security number, providing a unique identifier in some cases (although not all) was considered too sensitive for use. Thus, a unique identifier has been generated for each student and staff member. This is part of the permanent information associated with each individual, regardless of employment change, location change, or name change.
This link describes the rationale for the unique id.
This link is the documentation on the Texas Student Data System (TSDS) unique identifier. You might find the XML examples at the end of the document of most interest. Much of the information involves submitting requests for an id where demographic information is needed for disambiguation.
Basically, something similar to a Java UUID as an extra field in the database should be sufficient to achieve your aim.
Hope this helps.
Yes, the UID is the only solution. This problem comes up in medical systems too, for example. Another is photos, I'm not sure which causes more problems!
I know approach which is using "external_id" field for that. Several external ids can be exploited in case of many systems.
I am kind of new to Salesforce. Could you please let me know what is the difference between Standard Fields and Custom Fields in Salesforce? Can I consider combination of Standard Fields as the unique identifier for a record?
Custom fields are just that. Fields that have been added to the standard Salesforce schema to tailor the data for each object. The user who creates the field can specify the field type and any applicable limitations, such as the maximum number of characters in a text field. These fields might be added to an Org via a managed package or through direct customization.
Standard fields in contrast are those that are already present in the Salesforce schema when a new Organization is created. They are present in all Orgs where the same features are enabled. You can't customize these fields to the same degree. E.g. you could change the display label, but not the underlying API name or data type.
You can see the list of the standard fields in the Salesforce Field Reference Guide
From an API perspective, custom fields are usually identified by a __c suffix (there are a few exceptions, such as GeoLocation fields).
Can I consider combination of Standard Fields as the unique identifier for a record?
You would usually rely on the Id field to be unique. If you wanted to augment this with another unique value, you would create a custom field and mark it as an External ID.
A composite key isn't directly supported. Instead you need to create a Unique Text field and then use a workflow field update or before trigger to populate the unique field with the components of the composite key.
Incidentally, the salesforce.stackexchange.com site is a great place to ask Salesforce specific questions.
The CakePHP cookbook presents the following (http://book.cakephp.org/2.0/en/models/model-attributes.html#schema):
Contains metadata describing the model’s database table fields. Each field is described by:
name
type (integer, string, datetime, etc.)
null
default value
length
Some of these are self-explanatory, but here are my questions:
Name - what's the purpose of this? Is the cakebook just unclearly saying that the other values will be in an array stored under the name of the field, or is this a key that can give a different name, and what would it be for?
Type - I understand what type is, but could someone give me a full list of the options? Hard to say what it is if I don't know what my options are. Are they based on typical database types, or form types, or what?
Null - Is this the same as the not null option of a database? Basically just requiring a value or throwing an error?
I would like to write out each of my table's schemas for various reasons, but I'm a little stuck because of these questions.
Thank you for your help!
you can find most of the answers to your questions yourself.
either you debug the returned data from
$this->Model->schema();
which contains all the fields above.
Or you use the cake shell to create/dump a schema file in /Config/Schema:
cake schema generate
this way you can look at what cake creates.
So if you create a dummy table "foobars" with all kind of field types you will have a full schema reference out of the box for the current cake version you are using. Also you will see your database reflected as cake sees it. meaning: if you set one field to "default not null", the other as "default null" you will see what "null" means. And what type of the database matches what type in cake.
And yes, name is the fieldname. it should be the array key itself, though.
I have the following data structure for creating index.
user
userid
username
userstatus
friends
friendid
friendstatus
friendcreateddate
I think dynamic field wont work for me since I need to query based on specific field names.
I have search based on friendstatus and friendcreateddate. Can someone advise me on best possible document structure?
That is a very simple data structure. You just need to look at an example schema.xml and put your own field definitions in there. A field like "friends" would be declared as multiValued="true" and the userid would be tagged <uniqueKey>
Follow this guide http://wiki.apache.org/solr/SchemaXml
and ignore complicated stuff like dynamic fields which you probably don't need.
Here's three best practices I try to follow when naming tables:
Never name a table with plural (such as "users")
Never name a table using a reserved keyword (such as "user")
Never prefix your table name with "tbl" or some other object type prefix
Keeping all this in mind, how do you recommend naming the table that will hold user identities?
I agree, do not use any reserved words, or quoted or bracketed or escaped forms of reserved words.
Name the User table Person.
You may be interested in this answer and google for the ISO standard 11179 for naming Guidelines
I typically use something like member or account, depending on the application. That said, if you're using modern design tools and principles (e.g., a db abstraction layer or ORM with an object-oriented code base that separates business logic from data access), then table naming becomes fairly irrelevant. Your developers should only ever be accessing the database through a well-defined interface and not by hand-writing SQL that requires them to know the table name. For example, you could name the table account but map access to it via an object named User. Your developers shouldn't be thinking in terms of tables, but in terms of access objects, which aren't going to have the same restrictions on naming:
$user = new User($username);
$user->authenticate($password);
Use a synonym. What word to use depends on what exactly you store in the table, but account strikes me as a good alternative. If you want to use a variation user I'd break the first guideline you mention, not the second or third: users is common enough that the inconsistency is essentially mnemonic.
Do not use reserved words or quoted or escaped words for database table names.
If you really want to do this then you need to escape the names:
quotation marks: "user"
Java + JPA escaping: #Table(name = "\"user\"")
I highly not recommend using plural worlds for database table names like USERS. This is a BAD PRACTICE, against the SQL naming convention. Database table names need to be singular nouns.
I recommend using ACTOR for a database table name to store users details. This name is clear, understandable and enough general. It can be used for companies and individuals as well (not like ex. PERSON, which fit for only person but not companies).
I use CakePHP rules even when I don't use the framework :
Table names are by convention lowercase and pluralized with multi-word table names separated by underscores. For example, a Model name of Ingredient expects the table name ingredients. Model name of EventRegistration would expect a table name of event_registrations.