Get Lookup value in WSS_Content - sharepoint-2016

I try to find where does Sharepoint 2016 store lookup values in database.
I create Person and Gender lists:
I wonder a relation from Gender and Person lists. How Person list can get exactly gender data from Gender list. Could anybody provide me the SQL query to get data.
many thanks

Related

MongoDb conditional relationship

Suppose I have following 4 collections:
1- posts
2- companies
3- groups
4- users
Bellow is my current structure in post:
and their relation is:
A company has an owner and many other members (user collection).
A group has many members (users).
A user has many posts.
A group has many posts that published by one of its members.
A company has many posts that published by its owner or members.
Now i have a problem on storing relation of users, company, and group with posts collection.
Bellow is my current structure:
I have decided to have a field postable inside my post document, and has a type field that will be 'user', or 'group', or 'company', and two other fields name, and id that will be company/group id and company/group name in cases that post is belonged to company or group but not user means type="group" || type="company".
Now how i can handle this to map id as FK of group and company collection (one field FK of two collection) ?
Is it the right structure ?
What you have here is a polymorphic association. In relational databases, it is commonly implemented with two fields, postable_id and postable_type. The type column defines which table to query and id column determines the record.
You can do the same in mongodb (in fact, that is what you came up with, minus the naming convention). But mongodb has a special field type precisely for this type of situations: DBRef. Basically, it's an upgraded id field. It carries not only the id, but also collection name (and database name).
how i can handle this to map id as FK of group and company collection (one field FK of two collection)?
Considering that mongodb doesn't have joins and you have to load all references manually, I don't see how this is any different from a regular FK field. Just the collection name is stored in the type field now, instead of being hardcoded.

Retrieve the data from the relationship in parse DB through Rest API

I am been going through the parse DB but got stuck at one issue. The issue is How can I retrieve the data from the relationship in parse DB.
For ex: I have two table
Department
Employee
Department table structure is:
ObjectId
departmentId
deparmentName
Employee table structure is:
ObjectId
EmployeeName
Age
department
In the Employee table i have created one column with department and added the relation With Department table.
I have successfully added the records and created a relation. And when i am clicking on View Relation in department column i am getting the data for the associated Department.
I have given the curl command to get the data:
Curl -X GET <my application Id> <my rest api key>
https://api.parse.com/1/classes/Employee
I am getting the result as
{"results":[{"department":{"__type":"Relation","className":"Department"},"createdAt":"2015-08-07T08:53:23.220Z","objectId":"AkceV0fwW","updatedAt":"2015-08-07T09:04:45.362Z","userName":"XYZ"}]}
Now how to retrieve the objectId of the Department in this result means I want to get the department name for this Employee.
Department class doesn't have an objectId, instances of that class do, and your statement means you're thinking about the relationship query backwards.
The relation holds multiple instances (potentially). If you just want one then you should use a pointer as it's much easier.
With a relation you use the objectId of the container and the name of the relation to do a query on the contained class:
GET https://api.parse.com/1/classes/Department
'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Employee","objectId":"AkceV0fwW"},"key":"department"}}'

Selecting columns from different entities

I don't know whether I should be drawing parallels, but unfortunately, that's the only way I can express my issue.
In SQL, suppose we have two tables:
Employee with columns Employee ID, Employee Name, Dept. ID
Deptartment with columns Dept. ID, Dept Name
The Dept ID. in the Employee table is a foreign key with that in the Department table.
Now suppose I want to fetch the following columns:
Employee ID, Employee Name, Department Name
using a SQL such as:
SELECT A.EMPLOYEE_ID, A.EMPLOYEE_NAME, B.DEPT_NAME
FROM EMPLOYEE A, DEPARTMENT B
WHERE A.DEPT_ID = B.DEPT_ID
How would one do this using Core Data in Swift? I guess I'm getting confused by only seeing references to
NSFetchRequest(entityName: entityName)
where the entityName refers to a single entity (table in relational DB lingo)
I'd really appreciate any pointers or examples that can help me clear my doubts.
Thanks
It is certainly possible to create a fetch request that is equivalent to your SQL query. More complex queries can be difficult if not impossible to achieve with a single fetch request. But I recommend trying NOT to draw parallels between CoreData and SQL, at least until you have got to grips with how it works.
To take your example, in the CoreData view of the world, Employee would be an entity with a relationship to another entity, Department. A fetch request based on the Employee entity will return an array of Employee objects, and (assuming you create subclasses of NSManagedObject for each entity) you can access the attributes with simple dot notation:
let employeeName = myEmployeeObject.employeeName
But you can use the same notation to traverse relationships equally easily:
let departmentName = myEmployeeObject.department.departmentName
You don't need to worry about joins, etc; CoreData handles that for you.
Now, suppose you try to do it "the SQL way". You can construct a fetch request based on the Employee entity, but specify "properties to fetch" which likewise traverse the relationship:
let fetch = NSFetchRequest(entity:"Employee")
fetch.propertiesToFetch = ["employeeID", "employeeName", "department.departmentName"]
For this to work, you would need to specify the "resultType" for the fetch request to be DictionaryResultType:
fetch.resultType = .DictionaryResultType
The results from this query would be an array of dictionaries containing the relevant keys and values. But the link with the underlying objects is lost. If you subsequently want to access any details from the relevant Department (or even the Employee), you would have to run a new fetch to get the object itself.

How to call the elements in jsf page when join is used

I have three tables student , result , student_result
In Student entities are Id ,name
In result entities are studentId, marks
In student_result entities is StudentId
In jsf page i have to display name by using studentid in intermediary table.
and i dont know how to pass the value in jsf page . Please help me for that
You can access all the data of student using "Student Id". Just you need to define relationship between the tables and then recapture the database again. Then you can access all other field/properties of students.

Getting distinct list of ID's in CoreData

What's the most efficient way to perform this query on a CoreData table? To use the standard employees database model -- I want DISTINCT department ID's for all departments that contain employees with job-description "chef." As it happens, there is only a single table (Employees) relevant here -- I don't actually have a departments table, just department ID's that are repeated.
Given the schema you describe, I would execute a fetch with a predicate (format string) like #"jobDescription LIKE 'chef'" and then use key-value coding to get the unique values from the resulting array:
[result valueForKeyPath:#"#distinctUnionOfValues.departmentID"];
or create a set:
NSSet *deparmentIDs = [NSSet setWithArray:[result valueForKey:#"departmentID"]];
Depending on the size of the problem (how many employees), doing the final step in-memory may prove prohibitive. At this point, you'll have to create a Department entity and do the work to make sure you connect appropriate employees to each department. Then you can do a fetch of Departments with a predicate (format string) like #"ANY employees.jobDescription LIKE 'chef'" to get the departments with chef employees.