See the image below,say if i i/p z,i need to get o/p as x.
This is used to find parents and grand parents.
Can i do this using Mysql.
Any help in this would be appreciated.
Can this be done using facebook fql
You can use the user_relationships permissions on facebook to retrieve information about a users family. However this requires the user to actually define people as their family members. Here is a link to the permissions page. Once you have determined which permissions you need, you can read here and learn how to implement the permission dialog into your application.
Hierarchies are complicated in MySQL. I don't think you can store a bunch of custom stuff in fql so you probably can't do it that way unless it's a built in feature.
Here's an article about MySQL hierarchies:
http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-MySQL.html
See also this question with good answers:
Hierarchical Data in MySQL
There are even books written on the subject:
http://www.amazon.com/Hierarchies-Smarties-Kaufmann-Management-Systems/dp/1558609202
Complicated, but doable.
Related
I'm about to develop a management web app with Laravel.
I need that my users have different roles with different permission.
In details: some users can add customers, some users can write pieces of a paper related to the customer, some other users can just read that paper and some other users can read just some pieces of that paper.
So I decided to use an RBAC approach in order to gain a certain flexibility.
I'll use this DB schema (just an example schema, but represent the needings of my application):
dbexample
My answer is: since there is a direct relationship between users and paper, customer, attachs etc., how are RBAC rules expressed? I have to check user's permission in frontend when he request an operation or a resource? Or there are ways to express this rules even at backend level? Maybe using some GRANT options?
Hope sby can help.
Thank you!
I would recommend using one of the RBAC packages already available to you, there are a few out there but a couple noteworthy mentions include:
Spatie Permissions
Laratrust
You define roles such as User and Customer, permissions such as can-write-paper, can-read-paper and assign them to either roles or individual users depending on your use case.
I want to build a small Access database to better keep track of the companies we are looking at. I read Access 2010 Inside Out by Conrad/Viescas, did a lot of their examples and had the feeling I understood the basics, so I started with my own data base. Now the struggle begins, I think I have a basic misunderstanding here.
The relation I started with is quite simple: Each company we look at can have listed peers that we want to use to compare this company to. Of course, each company can have many peers and each peer can be the peer of many of our companies. So I modelled this relation as a many-to-many relationship:
Next, I created the form for a company, which looked something like this:
I related the subform I used to show the peers with a query that is based on tblPeersCompanies_1 and gives some additional information. What I now want from a user perspective is straightforward: A user should simply add peers to this subform for the company he is currently viewing. Access should then automatically update tblPeersCompanies_1 and tblPeers_1. The peers really serve no other purpose than to relate them to a company.
However, I struggle implementing this. Adding a new peer to the subform does not work, simply because it is not based on tblPeers_1 and if I enter the information there, Access notices that the peer is not in that table yet. (That is at least what I think the problem is). How can this be achieved though? I don't want the user to open another form, enter the peer first, go back to this form, type the peer again and the other related information. I hope that there must a simple way to do that automatically. Or is this indeed not so simple.
In summary, the question probably can be phrased as: "How to add records to a matching table and a related one-table on the fly in a form?"
Thanks to the great comment by #Remou, I found a solution to this problem. It contais three steps:
Use a combo box as outlined in another SO post
Use this function to automatically enter new records in case the peer is missing. Call this function in the "On Not in List" event
Show other values from tblPeers by linking it to the selected value in the combo box, as explained here
I have to say, this is much harder than I hoped it to be. Let's hope that the learning curve is steep and that it will at least be easy to use for the user and quite robust.
I am interested in the underlying data structure of the database and the way stackoverflow manages tags. I am about to build application that will rely entirely on tag based filters and I seek for the right approach. What is the best way to design the database, so a minimum queries will have to run in future when working with the sets of tags to filter my data. I did use the search, but couldn't find what I am looking for.
Stackoverflow does not rely entirely on SQL database to work with tags. They cache, pre-sort and pre-aggregate them aggressively.
Read this interesting story of one optimization.
From there you can get some insights on how stackoverflow works.
I don't know if they do it well, but you may want to look at Drupal taxonomy for ideas (http://drupal.org/documentation/modules/taxonomy). If you run the installation, you can look at how they handle this in the generated db.
i have an entity with a lot of fields(like facebook user Information with multiple levels like Basic Information, Contact Information, and...). and i want to use it exactly like facebook . i mean i want several tabs to put related fields in there. the easiest way is to store all of them in a table but it's too nasty . is there any way to do this better? i know something about database hierarchical design, but is there a way to do this in symfony 1.4 and use it's form creator either?
thanks.
First of all: where do you need help? In the view or in the model?
If you want it too look like Facebook, we're talking View. This has nothing to do with Symfony, but just HTML (with some CSS/JS probably).
If you're talking about how to store this information: the information your describing isn't "hierarchical". Hierarchical is about trees and things like that, most of the time with an almost infinite depth.
Here you're talking about a strict structure (you, as developer, know exactly which fields you want to render, and define these yourself). You could look into Entity-Attribute-Value stores. But beware: when implementing some like this in mySQL, it won't be easy to do 'complex' queries. (Even a query like: "List all people in New York, older than 30 years old", is not rendered easy).
So why won't you go with a table with a lot of columns? There's nothing nasty about that! That you, as a human being, may have troubles viewing these data in phpMyAdmin, has nothing to do with how a computer manages this information ;-). You could split up the 'User' model in a seperate 'UserProfile' model (with a one-on-one relation), so you can easily refer to users on other pages (where you don't need all profile data).
You can use Doctrine Nested sets. It is basically a tree structure contained in your database. I have a demo of how this can be used, but the source code might scare you.
Take a look at the demo to give you an idea of what you can do. If you are leaning towards this option, then you should definitely check out the tutorial link I posted below to get started.
Demo
Source Code
Doctrine Nested Sets Documentation
Tutorial on Nested Sets
I am rolling my own blogging system and I am wondering how to determine permissions and implement them in a blogging system?
What should be the permissions for a commenter, a blogger and an admin?
What is the best way to implement them?
You didn't mention what language/framework you're using. Django includes a very useful and complete set of permissions that you can get up and running with. I'd assume that there are a number of other web frameworks that do the same.
Therefore, my advice is to find a web framework that you like and think is fun (this sounds like a personal project after all) that will handle these kinds of things for you.
I'd go with a combination of a decoupled authentication component, that you can ask if the current user has the role X, and if so allow them to do the thing. That way you can leave the specifics of groups and expiry etcetera to the authentication component.
You could combine this with some specialized authentication for your blogging engine, eg. having a list of posters in the blog object, and always allowing those persons to make posts.
Give each user a "privilege" value and store it in the users table in the database.
for example:
0: plain user (can comment)
1: writer (can write new posts and modify his own posts)
2: moderator (accepts/deletes comments)
4: admin (access to all)
Use a combination of serverside sessions and cookies for logins.
For "advanced" user privileges, use bitmasks and create groups.
Bitmasking: for example, using previous values, user level 3 (2+1) would have both writer and moderator privileges.